Skip to content

Fix Excel ooxml compatibility - #1

Closed
rolandboon wants to merge 5 commits into
litejs:mainfrom
rolandboon:fix/excel-ooxml-compatibility
Closed

rolandboon wants to merge 5 commits into
litejs:mainfrom
rolandboon:fix/excel-ooxml-compatibility

Conversation

@rolandboon

Copy link
Copy Markdown
Contributor

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:

  • Compute dimension from the widest used row/column range, not just the first row
  • Include a complete styles.xml: cellStyleXfs, cellStyles, full cellXfs, fonts in schema order with <b val="1"/>, and 8-digit ARGB fill colors
  • Place dimension before sheetViews and fix freeze-pane topLeftCell when rows/cols is 0

I'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).

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.
@lauriro

lauriro commented Aug 11, 2026

Copy link
Copy Markdown
Member

Hi, thank you for those fixes.
Not sure why, but I did not see them earlier.

As I have fixed same things locally before I saw your work, I will try now to pick the best from both work and release it.

@lauriro

lauriro commented Aug 12, 2026

Copy link
Copy Markdown
Member

Most of stuff should be in v26.8.0, thank you for Validator!

I belive opening issue before PR should notify me and there would not be such merge issues.

@lauriro lauriro closed this Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants