@@ -12,40 +12,7 @@ static void Main(string[] args)
1212 //Create a new Word document.
1313 using ( WordDocument document = new WordDocument ( ) )
1414 {
15- //Add a section to the document.
16- IWSection section = document . AddSection ( ) ;
17- //Add a paragraph to the section.
18- IWParagraph paragraph = section . AddParagraph ( ) ;
19- //Create and append the chart to the paragraph.
20- WChart chart = paragraph . AppendChart ( 446 , 270 ) ;
21- //Set chart type.
22- chart . ChartType = OfficeChartType . Pie ;
23- //Set chart data.
24- chart . ChartData . SetValue ( 2 , 1 , "Food" ) ;
25- chart . ChartData . SetValue ( 3 , 1 , "Fruits" ) ;
26- chart . ChartData . SetValue ( 4 , 1 , "Vegetables" ) ;
27- chart . ChartData . SetValue ( 5 , 1 , "Dairy" ) ;
28- chart . ChartData . SetValue ( 6 , 1 , "Protein" ) ;
29- chart . ChartData . SetValue ( 7 , 1 , "Grains" ) ;
30- chart . ChartData . SetValue ( 2 , 2 , "Percentage" ) ;
31- chart . ChartData . SetValue ( 3 , 2 , 36 ) ;
32- chart . ChartData . SetValue ( 4 , 2 , 14 ) ;
33- chart . ChartData . SetValue ( 5 , 2 , 13 ) ;
34- chart . ChartData . SetValue ( 6 , 2 , 28 ) ;
35- chart . ChartData . SetValue ( 7 , 2 , 9 ) ;
36- //Set region of Chart data.
37- chart . DataRange = chart . ChartData [ 2 , 1 , 7 , 2 ] ;
38- //Set chart series in the column for assigned data region.
39- chart . IsSeriesInRows = false ;
40- //Set a Chart Title.
41- chart . ChartTitle = "Pie Chart" ;
42- //Set Datalabels.
43- IOfficeChartSerie serie = chart . Series [ 0 ] ;
44-
45- serie . DataPoints . DefaultDataPoint . DataLabels . IsValue = true ;
46- //Set legend.
47- chart . HasLegend = true ;
48- chart . Legend . Position = OfficeLegendPosition . Bottom ;
15+
4916 //Create a file stream.
5017 using ( FileStream outputFileStream = new FileStream ( Path . GetFullPath ( @"Output/Output.docx" ) , FileMode . Create , FileAccess . ReadWrite ) )
5118 {
0 commit comments