date_cells hashed every non-date number of a column into the General set even
when no cell of the column was a date, which a numeric General row field paid
for on every refresh. The set is now built only when some flag is set.
The General-wins rule ran in item interning, which only sees records that pass
the report filter, so filtering out the General cell made its number sort as a
date. The date flags are now decided over every record of the column before
filtering, as Excel's cache decides.
Reading every source cell's style made each refresh of a large source much
slower. The source now keeps the sheet row of each record, and the per-cell
date flags are read only for ungrouped row and column fields, one format lookup
per distinct style.
One number in a date cell and in a General cell is one item; its sort class
depended on which cell came first. Any General occurrence now makes it a
number.
The date sort class came from the number format of the column's first data
cell. Excel decides per cell (it caches date-formatted cells as <d> and General
ones as <n>), so a General first cell made every date sort as a number, and a
date-formatted first cell made General numbers sort as dates. The source now
records, per cell, whether its own format is a date, and the class follows that.
The ascending item order put dates between text and TRUE/FALSE. Excel's item
lists put numbers, text, logicals, errors, dates and then blanks: in the one
Excel-saved cache in the test corpus whose fields mix dates with logicals or
errors (ClosedXML VariousDataTypesInTableColumns), the Mixed Types field lists
10, 14.5, ABC, TRUE, #DIV/0!, 16:30, 8/10/2020, (blank), and the DateTime with
num field puts its numbers before its dates. The sort classes follow that order.
Also adds the regression test for the time items read from an Excel cache.
- Sort scope entries name their field by source column and date grouping
(PivotScopeItem), so Years and Quarters of one date column stay apart when
reading, computing and writing.
- The engine and the writer resolve a scope the same way: a scope naming an
item that's no longer there sorts by the grand total, as it is then saved.
- A field with custom subtotal functions (sumSubtotal...varPSubtotal) has
subtotals on; it shows the automatic subtotal, with a warning.
- Date groups that aren't sorted show in date order, the order of the cache's
group items, instead of source order.
- Sort by the values in a column (autoSortScope references naming items of the
other axis): read, written back and used by the engine, instead of sorting by
the grand total. A scope GridCraft can't represent loads as a sort by label,
with a warning.
- Changing subtotals in Design replaces each field's own subtotal setting.
- A numeric "For empty cells show" caption (Excel stores missingCaption="0")
is written as a number in the value's format.
- With field headers off there's no Values row, so firstDataRow matches.
- A field that isn't auto-sorted keeps its <items> order even when it is cache
order (date groups only when reordered).
Items tied in a sort by value still break ties by label in the sort
direction: over 60 tie groups in the 11 Excel-saved reports no stored order
(pivotField items, sharedItems, first appearance, reversed or not) explains
more than 21, the same as the current rule.
A refreshed PivotTable read from an Excel file now lays out like Excel's:
- Sort by a value field (autoSortScope on data field n): PivotField.sort_by, applied within
each parent; pivot.sort takes `by: "Sum of X"`.
- Captions: rowHeaderCaption, colHeaderCaption, dataCaption, grandTotalCaption and
missingCaption (For empty cells show), field custom names and renamed items (item n).
- Manual item order of fields that aren't auto-sorted.
- Per-field subtotals (defaultSubtotal, with the table default in pivotTableDefinition16),
Repeat Item Labels (fillDownLabels), field number formats, the Values row
(hideValuesRow) and the classic layout (gridDropZones).
- rowGrandTotals/colGrandTotals were read and written the wrong way round.
- Date items sort after text, as in Excel.
All settings are written back to XLSX.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- restore closing braces the line-level merges of side-by-side tests dropped
- new ChartData literals carry the palette field
- the filter-menu shortcut passes the row with the column
- #688's tab tests account for #851's All Sheets button
- Serbian margins for the ruler-margin labels
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>