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:
|
" codeBody "
private nietige button4_Click (objecten afzender, EventArgs e)
{
Excel.Application oXL = nieuwe Microsoft.Office.Interop.Excel.Application ();
Excel.Workbook oWB;
Excel.Worksheet oWS;
oWB = oXL.Workbooks.Add (Missing.Value);
oWS = (Excel.Worksheet) oWB.Worksheets.get_Item (1);
Excel.Range oResizeRange;
voorwerp misValueDelComp = System.Reflection.Missing.Value;
oResizeRange = oWS.get_Range („A1: C20“, Missing.Value) .get_Resize (Missing.Value, Missing.Value);
Excel.Chart grafiek = AddChart (oWB, „mychart“, de „grafiektitel“, Excel.XlChartType.xlColumnClustered, oResizeRange, Excel.XlRowCol.xlRows);
oWB.SaveAs („TestGraph.xls“, Excel.XlFileFormat.xlWorkbookNormal, misValueDelComp, misValueDelComp, misValueDelComp, misValueDelComp, MyExcel.XlSaveAsAccessMode.xlExclusive, misValueDelComp, misValueDelComp, misValueDelComp, misValueDelComp, misValueDelComp);
}
openbare statische Excel.Chart AddChart (werkboek Excel.Workbook, koord chartSheetName, koordtitel, byRowOrCol Excel.XlChartType chartType, Excel.Range dataRange, Excel.XlRowCol)
{
Excel.Chart grafiek;
grafiek = (Excel.Chart) werkboek. Charts.Add (Type.Missing, Type.Missing, Type.Missing, Type.Missing);
chart.ChartType = chartType;
grafiek. Plaats (Excel.XlChartLocation.xlLocationAutomatic, chartSheetName);
chart.SetSourceData (dataRange, byRowOrCol);
chart.HasTitle = waar;
chart.ChartTitle.Text = titel;
terugkeer grafiek;
}
|