Add a shared differential-style list and index pivot formats into it#55
Draft
gthb wants to merge 3 commits into
Draft
Add a shared differential-style list and index pivot formats into it#55gthb wants to merge 3 commits into
gthb wants to merge 3 commits into
Conversation
Introduce a workbook-level list of differential styles (dxf records) that formatting-overlay features reference by index, instead of each feature inlining a full Style. This is the differential-overlay analog of Workbook.styles: where Cell.s indexes a complete cell style, an overlay's dxfId indexes a partial override. The list element type reuses the existing Style type, which is already all-optional; what differs is interpretation (absent property means "leave unchanged", not "use the default") and the list it lives in, not the structure. A separate DiffStyle type would duplicate ~25 identical properties for no structural gain, mirroring OOXML where <dxf> reuses the same children as <xf>. - Workbook.diffStyles?: Style[] (name provisional) - PivotFormat: replace inline `style?: Style` with `dxfId?: integer` indexing into Workbook.diffStyles. BREAKING: this changes the shipped 2.5.0 PivotFormat.style (inline Style) to PivotFormat.dxfId (index). Done intentionally to avoid baking the inline-Style "legacy" deeper before more features depend on it.
Rename the differential-style index field from `dxfId` to `diffStyleId` (PivotFormat.diffStyleId) and update the Workbook.diffStyles docstring and @see references to match. The old name echoed a file-format attribute name; `diffStyleId` keeps the model naming consistent with `diffStyles` and free of format-specific terms. Also drop the "name is provisional" note from the diffStyles docstring — the name is now final.
The formats docstring still said each format carries its differential style inline and that there is no separate style table, and linked the removed PivotFormat.style. Both are now false: formats reference a shared differential style by index. Point at PivotFormat.diffStyleId and Workbook.diffStyles instead.
This was referenced Jun 24, 2026
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.
What
Introduce a shared, workbook-level list of differential (partial) styles, referenced by index, as the single home for formatting that overlays a cell's own style instead of replacing it.
Workbook.diffStyles?: Style[]— an ordered list of partial style overrides. Only the properties present in an entry apply; everything else on the target cell is left as-is. It reuses the existing, already all-optionalStyletype.PivotFormatto reference an entry by index: the inlinestyleis replaced bydiffStyleId?: integer(an index intoWorkbook.diffStyles).Why
Several features overlay formatting on top of a cell's own style rather than replacing it: pivot table formats today, custom table styles (#54) and dynamic/conditional styles later. They all want the same kind of partial override, and they want to share entries rather than each carrying its own inline copy. A single shared list referenced by index models this directly, mirroring how cells already work —
Cell.sindexesWorkbook.styles, and nowdiffStyleIdindexesWorkbook.diffStyles. This is the foundation the other overlay features build on, so it lands first on its own.This replaces the inline
PivotFormat.styleadded in #53. Nothing consumes that field yet, so it is a clean replacement.Design notes
diffStylesreusesStylerather than introducing a separateDiffStyletype:Styleis already entirely optional, so it is structurally exactly what a partial override needs. The differential reading — an absent property means "leave unchanged", not "use the default" — comes from the list an entry lives in.diffStyleIdis a plain index; the first entry is index0. There is no implicit default entry (unlikeCell.s, where0is the default cell style), and an absentdiffStyleIdmeans "no overlay".Open question
How should a pivot format that explicitly blanks formatting be encoded? This PR keeps the existing convention:
PivotFormat.action: 'blank'with nodiffStyleId. An alternative would be a dedicated empty entry referenced like any other. Feedback welcome.Follow-ups (not in this PR)
TableStyleElementreferencingdiffStyleIdinstead of an inline style (prototyped locally).diffStyles, resolve the index references, and dedup equal entries into one shared list.