Skip to content

fix(xlsx/pivot): pad rowItems subtotal entries per ECMA-376 spec#47

Open
BubbleWolf wants to merge 1 commit intoiOfficeAI:mainfrom
BubbleWolf:fix/pivot-rowItems-spec-padding
Open

fix(xlsx/pivot): pad rowItems subtotal entries per ECMA-376 spec#47
BubbleWolf wants to merge 1 commit intoiOfficeAI:mainfrom
BubbleWolf:fix/pivot-rowItems-spec-padding

Conversation

@BubbleWolf
Copy link
Copy Markdown

Summary

  • Fix BuildMultiRowItems (N=2 row fields) and BuildTreeAxisItems (N≥3 row fields) to emit the correct number of <x> children per subtotal <i> element
  • ECMA-376 §18.10.1.44 requires exactly fieldCount - r children, but subtotal entries only emitted 1 regardless of depth
  • Pad with the "default" item index for each deeper field so Excel can correctly rebuild the row hierarchy on manual refresh

Root Cause

Subtotal rows represent an aggregate across all children. The code emitted only the current level's value as a single <x> child, but the spec requires values for all deeper fields too (using the "default" item index — the last entry in each pivotField's items list). Without padding, Excel's pivot refresh engine cannot reconstruct the row hierarchy and shows an empty data area.

Test plan

  • Generate a pivot with 2 row fields (e.g. rows=Region,Country) and verify subtotal rows render correctly in Excel after manual refresh
  • Generate a pivot with ≥3 row fields (e.g. rows=Region,Country,Category,Product) and verify the same
  • Verify column items are unaffected (col subtotals use a separate code path)

BuildTreeAxisItems (N>=3) and BuildMultiRowItems (N=2) emitted fewer
<x> children than required for subtotal <i> elements. ECMA-376
§18.10.1.44 requires exactly (fieldCount - r) children per entry.

Pad subtotal entries with the "default" item index for each deeper
field so Excel can correctly rebuild the row hierarchy when the user
manually refreshes the pivot table.
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.

1 participant