Hi,
I have written a sample code to accomplish the task where you may specify non contiguous cells range/area while setting the data series and category data for the chart, you may refer to it and write your own codes accordingly for your needs:
e.g
Sample code:
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Get First Worksheet of the Workbook
Worksheet ws = workbook.Worksheets[0];
string sname = “Data”;
//Add new Data Sheet
ws.Name = sname;
Cells cells = ws.Cells;
cells[“A1”].PutValue(“Aspose.Slides”);
cells[“A2”].PutValue(“Aspose.PDF”);
cells[“A3”].PutValue(“Aspose.Cells”);
cells[“A4”].PutValue(“Aspose.Words”);
cells[“B1”].PutValue(35);
cells[“B2”].PutValue(50);
cells[“B3”].PutValue(65);
cells[“B4”].PutValue(75);
Worksheet ws2 = workbook.Worksheets[workbook.Worksheets.Add()];
ChartCollection charts = ws2.Charts;
int index = charts.Add(ChartType.Line, 5, 0, 15, 5);
Chart chart = charts[index];
chart.NSeries.Add("=Data!B4,Data!B3,Data!B2,Data!B1", false);
chart.NSeries.CategoryData = “Data!A4,Data!A3,Data!A2,Data!A1”;
workbook.Save(“e:\test2\out1.xlsx”);
Hope, this helps a bit.
Thank you.