Skip to content

Do not include xfId in CellStyleXfs XML#1325

Merged
tonyqus merged 1 commit into
nissl-lab:masterfrom
jones-gareth:bug/xfIdInCellStyle
May 4, 2024
Merged

Do not include xfId in CellStyleXfs XML#1325
tonyqus merged 1 commit into
nissl-lab:masterfrom
jones-gareth:bug/xfIdInCellStyle

Conversation

@jones-gareth
Copy link
Copy Markdown
Contributor

This fix removes the xfId attribute from xf elements in the cellStyleXfs collection.

When writing the styles.xml file NPOI includes a xfId attribute in the xf elements of the cell style format collection

<cellStyleXfs count="1">
    <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
</cellStyleXfs>

The xfId attribute is meaningless in cellStyleXfs collections. The xf record is also used in the cellXfs collection where xfId is an index into cellStyleXfs.

If you load a generated file into Excel and save it the xfId is stripped out of cellStyleXfs elements.

Unfortunately, inclusion of the xfId attribute in the cellStyleXfs collection can cause other applications to fail. Spotfire will not read a file created with NPOI. Spotfire uses Syncfusion.XlsIO.Implementation.XmlReaders.Excel2007Parse which will crash if an xfId is present on xf records in a cellStyleXfs colllection. Spotfire will read files once the fix in this PR is applied.

@tonyqus tonyqus added bug file_error file format generation/writing issue xssf labels May 3, 2024
@tonyqus tonyqus self-requested a review May 3, 2024 00:22
@tonyqus tonyqus added this to the NPOI 2.7.1 milestone May 3, 2024
@tonyqus
Copy link
Copy Markdown
Member

tonyqus commented May 4, 2024

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug file_error file format generation/writing issue xssf

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants