fix(xlsx): paint merged ranges fully and write styled blank cells - #2
Merged
Merged
Conversation
Two writer gaps left branded report headers striped white where exceljs rendered a solid block: - merge() now materializes every covered cell and shares the master's style object (exceljs semantics), so a fill set on the master — before or after merging — paints the whole range. Spreadsheet apps render each underlying cell of a merge, so a master-only fill covered one position. Merges also count toward rowCount now, so addRow lands below a merged block exactly like exceljs. - The worksheet writer emits value-less cells that carry a non-default style (`<c r="A2" s="3"/>`), instead of dropping them. Blank spacer rows styled via cell().style previously vanished from the file. - The worksheet reader keeps self-closing styled cells so those blanks round-trip through readXlsx; unstyled empties stay dropped. Verified against exceljs as oracle: the report-header pattern (title merge + styled spacer rows + label/value merges) now serializes cell-for-cell identically. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JpaqFKiTLyBFcYZHuqL5G1
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JrxsnGbCRtq7VPskBRoSPr
<mergeCells> appears after <sheetData>, so the reader calling the new style-propagating merge() overwrote covered-cell styles that were just parsed — Excel writes distinct xfs per merge edge (borders), and those must round-trip. Split out recordMerge() for the reader; public merge() keeps the exceljs-matching propagation. Verified ExcelJS's own reader preserves covered-cell styles the same way; regression test fails on the old path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JrxsnGbCRtq7VPskBRoSPr
Owner
Author
|
Reviewed and hardened before merge:
🤖 Generated with Claude Code |
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.
Problem
Report headers built as title merge + styled blank spacer rows + label/value merges rendered with alternating white stripes, where the same code on exceljs produced a solid colour block (found migrating a consumer from exceljs; repro'd byte-level against exceljs output).
Two writer gaps:
C3:F3of a mergedB3:F3stayed white.cell('A2').style.fill = …without a value emitted nothing, so styled spacer rows disappeared entirely (<row r="2"></row>).Fix
Worksheet.merge()materializes every covered cell and shares the master's style object (exceljs semantics) — styling works before or after merging. Merges now also count towardrowCount, soaddRowlands below a merged block exactly like exceljs.<c r="A2" s="3"/>for blank cells with a non-default style; default-styled blanks stay unwritten.readXlsx; unstyled empties stay dropped.Verification
merged-styles.test.ts(exceljs-as-oracle +readXlsxround-trip + model semantics).🤖 Generated with Claude Code
https://claude.ai/code/session_01JpaqFKiTLyBFcYZHuqL5G1