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.
Excel writes a pivot cache's date items as ISO dates counting real days from
1899-12-30: a time is 1899-12-30T08:00:00 and serial 1 is 1899-12-31. GridCraft
read them with DATE() rules, which move year 1899 on to 3799, so those items
never matched the report's items. A refresh then put them after every item that
did match, such as (blank), and saving wrote that wrong order into the file.
ISO dates (pivot cache items, t="d" cells) now go through a calendar-date
conversion that counts real days from the epoch, accepts 1900-02-29 as serial
60, and in the 1904 system takes 1899-12-30 as a time's date part. The cache
writer uses the inverse, so serial 1 is written as 1899-12-31 as Excel does.
DATE() keeps its own rules.
- 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>
Brings the branch up to upstream's main (59 more commits). One conflict:
- docs/ui-parity.md: every line of both sides is kept, as upstream's own
merges keep them, in the order of their dates, newest first (upstream
has a change of the 13th now, which goes above this one of the 12th).
Gate: all eight steps, 1580 tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>