private leeres button4_Click (Gegenstandabsender, EventArgs e)
{
Excel.Application oXL = neues 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;
Gegenstand misValueDelComp = System.Reflection.Missing.Value;
oResizeRange = oWS.get_Range („A1: C20“, Missing.Value) .get_Resize (Missing.Value, Missing.Value);
Excel.Chart Diagramm = AddChart (oWB, „mychart“, „der Diagrammtitel“, 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);
}
allgemeiner Static Excel.Chart AddChart (Excel.Workbook Arbeitsbuch, Schnur chartSheetName, Schnurtitel, Excel.XlChartType chartType, Excel.Range dataRange, Excel.XlRowCol byRowOrCol)
{
Excel.Chart Diagramm;
Diagramm = Arbeitsbuch (Excel.Chart). Charts.Add (Type.Missing, Type.Missing, Type.Missing, Type.Missing);
chart.ChartType = chartType;
Diagramm. Position (Excel.XlChartLocation.xlLocationAutomatic, chartSheetName);
chart.SetSourceData (dataRange, byRowOrCol);
chart.HasTitle = richten aus;
chart.ChartTitle.Text = Titel;
Rückholdiagramm;
}
|