Chart with No Data causes XLSX to become corrupt after saving with Aspose Cells

Hello,

When a worksheet contains a Chart which is not associated with any cell data, the Workbook becomes corrupt after it is saved by Aspose Cells.

This behavior can be seen under the latest Aspose Cells for Java version 21.6, the attached NoDataChart.xlsx file and the following Java code:

String xlFile = [PATH] + "NoDataChart.xlsx";

Workbook wb = new Workbook(xlFile);

String newFile = xlFile.replace(".xlsx", "_aspose.xlsx");
Files.deleteIfExists(Paths.get(newFile));
wb.save(newFile);
System.out.println("Saved Workbook as:  " + newFile);

Running the above code should produce a file similar to the attached NoDataChart_aspose_.xlsx file. If you attempt to open the new file in Excel, a warning appears stating:

“We found a problem with some content in ‘NoDataChart_aspose.xlsx’. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes.”

Key Observations:

  1. The “no data chart” is a Clustered Column Chart type.
  2. If you click ‘Yes’ to the prompt from Excel, it removes the 2 embedded charts in the Workbook (one of which is valid and does have data).
  3. The culprit is the chart with no data. If you remove the chart with no data from the original Workbook, save it (in Excel) and rerun the above code - the newly generated workbook (saved by Aspose) is no longer corrupt.

Environment Details:

  • Aspose Cells for Java 21.6
  • Java version 1.8.0_211
  • Windows 10 OS (but also reproducible under Linux).

File description in the NoDataChart.zip (31.8 KB) attachment:

  • NoDataChart.xlsx: Excel saved workbook to be used by the code above.
  • NoDataChart_aspose.xlsx: Aspose saved workbook which cannot be opened by Excel.
  • Excel_Error.png: Screenshot of error message when the corrupt workbook is opened by Excel.

Thank you!

@oraspose,
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSJAVA-43538 - Chart with No Data causes corrupt XLSX

@oraspose,
This is to inform you that we have fixed your issue now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@oraspose
Please try our latest version/fix:
aspose-cells-21.7.2-java.zip (7.4 MB)

Your issue should be fixed now.
Let us know your feedback.

The issues you have found earlier (filed as CELLSJAVA-43538) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi