OpenXML 样式表损坏

OpenXML stylesheet corruption

我在 OpenXML 样式表的第 153 列(为了便于阅读而格式化)出现错误,它似乎是“.”在 0.0% 格式标识符中。谁能看出这里出了什么问题?如果我删除 numFmts,那么问题就会消失。

<?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>

问题的原因是上一行中的空 <x:numFmt> 元素。 numFmtIdformatCode 是该元素中的必需元素。

来自 ECMA 的架构是:

<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>

在这种情况下值得尝试 OpenXml Productivity Tool。它将验证文件以及来自有效文件的反向工程代码。在你的情况下你会得到这样的东西: