feat(xls-codec): read and write a cell's own horizontal/vertical alignment - #912
Merged
Conversation
…nment CellXF/StyleXF's leading word (word1) carries alc/alcV -- horizontal and vertical alignment -- and this reader skipped it entirely while the writer always packed the same General/Bottom defaults. Both now resolve through the identical alc<->Alignment and alcV<-> verticalAlignment mapping (xf-colors.ts's resolveHorizontalAlignment/ horizAlignTokenFor and resolveVerticalAlignment/vertAlignTokenFor), mirroring ooxml.js's own xlsx alignment policy: only the four HorizAlign members with a real Alignment counterpart survive (left/center/right/justify; ALCGEN/ALCFILL/ALCCONTCTR/ALCDIST all read as the value-kind default), and only the two VertAlign members with a verticalAlignment counterpart survive (top/middle; ALCVBOT/ALCVJUST/ ALCVDIST all read as the schema's own documented bottom default). The (format, decoration) XF-interning pair write.ts already carried becomes a (format, alignment, verticalAlignment, decoration) tuple, so two cells sharing all four still share one XF record. written-cells.ts's cellCarriesDecoration is renamed cellCarriesFormatting and widened to treat a non-default alignment the same way it already treats a background or a border: a blank cell carrying only alignment now gets a real Blank record instead of being silently dropped, and the reader keeps such a cell on the way back in rather than treating it as an undecorated blank with nothing to say.
…t assumed it was never read cellXfTrailer's own word1 was hardcoded to 0, on the stated assumption that the reader never acted on the payload's leading alignment word -- true when it was written, but a real Excel-written "no explicit alignment" XF actually carries alcV=ALCVBOT(2), not 0. With the reader now resolving that word for real, a bare 0 decodes as genuine top alignment (ALCVTOP=0), and several pre-existing tests that used cellXfTrailer() as a "plain, undecorated XF" shorthand started resolving an alignment they never meant to state. cellXfTrailer now defaults alc/alcV to General/Bottom, matching what a real Excel-written XF with no explicit alignment carries, and takes optional alc/alcV overrides for a test that wants to state one. New coverage in write.test.ts: every Alignment/verticalAlignment member round-trips, absence stays absent, alignment shares an XF with decoration on the same cell, an alignment-only empty cell earns a real Blank record (and one with neither alignment nor decoration still writes nothing), and two cells sharing an alignment share one XF entry.
Adds a Cell alignment section mirroring Cell decoration and Print settings, including the same LibreOffice 26.2.5.2 verification bar in both directions -- every Alignment/verticalAlignment member written by this package opens in LibreOffice with the correct fo:text-align/ style:vertical-align, and a LibreOffice-authored .xls with real alignment reads back correctly through this package's own reader. Removes alignment from the Writer scope and Read-side gaps tables' own gap lists, since it is no longer one -- only per-cell fonts remain alongside formulas there. Updates the root README's and documents.js's own Fidelity-table description of xls-codec's write coverage to match: xls's writer already never touched per-cell fonts (alongside formulas and images), and alignment now joins background/borders/print settings/metadata as a construct that survives xls<->xlsx/ods crossings rather than one of the reasons those pairs are rated below xlsx<->ods.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
|
🎉 This PR is included in version 2.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Contributor
|
🎉 This PR is included in version 6.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
CellXF/StyleXF's leading word (word1) carries alc/alcV -- horizontal and vertical alignment -- and this reader skipped it entirely while the writer always packed the same General/Bottom defaults. Both now resolve through the identical alc<->Alignment and alcV<->verticalAlignment mapping (xf-colors.ts's resolveHorizontalAlignment/horizAlignTokenFor and resolveVerticalAlignment/vertAlignTokenFor), mirroring ooxml.js's own xlsx alignment policy: only the four HorizAlign members with a real Alignment counterpart survive (left/center/right/justify), and only the two VertAlign members with a verticalAlignment counterpart survive (top/middle).
The (format, decoration) XF-interning pair write.ts already carried becomes a (format, alignment, verticalAlignment, decoration) tuple, so two cells sharing all four still share one XF record. written-cells.ts's cellCarriesDecoration is renamed cellCarriesFormatting and widened to treat a non-default alignment the same way it already treats a background or a border: a blank cell carrying only alignment now gets a real Blank record instead of being silently dropped.
Verified against real LibreOffice 26.2.5.2 in both directions: every Alignment/verticalAlignment member this package writes opens in LibreOffice with the correct fo:text-align/style:vertical-align, and a LibreOffice-authored .xls with real alignment reads back correctly through this package's own reader.
Part of #815