We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Incorrect charts are returned

We are using Aspose Cells 8.2.1


While getting the charts from the worksheet, it returns 2 charts whereas there are no charts in this worksheet.

For your reference I have also attached the source excel file.

Following is the code snippet being used to get charts from the sheet:

private Chart[] getCharts(com.aspose.cells.Worksheet worksheet) {
ChartCollection chartCollection = worksheet.getCharts();
Chart[] charts = new Chart[chartCollection.getCount()];
for (int i = 0; i < chartCollection.getCount(); i++) {
Chart chart = new Chart();
com.aspose.cells.Chart selectedChart = chartCollection.get(i);
chart.setName(selectedChart.getName());
charts[i] = chart;
}
return charts;
}

Kindly let me know what is going wrong here.

Thanks,
Neeraj


Hi Neeraj,

Thanks for your posting and using Aspose.Cells.

We were able to observe this issue after executing the following code using your source Excel file with the latest version: Aspose.Cells
for Java v8.2.1.4
. It returns incorrect number of charts, it returns 2 whereas it should return 0 because there are not any charts inside the worksheet.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSJAVA-41051 - Incorrect number of charts are returned.

I have also shown the console output of the following test code for a reference.

Java

String filePath = “F:\Shak-Data-RW\Downloads\Incorrect+Charts.xls”;


Workbook workbook = new Workbook(filePath);


for (int i = 0; i < workbook.getWorksheets().getCount(); i++)

{

Worksheet worksheet = workbook.getWorksheets().get(i);


System.out.println(worksheet.getCharts().getCount());

}


Console Output:
2

Hi,


We have evaluated your issue further, there are surely two charts on the sheet, so Aspose.Cells works fine to give you two charts in count. For confirmation, please open your Excel file into MS Excel , in Home menu, click the “Find & Select” and then select “Selection Pane” to open Selection and Visibility panel. At the bottom, you may see that there are two charts mentioned.

Thank you.

Thanks for your assistance. I was able to find these charts.


Thanks,
Neeraj

Hi Neeraj,

Thanks for your posting and using Aspose.Cells.

Since it is not a bug of Aspose.Cells and charts do exist inside the worksheet but they are hidden, so we have closed this issue now. Let us know if you encounter any other issue, we will be glad to look into it and help you further.