1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
2: word = new Word.Application();
3: word.Visible = true;
4: Word.Document doc = word.Documents.Add(ref missing, ref missing, ref missing, ref missing);
5: Word.Chart wdChart = doc.InlineShapes.AddChart(Microsoft.Office.Core.XlChartType.xl3DColumn , ref missing).Chart;
6: Word.ChartData chartData = wdChart.ChartData;
7: Excel.Workbook dataWorkbook = (Excel.Workbook)chartData.Workbook;
8: Excel.Worksheet dataSheet = (Excel.Worksheet)dataWorkbook.Worksheets[1];
9: Excel.Range tRange = dataSheet.Cells.get_Range("A1", "B5");
10: Excel.ListObject tbl1 = dataSheet.ListObjects["Table1"];
11: tbl1.Resize(tRange);
12: ((Excel.Range)dataSheet.Cells.get_Range("A2", missing)).FormulaR1C1 = "Bikes";
13: ((Excel.Range)dataSheet.Cells.get_Range("A3", missing)).FormulaR1C1 = "Accessories";
14: ((Excel.Range)dataSheet.Cells.get_Range("A4", missing)).FormulaR1C1 = "Repairs";
15: ((Excel.Range)dataSheet.Cells.get_Range("A5", missing)).FormulaR1C1 = "Clothing";
16: ((Excel.Range)dataSheet.Cells.get_Range("B2", missing)).FormulaR1C1 = "1000";
17: ((Excel.Range)dataSheet.Cells.get_Range("B3", missing)).FormulaR1C1 = "2500";
18: ((Excel.Range)dataSheet.Cells.get_Range("B4", missing)).FormulaR1C1 = "4000";
19: ((Excel.Range)dataSheet.Cells.get_Range("B5", missing)).FormulaR1C1 = "3000";
20: wdChart.ChartTitle.Font.Italic = true;
21: wdChart.ChartTitle.Font.Size = 18;
22: wdChart.ChartTitle.Font.Color = Color.Black.ToArgb();
23: wdChart.ChartTitle.Text = "2007 Sales";
24: wdChart.ChartTitle.Format.Line.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
25: wdChart.ChartTitle.Format.Line.ForeColor.RGB = Color.Black.ToArgb();
26: wdChart.ApplyDataLabels(Word.XlDataLabelsType.xlDataLabelsShowLabel, missing, missing, missing, missing, missing, missing, missing, missing, missing);
27: dataWorkbook.Application.Quit(); |
Partager