Fix Excel ooxml compatibility#1
Open
rolandboon wants to merge 5 commits into
Open
Conversation
The dimension element must cover the full used range (CT_SheetDimension). Derive the ref from the maximum column and row index across all rows, including sparse rows and rows wider than the first row.
Emit a complete styleSheet part per SpreadsheetML: cellXfs with numFmtId, fillId, borderId and xfId; required cellStyleXfs and cellStyles sections; CT_Font children in schema order with boolean val attributes; and 8-digit ARGB rgb values (ST_UnsignedIntHex) for solid fills.
Place dimension before sheetViews per CT_Worksheet child sequence. Treat freeze rows and cols of zero explicitly so topLeftCell stays a valid ST_CellRef and xSplit/ySplit are omitted when no split is requested. Detect CommonJS module.exports for the IIFE export target.
Run Microsoft Open XML SDK validation on snapshot xlsx files via npx (@xarsh/ooxml-validator), without adding a package dependency. Wired into the Coverage CI job.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generated XLSX files opened in LibreOffice but Excel 365 reported them as corrupted. This PR fixes Open XML conformance issues so output passes the Microsoft Open XML SDK validator and opens correctly in Excel.
Fixed issues:
styles.xml:cellStyleXfs,cellStyles, fullcellXfs, fonts in schema order with<b val="1"/>, and 8-digit ARGB fill colorsdimensionbeforesheetViewsand fix freeze-panetopLeftCellwhenrows/colsis 0I've extended the unit tests and updated the existing snapshots to reflect these changes.
In the last commit I've added a helper script to validate snapshots against the official Open XML Validator (which helped enormously in fixing these compatibility issues).