views:

543

answers:

0

I've used the Open XML Format SDK 2.0 to create a simple excel document. Opening the document in Excel first requires Excel to open it. I've narrowed this down to the CellFormats within the Stylesheet. The contents of which are below:

<x:styleSheet xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main"&gt;
  <x:numFmts count="4">
    <x:numFmt numFmtId="170" formatCode="_-[$GBP]\ * #,##0.00_-;\-[$GBP]\ * #,##0.00_-;_-[$GBP]\ * &quot;-&quot;??_-;_-@_-" />
    <x:numFmt numFmtId="171" formatCode="_-[$EUR]\ * #,##0.00_-;\-[$EUR]\ * #,##0.00_-;_-[$EUR]\ * &quot;-&quot;??_-;_-@_-" />
    <x:numFmt numFmtId="172" formatCode="_-[$SEK]\ * #,##0.00_-;\-[$SEK]\ * #,##0.00_-;_-[$SEK]\ * &quot;-&quot;??_-;_-@_-" />
    <x:numFmt numFmtId="173" formatCode="_-[$NOK]\ * #,##0.00_-;\-[$NOK]\ * #,##0.00_-;_-[$NOK]\ * &quot;-&quot;??_-;_-@_-" />
  </x:numFmts>
  <x:cellXfs count="5">
    <x:xf />
    <x:xf numFmtId="170" applyNumberFormat="1" />
    <x:xf numFmtId="171" applyNumberFormat="1" />
    <x:xf numFmtId="172" applyNumberFormat="1" />
    <x:xf numFmtId="173" applyNumberFormat="1" />
  </x:cellXfs>
</x:styleSheet>

Once Excel has repaired the file it looks like I expect it. However in order to make it look like expected I had to add the empty cell format as the first child. If one of the proper styles were used as the first child, once Excel had repaired the file that style would have been removed.

Any pointers in the right direction would be greatly appreciated.