Add a column field.
Field options including the source field index and display name.
this for chaining.
Add a data (values) field.
The same source field may be added again with another aggregation, and may also sit on a row, column or page axis. The display name goes on the data field only, never on the pivot field.
Data field options including field index, aggregation function, and display name.
this for chaining.
Add a page (report filter) field.
Page field options including field index and optional selected item.
this for chaining.
Add a row field.
Field options including the source field index and display name.
this for chaining.
Build the final PivotTableData object.
Returns an independent deep copy; later builder calls do not affect it. Every pivot
field has empty items, which the writer completes from the cache (see
PivotFieldData.items).
The complete pivot table data ready for insertion via Worksheet.addPivotTable().
Set the pivot cache ID: the cacheId of a cache in the workbook's pivotCaches,
or that cache's 0-based index when its cacheId is unset. No cache is created
here; register one with addPivotCache.
The cache's cacheId (or index when unset).
this for chaining.
Set the data caption text.
The caption label for the data area.
this for chaining.
Set the location reference (e.g., 'A3:D20' or 'A3').
The A1-style range or cell reference.
Optionaloptions: { firstDataCol?: number; firstDataRow?: number; firstHeaderRow?: number }
Optional first header row, data row, and data column offsets.
this for chaining.
Set the pivot table name.
The display name for the pivot table.
this for chaining.
Fluent builder for constructing
PivotTableDataobjects.Every pivot field is built with empty
items. On write, the row, column and page fields get the items Excel needs from the cache thatcacheIdnames, and that cache refreshes when Excel opens the file, which lays the table out and shows its values (seePivotTableData). With two or more data fields the writer also puts the values field on the columns.The builder makes pivot fields only up to the highest
fieldIndexused. On write,pivotFieldsgets empty fields up to the number of fields in the cache thatcacheIdnames, because Excel refuses a table with fewer.Example