I can generate an Excel file when I pass a datatable
into the below function:
public static void ExportDataTableToExcel(DataTable dt, string fil
Take a look at the tutorial here (one of the first Google hits).
It very clearly describe how to make a simple chart in Excel from C# code.
The general idea is like this:
// Add chart.
var charts = worksheet.ChartObjects() as
Microsoft.Office.Interop.Excel.ChartObjects;
var chartObject = charts.Add(60, 10, 300, 300) as
Microsoft.Office.Interop.Excel.ChartObject;
var chart = chartObject.Chart;
// Set chart range.
var range = worksheet.get_Range(topLeft, bottomRight);
chart.SetSourceData(range);
// Set chart properties.
chart.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlLine;
chart.ChartWizard(Source: range,
Title: graphTitle,
CategoryTitle: xAxis,
ValueTitle: yAxis);