Format string incorrectly saved in XLSX

Hi!

We think we may have found an issue where Aspose Cells does not correctly store format strings in the styles.xml part of an XLSX file. I’ll keep everything simple here so I’ll include information relevant for the problem.

We create an XLSX using Aspose.Cells through a very complex mechanism (too complex to put in a single testing app), but essentially we’re ending up with the following entry in styles.xml:

<numFmt numFmtId="178" formatCode="#,##0;CHF-#,##0" />

When opening that XLSX file Excel complains about a corrupted styles.xml and repairs it. If we manually change the styles.xml entry to the following entry, Excel does not complain:

<numFmt numFmtId="178" formatCode="#,##0;\C\H\F-#,##0" />

Aspose.Cells does not seem to write escape characters and we are wondering whether you know about this issue and if you can solve it in a future version.

BR,
Bernd

@bernd.podhradsky,

Thanks for the details.

We conducted a test implementing your scenario/case a bit. When setting custom formatting directly with string like “#,##0;CHF-#,##0”, it will generate corrupted file you talked about. We cannot fix invalid custom strings automatically so you have to give the correct custom string for the style in your code accordingly. You may either escape every character by ‘\’ or escape them together by custom string like following:
style.Custom = "#,##0;\"CHF\"-#,##0";

Hope, this helps a bit.