Excel Number format not same as in styles.xml when workbook is opened.

R D 6 Reputation points
2022-07-27T23:54:45.25+00:00

225512-excel-options.pngExcel workbook is generated using aspose cells. Generated workbook's styles.xml appears correct. However when the excel workbook is opened, the number format is no longer what it shows in styles.xml.

For example - in this case I would like to have comma as the decimal separator and dot as thousand separator, with one digit after decimal.

The workbook has following specified in the styles.xml :
<numFmt numFmtId="182" formatCode="#.##0,0;[Color3]-#.##0,0"/>
</numFmts>

When this workbook is opened, and when I look at the corresponding number format for the cell, it has been replaced with incorrect format string:
"#,##00;[Color3]-#,##00" which makes the numbers appear incorrect.
225511-workbook.xml
Number -40845,3 appears incorrectly as "-40845,300" - with no thousand separator and incorrect number of decimal places.

Excel options-->advanced options has been set to correctly match the format options.

Any idea what could be wrong here and why Excel is changing the format string?

225521-styles.xml

225531-excel-cell.png

Microsoft 365 and Office Open Specifications
Microsoft 365 and Office Excel For business Windows
{count} vote

3 answers

Sort by: Most helpful
  1. Hung-Chun Yu 981 Reputation points Microsoft Employee Moderator
    2022-08-02T19:34:00.917+00:00

    Hi @R D

    It turned out it's by design.

    The option customer is toggling is an app setting and it has impact only in how user interacts with the application, it has no impact on how file load/save would operate. File content must be written in a way that's invariant across different locales and different app settings. As a result, files are always written using comma and period as the thousands/decimal separator respectively.

    Hung-Chun Yu
    Microsoft Open Specifications Support

    0 comments No comments

  2. R D 6 Reputation points
    2022-08-04T16:37:03.047+00:00

    If this is by design, please explain how one can set number formatting to custom format string, which is different than the standard English one.


  3. R D 6 Reputation points
    2022-08-04T18:37:24.193+00:00

    VB cannot work for us. Excel workbook is generated on the server using a java library. It is not possible to set client-side locale settings, or preferences. Workbook generated needs to set custom format using specified decimal and thousand separator in the cell itself.

    Also, this used to work before, and appears to be broken recently.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.