ft-3ir.2.1: keep PivotTables on a data connection or the Data Model on XLSX save

A PivotTable whose cache has cacheSource type="external" (a data
connection, or the workbook's Data Model: OLAP caches with saveData="0"
and no records) was read as unsupported and dropped on save with its
cache, and the Data Model part (xl/model/item.data) was never kept.

Such PivotTables are now reported by read_pivots and kept by the
pass-through layer like those on another workbook: table, cache and
records parts unchanged, original cacheId, style ids renumbered. The
connection is looked up in xl/connections.xml to tell the Data Model
from a plain connection. The Data Model part is kept byte for byte
whenever the workbook's connections are kept. A cache on a connection is
kept only with the connections, one on the model only with the model;
otherwise its PivotTable is left as plain cells with one warning.

Checked in Excel with synthetic workbooks: Excel needs the table, cache,
connections.xml and the hidden _xlcn. name of a worksheet connection to
open the file, and item.data to refresh it; the x15:dataModel workbook
extension is not needed and is not kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Harrison Booth
2026-10-15 06:27:02 -05:00
co-authored by Claude Opus 5.5
parent 8732325b58
commit cdb3c163ec
7 changed files with 406 additions and 36 deletions
+1 -1
View File
@@ -594,7 +594,7 @@ fn cond_format_list(s: &Sheet) -> Vec<String> {
}
/// The sheet's PivotTables: those modelled, and those kept unchanged for saving (their source is
/// in another workbook).
/// in another workbook, a data connection or the Data Model).
fn pivot_count(s: &Sheet) -> usize {
let kept = s.preserved.as_deref().map_or(0, |p| p.rels.iter().filter(|r| !r.external && r.rel_type.ends_with("/pivotTable")).count());
s.pivots.len() + kept