Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No numFmt in Styles.xml

I am analyzing an OpenXML Excel file. I check the styles.xml, I find many entries like this:

<xf numFmtId="0" [..]>

However, there are no <numFmt> element in the styles.xml file at all. In such a case, how can I determine the number format for that style?

like image 585
user2347976 Avatar asked Jun 22 '26 20:06

user2347976


1 Answers

If the user applies a custom number format then the styles.xml file will contain numFmt elements like this with a numFmtId and formatCode:

<numFmts count="1">
  <numFmt 
    numFmtId="165" 
    formatCode="0.000"/>
</numFmts>

The numFmtId is then used in the <xf> element to reference the number format.

However, if the user applies a standard or built-in format such as 0.00 then a numFmt element isn't written. The <xf> element still contains a numFmtId but it refers to a built-in format that isn't stored in the file.

Number format ids less than 164 (but most often in the range 0-50) represent builtin formats.

Here is a list of some of the built-in formats form the XlsxWriter documentation.

like image 197
jmcnamara Avatar answered Jun 24 '26 12:06

jmcnamara



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!