I got the exception because I was using data entered into the same sheet so please ignore my previous posting as it works okay for chart type. thank you!
@tedc,
Aspose.Cells has replaced Aspose.Excel that is no more under active development now. This new product contains lot of advanced features to generate charts supported by different latest versions of MS Excel. Here is an example that creates a chart on a separate chart sheet.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet dataWorksheet = workbook.Worksheets[0];
// Adding a new worksheet to the Workbook object
int sheetIndex = workbook.Worksheets.Add(SheetType.Chart);
// Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet chartWorksheet = workbook.Worksheets[sheetIndex];
// Adding sample values to cells
dataWorksheet.Cells["A1"].PutValue(50);
dataWorksheet.Cells["A2"].PutValue(100);
dataWorksheet.Cells["A3"].PutValue(150);
dataWorksheet.Cells["A4"].PutValue(110);
dataWorksheet.Cells["B1"].PutValue(260);
dataWorksheet.Cells["B2"].PutValue(12);
dataWorksheet.Cells["B3"].PutValue(50);
dataWorksheet.Cells["B4"].PutValue(100);
// Adding a chart to the worksheet
int chartIndex = chartWorksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 5, 0, 15, 5);
// Accessing the instance of the newly added chart
Aspose.Cells.Charts.Chart chart = chartWorksheet.Charts[chartIndex];
// Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
chart.NSeries.Add("='Sheet1'!A1:'Sheet1'!B4", true);
// Setting the chart type of 2nd NSeries to display as line chart
chart.NSeries[1].Type = Aspose.Cells.Charts.ChartType.Line;
// Saving the Excel file
workbook.Save("output.xls");
}
You may refer to the following article for more information about charts: Charts