0
votes

I'm getting an error on this (formatted for readability) OpenXML stylesheet at column 153, which seems to be the '.' in the 0.0% format identifier. Can anyone see what is wrong here? If I remove the numFmts then the issue goes away.

<?xml version="1.0" encoding="utf-16"?>
<x:styleSheet xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
  <x:numFmts count="2">
    <x:numFmt />
    <x:numFmt numFmtId="164" formatCode="0.0%" />
  </x:numFmts>
  <x:fonts count="2">
    <x:font>
      <x:sz val="11" />
      <x:color rgb="000000" />
      <x:name val="Calibri" />
    </x:font>
    <x:font>
      <x:b />
      <x:sz val="11" />
      <x:color rgb="000000" />
      <x:name val="Calibri" />
    </x:font>
  </x:fonts>
  <x:fills count="1">
    <x:fill>
      <x:patternFill patternType="none" />
    </x:fill>
  </x:fills>
  <x:borders count="1">
    <x:border>
      <x:left />
      <x:right />
      <x:top />
      <x:bottom />
      <x:diagonal />
    </x:border>
  </x:borders>
  <x:cellXfs count="3">
    <x:xf />
    <x:xf fontId="1" applyFont="1" />
    <x:xf numFmtId="164" applyNumberFormat="1" />
  </x:cellXfs>
</x:styleSheet>
1

1 Answers

0
votes

It's the empty <x:numFmt> element in the line above that's the cause of the issue. The numFmtId and formatCode are required elements within that element.

The schema from ECMA is:

<xsd:complexType name="CT_NumFmt">
    <xsd:attribute name="numFmtId" type="ST_NumFmtId" use="required"/>
    <xsd:attribute name="formatCode" type="s:ST_Xstring" use="required"/>
</xsd:complexType>

It's worth trying the OpenXml Productivity Tool in situations like these. It will validate files as well as backwards engineer code from a valid file. In your case you'd get something like this:

Image from the Productivity Tool showing the error