Skip to content

Fix #352 — Pivot table corruption, sheetFormatPr/pageMargins defaults, workbook namespaces - #354

Merged
MathNya merged 3 commits into
MathNya:masterfrom
yoonghm:fix/issue-352-pivot-and-sheet-corruption
Aug 14, 2026
Merged

Fix #352 — Pivot table corruption, sheetFormatPr/pageMargins defaults, workbook namespaces#354
MathNya merged 3 commits into
MathNya:masterfrom
yoonghm:fix/issue-352-pivot-and-sheet-corruption

Conversation

@yoonghm

@yoonghm yoonghm commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #352

Issues fixed

  1. Pivot table infrastructure silently dropped on write — Added rowGrandTotals, colGrandTotals, compactData, xr:uid, and refreshOnLoad attributes to PivotTableDefinition. Fixed RowItem to support multiple <x/> children (one per row field). Added pivot cache records preservation through the reader→writer pipeline.

  2. Empty sheetFormatPr from minimal template sheets — Writer now always emits defaultRowHeight (default: 14.25) and x14ac:dyDescent (default: 0.45) even when the template didn't supply them.

  3. Zero pageMargins from minimal templates — Writer now replaces all-zero margins with sensible defaults (left=0.7, right=0.7, top=0.75, bottom=0.75, header=0.3, footer=0.3).

  4. Workbook namespace declarations stripped — Writer now emits the standard Excel namespace set: xmlns:mc, xmlns:x15, xmlns:xr, xmlns:xr2, xmlns:xr6, xmlns:xr10, mc:Ignorable.

  5. Stale calcChain.xml — Verified: calcChain is never written (Excel regenerates it on open).

  6. missingItemsLimit on pivotField — Added read/write support for the missingItemsLimit attribute (0 = None, no limit on retained items per field).

Files changed (13)

  • src/helper/const_str.rs
  • src/reader/xlsx.rs
  • src/reader/xlsx/pivot_cache.rs
  • src/reader/xlsx/pivot_table.rs
  • src/structs/page_margins.rs
  • src/structs/pivot_cache_definition.rs
  • src/structs/pivot_field.rs
  • src/structs/pivot_table_definition.rs
  • src/structs/row_item.rs
  • src/structs/sheet_format_properties.rs
  • src/structs/writer_manager.rs
  • src/writer/xlsx/pivot_cache.rs
  • src/writer/xlsx/workbook.rs

1. Issue 1 (High): Pivot table infrastructure silently dropped on write
2. Issue 2 (High): Empty sheetFormatPr from minimal template sheets causes Excel XML error
3. Issue 3 (Medium): calcChain.xml left stale after sheet modifications
4. Issue 4 (Low): Workbook namespace declarations stripped
5. Issue 5 (Medium): refreshOnLoad attribute on pivotTableDefinition is not preserved
6. Issue 6 (Medium): missingItemsLimit attribute on pivotField element is not preserved.
@yoonghm yoonghm changed the title The branch covers issues reported in https://github.com/MathNya/umya-… Fix #352 — Pivot table corruption, sheetFormatPr/pageMargins defaults, workbook namespaces Aug 5, 2026
@c-git

c-git commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Just a question for my own education. For 3. is there a reason we need to replace the zero margins?

Never mind, I saw the comment in the code. Hadn't looked at the code yet.

Comment thread src/structs/pivot_table_definition.rs Outdated

#[inline]
#[must_use]
#[deprecated(since = "3.0.0", note = "Use xr_uid()")]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you adding deprecated functions?

Comment thread src/structs/row_item.rs Outdated
#[must_use]
pub fn member_property_index(&self) -> Option<&MemberPropertyIndex> {
self.member_property_index.as_ref()
pub fn member_property_indices(&self) -> &[MemberPropertyIndex] {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a breaking change?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the whole point is to change it to a list but from reading the PR description I wasn't aware it contained breaking changes.

yoonghm added 2 commits August 8, 2026 09:48
Removed deprecated getter methods for various properties in pivot_table_definition.
@MathNya

MathNya commented Aug 14, 2026

Copy link
Copy Markdown
Owner

@yoonghm
Thank you for the PR.
I don't see any issues with the changes, so I'll go ahead and merge them.

@MathNya
MathNya merged commit 6c3c82a into MathNya:master Aug 14, 2026
0 of 5 checks passed
@yoonghm
yoonghm deleted the fix/issue-352-pivot-and-sheet-corruption branch August 14, 2026 18:49
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.

Pivot table infrastructure silently dropped on write

3 participants