Here are a couple of examples of using Excel with C#:
This example sends a value to cell A1 of a Microsoft Office Excel 2003 worksheet.
Code:
public void EchoStringToCell(string str)
{
Excel.Worksheet sheet1 =
(Excel.Worksheet)this.ThisApplication.Sheets.get_Item(1);
((Excel.Range)sheet1.Cells[1,1]).Value2 = str;
}
This example uses the Add method of the ChartObjects collection to add a chart to a Microsoft Office Excel 2003 worksheet programmatically.
Code:
public void CreateChart()
{
Excel.Worksheet thisWorksheet;
thisWorksheet = thisWorkbook.ActiveSheet as Excel.Worksheet;
Excel.ChartObjects charts =
(Excel.ChartObjects)thisWorksheet.ChartObjects(Type.Missing);
// Adds a chart at x = 100, y = 300, 500 points wide and 300 tall.
Excel.ChartObject chartObj = charts.Add(100, 300, 500, 300);
Excel.Chart chart = chartObj.Chart;
// Gets the cells that define the bounds of the data to be charted.
Excel.Range chartRange = thisWorksheet.get_Range("A5","D8");
chart.SetSourceData(chartRange,Type.Missing);
chart.ChartType = Excel.XlChartType.xlXYScatter;
Excel.SeriesCollection seriesCollection=
(Excel.SeriesCollection)chart.SeriesCollection(Type.Missing);
Excel.Series series = seriesCollection.Item(seriesCollection.Count);
}
This example requires:
Data to be charted, stored in the range from A5 to D8 in the worksheet.
Not sure if this is what you were looking for.