Element, attribute, default and enumeration lists come from the Transitional schema
sml.xsd of ECMA-376 5th edition Part 4, checked against Part 1 section 18.10 (read
for this page). Notes marked Excel: come from [MS-OI29500]
(v20260818, notes 2.1.737 to 2.1.803 on 18.10); they are the places where Excel does not do what
the standard says. The viewer on this site reads the cache and the table definitions and lists
them (Pivot caches and Pivot tables tables); it does not rebuild the pivot grid, which is stored
as ordinary cells in the sheet.
Parts
A pivot table is two linked parts plus the sheet cells it fills.
- The pivot cache definition (
pivotCacheDefinition, 18.10.1.67) describes the source data and every source column as acacheField. The workbook lists it inpivotCaches(cacheIdand a relationship id); it is reached through the workbook part’s relationships. - The pivot cache records (
pivotCacheRecords, 18.10.1.68) hold the source rows, onerper row, whensaveDatais true. It is a child part of the definition (relationship inr:id). - The pivot table definition (
pivotTableDefinition, 18.10.1.73) is a part of a worksheet. ItscacheIdpicks the cache. The cells it covers are stored in the sheet like any other cells, so a reader that only wants values need not read the pivot parts.
Pivot cache definition
| Attribute | Type, default | Meaning |
|---|---|---|
r:id | relationship id | the records part |
invalid | boolean, false | cache must be refreshed |
saveData | boolean, true | records are saved |
refreshOnLoad | boolean, false | refresh when the file is opened |
optimizeMemory, enableRefresh | boolean, false and true | memory use; refresh allowed |
refreshedBy, refreshedDate, refreshedDateIso | string; double; dateTime | last refresh |
backgroundQuery | boolean, false | refresh in the background |
missingItemsLimit, recordCount | unsignedInt | how many retired items to keep; number of records |
createdVersion, refreshedVersion, minRefreshableVersion | unsignedByte, 0 | Excel versions |
upgradeOnRefresh, tupleCache, supportSubquery, supportAdvancedDrill | boolean, false | OLAP (multidimensional) cache flags |
Children in order: cacheSource and cacheFields (both required), then
the optional OLAP parts cacheHierarchies, kpis, tupleCache,
calculatedItems, calculatedMembers, dimensions,
measureGroups, maps, and extLst.
cacheSource and worksheetSource
cacheSource has type (required): worksheet,
external, consolidation or scenario; and
connectionId (default 0, an entry of the connections part). It holds one of
worksheetSource or consolidation. worksheetSource has
ref (a range), name (a defined name or table), sheet
and r:id (an external workbook).
Excel: exactly one of ref and name is given;
r:id is the external workbook and the sheet name is at most 31 characters;
refreshedBy is at most 255 characters; backgroundQuery must agree with
the connection’s own background flag; the tuple-cache rules apply to OLAP caches only.
cacheField and sharedItems
cacheField (18.10.1.3) has name (required), caption,
propertyName, serverField (false), uniqueList (true),
numFmtId, formula (a calculated field), sqlType (0),
hierarchy (0), level (0), databaseField (true),
mappingCount and memberPropertyField (false). Children:
sharedItems, fieldGroup, mpMap, extLst.
sharedItems (18.10.1.90) lists the distinct values of the column, each as one of
m (missing), n (number, v double), b
(boolean), e (error text), s (string), d (dateTime), and
carries summary flags with these defaults: containsSemiMixedTypes true,
containsNonDate true, containsString true,
containsDate, containsBlank, containsMixedTypes,
containsNumber, containsInteger and longText false;
minValue, maxValue, minDate, maxDate,
count are optional. The items of a field used for grouping are in
fieldGroup (rangePr for numbers and dates, discretePr for
chosen groups, groupItems).
Records
Each r has one child per cache field, in field order. A child is
x v="n" (index into that field’s sharedItems) or a literal
m, n, b, e, s,
d. A field whose sharedItems is empty stores literals; one with items
stores indices.
Pivot table definition
location (required, first) gives ref (the whole table),
firstHeaderRow, firstDataRow, firstDataCol (required) and
rowPageCount, colPageCount (0). Excel: ref
leaves out the page fields.
Children in order after location: pivotFields,
rowFields, rowItems, colFields, colItems,
pageFields, dataFields, formats,
conditionalFormats, chartFormats, pivotHierarchies,
pivotTableStyleInfo, filters, rowHierarchiesUsage,
colHierarchiesUsage, extLst.
| Attribute group | Names (defaults) |
|---|---|
| identity | name, cacheId, dataCaption (required); tag, updatedVersion, minRefreshableVersion, createdVersion (0) |
| data layout | dataOnRows (false), dataPosition, grandTotalCaption, rowHeaderCaption, colHeaderCaption |
| errors and blanks | showError (false) with errorCaption; showMissing (true) with missingCaption |
| styles | pageStyle, pivotTableStyle, vacatedStyle |
| totals | rowGrandTotals, colGrandTotals (true); asteriskTotals, subtotalHiddenItems, mergeItem (false); visualTotals, showMultipleLabel (true) |
| layout | compact (true), outline (false), compactData (true), outlineData (false), indent (1), showHeaders (true), showEmptyRow, showEmptyCol (false), pageWrap (0), pageOverThenDown (false), showDropZones (true), gridDropZones (false) |
| printing | fieldPrintTitles, itemPrintTitles, printDrill (false) |
| user interface | showItems, showDrill, showDataDropDown, showMemberPropertyTips, showDataTips, showCalcMbrs, enableWizard, enableDrill, enableFieldProperties, preserveFormatting, multipleFieldFilters, customListSort, immersive (true); editData, disableFieldList, useAutoFormatting, published, fieldListSortAscending, mdxSubqueries (false); chartFormat (0) |
| autoformat | autoFormatId and the six apply* flags (attribute group AG_AutoFormat) |
Excel ([MS-OI29500] 2.1.787, notes a to s on pivotTableDefinition): asteriskTotals true means
asterisks are not displayed, and immersive true means the immersive experience is left
on (the standard says the opposite for both); preserveFormatting true means formatting
is preserved on refresh (the standard says discarded); subtotalHiddenItems concerns
hidden items in the page area; mdxSubqueries is not used; autoFormatId
defaults to 1 and must be less than 21 or from 4097 to 4117; dataPosition defaults to
0 when absent; the caption, style and tag attributes are limited to 255 characters.
pivotField, items, row and column fields
pivotFields has one pivotField per cache field, in cache order.
axis is axisRow, axisCol, axisPage or
axisValues; dataField (false) marks a field used in the data area.
Display switches: compact, outline, subtotalTop,
showAll, showDropDowns, dragToRow, dragToCol,
dragToPage, dragToData, dragOff, topAutoShow
(true); insertBlankRow, insertPageBreak, autoShow,
hideNewItems, measureFilter, includeNewItemsInFilter,
allDrilled, serverField, multipleItemSelectionAllowed
(false); itemPageCount (10); sortType: manual (default),
ascending, descending; numFmtId, name,
subtotalCaption. The subtotals are chosen by defaultSubtotal (true) and
sumSubtotal, countASubtotal, avgSubtotal,
maxSubtotal, minSubtotal, productSubtotal,
countSubtotal, stdDevSubtotal, stdDevPSubtotal,
varSubtotal, varPSubtotal (false). Children: items,
autoSortScope, extLst.
item (18.10.1.45): x (index into the cache field’s shared
items), t (data, default = the subtotal row,
sum, countA, avg, max, min,
product, count, stdDev, stdDevP,
var, varP, grand, blank), h
hidden, s missing, sd (true) show details, f calculated,
m, c, d, e (true), n caption.
rowFields and colFields list field x="n" (index into
pivotFields; -2 means the values pseudo-field). rowItems and
colItems list i: t (an item type as above), r
(how many leading x repeat the previous line), i (which data field),
and x v children indexing the field’s items. They describe the layout of the
cells already in the sheet.
Excel: a field’s axis must agree with its presence in
rowFields, colFields or pageFields; name is
unique among the fields and at most 255 characters (32767 for captions).
Page and data fields
pageField: fld (required), item, hier,
name, cap. dataField: fld (required),
name, subtotal (sum default; average,
count, countNums, max, min,
product, stdDev, stdDevp, var,
varp), showDataAs (normal default, difference,
percent, percentDiff, runTotal, percentOfRow,
percentOfCol, percentOfTotal, index), baseField
(-1), baseItem (1048832), numFmtId.
Pivot table style and formats
pivotTableStyleInfo (18.10.1.74): name (a built-in
PivotStyleLight16 and the like, or a tableStyle of the styles part),
showRowHeaders, showColHeaders, showRowStripes,
showColStripes, showLastColumn. Excel:
showLastColumn is ignored and the defaults of all five are 0.
formats holds format elements: action
(formatting default, blank, drill, formula),
dxfId into the styles part’s dxfs, and a pivotArea
naming the cells by field, type (normal, none,
data, all, origin, button,
topEnd, topRight), dataOnly (true),
labelOnly, grandRow, grandCol, axis,
fieldPosition, offset and references.
Sources
- ECMA-376 5th edition Part 1 section 18.10 (18.10.1.1 to 18.10.1.97) and Part 4 Transitional
sml.xsd, in the project’s research/ooxml/ecma376/ - [MS-OI29500] v20260818, research/ooxml/ms/ (notes on 18.10.1.x, lines 14780 to 16510)
- The viewer code explorer/formats/xlsx/book.js (
readPivotCache,readPivotTable)