Hi,
I met a problem that if the series range column is too long, e.g. more than 1000 columns, when I set the series range as “Data!B2:AMP5”, the chart displayed with totally wrong series range “Data!B1:F6”.
However, if I set the series range manually, the chart works fine.
Please find the my codes below:
Dim chart = New Aspose.Cells.Charts.Chart()
'chart initialzation codes…
chart.NSeries.Add(“Data!B2:AMP5”, False)
chart.NSeries.CategoryData = (“Data!A2:A5”)
'more chart binding codes…
Hi,
If you are creating the chart from the scratch, please specify explicitly that you are using XLSX file format, see the following line of code that you should use at the start.
e.g
Sample code:
Workbook workbook = new Workbook(FileFormatType.Xlsx);
Using the above line will resolve your issue.
Let me know if you still have any issue.
Thank you.
Thanks for your quick answer.
But I’m afraid, it doesn’t work, the same result it returns to me, any other suggestion?
By the way, my series range column count is 1029.
Hi,
I used the following sample code with latest version/fix: Aspose.Cells for .NET v7.6.0, it works fine. The Series data is set appropriately.
Sample code:
Workbook workbook = new Workbook(FileFormatType.Xlsx);
Worksheet worksheet = workbook.Worksheets[0];
for (int i = 0; i < 10; i++)
{
worksheet.Cells[0, i].PutValue("Slice " + i.ToString());
worksheet.Cells[1, i].PutValue(i);
}
int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.PiePie, 3, 1, 20, 10);
Chart chart = worksheet.Charts[chartIndex];
chart.NSeries.Add(“Sheet1!B2:AMP5”, false);
chart.NSeries.CategoryData = “Sheet1!J1”;
Series series = chart.NSeries[0];
workbook.Save(“e:\test2\out1.xlsx”);
Could you paste your runnable sample code here, we will check your issue soon.
Thank you.
Yes, you are right, it works for me now by setting FileFormatType. My mistakes here, thanks.
Hi,
Good to know that it works for you now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.
Thank you.