Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not include xfId in CellStyleXfs XML #1325

Merged
merged 1 commit into from
May 4, 2024

Conversation

jones-gareth
Copy link
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 xlsx 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
Member

tonyqus commented May 4, 2024

LGTM

@tonyqus tonyqus merged commit 200c5d3 into nissl-lab:master May 4, 2024
2 of 3 checks passed
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 xlsx
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants