Repository navigation
PivotTables: GETPIVOTDATA, Generate GetPivotData, and the PivotTable Analyze/Design tabs - #1189
Herr-Enklo wants to merge 2 commits into
Conversation
The ribbon now shows Excel's two PivotTable tabs while the active cell is in a PivotTable report, and goes back to Home when it leaves. Every group follows Excel 365 in order and control type: Analyze has PivotTable (name, Options), Active Field, Group, Filter, Data, Actions, Calculations, Tools and Show; Design has Layout (Subtotals, Grand Totals, Report Layout, Blank Rows), PivotTable Style Options and the PivotTable Styles gallery. Existing pivot commands are wired where Excel has them; controls for features GridCraft doesn't have yet (slicers and timelines for PivotTables, calculated items, grouping dialogs, OLAP tools, blank rows...) stay visible, disabled, with the reason on hover. Each group is its own function in ribbon/pivot_tabs.rs, so a feature can be wired in where its control already sits. New pieces behind the controls: - pivot.clearAll and pivot.clearFilters (Actions > Clear): Clear All empties the PivotTable but keeps it, as Excel does, instead of deleting it. - pivot.showFieldList (UI): the Field List toggle hides the Fields pane. - Value Field Settings and Change PivotTable Data Source dialogs. - Key tips JT and JY. They are contextual: the matcher switches to a contextual tab only while it shows, so Table Design's JT letters keep working; xtask keytips accepts contextual tab targets and generates tests for the hidden case. - German labels in German Excel's wording (PivotTable-Analyse, Entwurf, ...), checked against the installed German Excel's own labels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GETPIVOTDATA(data_field, pivot_table, [field1, item1], ...) reads a value
shown in a PivotTable report, with Excel's semantics, checked against Excel
365 on synthetic PivotTables:
- data_field is a value field's caption or its source field, case ignored;
pivot_table is any cell or range in the report (#REF! otherwise).
- Pairs name row, column or single-item report filter fields and one of
their shown items: numbers and dates (serials or DATE) match by value,
text matches an item's label. Fields left out stand for their total, or
for the one item the named items leave (Plums sells only in the West).
- Hidden, filtered and collapsed items, totals turned off and ambiguous
pairs give #REF!; an empty value cell in a cross tab is 0; Show Values As
results come back as shown.
Layering: the engine, which lays out reports, now records with each report
what every line and data column stands for (model PivotReport, a runtime
cache on the PivotTable that comparisons ignore). calc evaluates
GETPIVOTDATA from that index alone and depends on the report area, so
refreshes (full recalcs) and edits inside the report reach it. Reports of
PivotTables read from files are indexed on open when the recomputed report
matches the cells on the sheet. GETPIVOTDATA has no _xlfn prefix in files.
Generate GetPivotData (PivotTable Analyze > PivotTable > Options, and File
> Options > Formulas > Use GetPivotData functions for PivotTable
references) is an application setting, on by default: clicking, dragging
back to or arrowing onto a PivotTable value while typing a formula inserts
GETPIVOTDATA("Sum of Sales",$A$3,"Region","East") instead of the
reference, with the sheet when the PivotTable is elsewhere and DATE for
date items.
The PivotTable Analyze tab now uses the index too: Active Field shows the
active cell's field, Field Settings opens Value Field Settings, Expand and
Collapse Field and Ungroup act on it, and Select > Values selects the
value cells.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @vangel76 (#290) and @Herr-Enklo (#1189) for both taking this on. I built both heads (dbf9e5a and dbf7dc7, both on 84acf62) and compared them with Excel on 74 GETPIVOTDATA cells: the 10 in the corpus's
Why they differ on open: #290 recomputes each pivot from its source when the file opens. #1189 only indexes a pivot if the recomputed report matches the cells on the sheet. GridCraft lays items out in source order and Excel sorts them, so that check fails on most files until a refresh. Other differences:
Shared, not specific to either PR:
Everything else matched Excel in both: case-insensitive names, data field by caption or source name, items from cells, either field order, dates and numbers as items, hidden items, totals off, filters, Count, Average and % of total, tabular layout, another sheet. The workbooks and the build script are available if you want them. 🤖 Generated with Claude Code. Reviewed by @Harrison-Booth before posting. |
|
Hi @Harrison-Booth , thanks for the detailed testing and feedback. I’ve made targeted local fixes for the pivot issues and checked selected cases, but I haven’t rerun your full 74-case suite, so I can’t claim the same coverage yet. |
|
@Herr-Enklo thanks. I can share the 74 GETPIVOTDATA cases as a small synthetic workbook, plus the steps I used to build your head and compare it with Excel. I'll post it here once I've checked it holds no private data. If you'd rather start now, the 10 cases that differed from Excel are the ones to look at first. 🤖 Generated with Claude Code. Reviewed by @Harrison-Booth before posting. |
|
@Herr-Enklo the 74 cases are now in the public corpus: https://github.com/Harrison-Booth/gridcraft-corpus/tree/main/excel/getpivotdata. They are the 10 cells in 🤖 Generated with Claude Code. Reviewed by @Harrison-Booth before posting. |
Adds Excel's GETPIVOTDATA, Generate GetPivotData, and the PivotTable Analyze / PivotTable Design contextual tabs (gaps.md §8).
PivotTable Analyze and PivotTable Design tabs
ribbon/pivot_tabs.rs, so follow-up work can wire them in directly.pivot.clearAll(empties the PivotTable and keeps it, as Excel does; the old Clear All deleted it),pivot.clearFilters,pivot.showFieldList.GETPIVOTDATA
The rules below were checked against Excel 365 on synthetic workbooks:
pivot_tablemay be any cell or range in the report.#REF!.How it is built:
model::PivotReport, not saved)._xlfn.prefix; the formula round-trips through XLSX."Values"pseudo-field pair, and arrays of items.Generate GetPivotData
GETPIVOTDATA("Sum of Sales",$A$3,"Region","East"), as Excel does.DATE(), and follows the formula locale's separators.Tests
crates/engine/tests/getpivotdata.rs(11):cargo xtask ci: all 8 steps pass (1627 tests).🤖 Generated with Claude Code