Overwriting custom workbook properties produces a corrupted workbook

Using Aspose.Cells version 8.2.2.3, overwriting existing custom properties produces a corrupted workbook.


Error message on worbook open :
"Excel found unreadable content in ‘x’. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes.

Workbook can be anything. Attached workbook I used is blank, newly created.

Sample code :

Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(“CustomProperties.xlsx”);
wb.CustomDocumentProperties.Add(“SomeProperty”, “SomePropertyValue”);
wb.Save(“CustomProperties.xlsx”);

Run the code twice on the same workbook to overwrite existing custom property value.
Removing existing custom property first before writing does not corrupt the workbook.

Thanks,
Dean

Hi,


Thanks for the template file.

I observed the issue but I think you may simply add a simple conditional line of struct to cope with it easily:
e.g
Sample code:

Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(“CustomProperties.xlsx”);
if (wb.CustomDocumentProperties.Contains(“SomeProperty”))
{
wb.CustomDocumentProperties.Remove(“SomeProperty”);
}
wb.CustomDocumentProperties.Add(“SomeProperty”, “SomePropertyValue”);
wb.Save(“CustomProperties.xlsx”);


Thank you.

Right. I was able to work around the issue, but I would think Aspose.Cells would throw an error rather than produce a corrupted workbook.

Hi,


Thanks for your suggestion.

As I observed the issue and found that overwriting custom workbook properties produces a corrupted workbook. We will check if we could throw some exception so that the corrupted file should not be produced or we can see there should be some other good way to cope with it. I have logged a ticket with an id “CELLSNET-43186” for your issue. We will look into it to figure it out soon.

Once we have any update on it, we will let you know here.

Thank you.

Hi,

Thanks for your using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for .NET v8.3.0.2 and let us know your feedback.