Skip to content

PivotDefinition@sheetwrite/core

On this page

Serializable pivot-table definition, owned by the sheet that holds its anchor. The output starts at anchor and spills right and down.

Members 14

id Stable identity, unique in the workbook.
id: string;
name User-facing caption.
name: string;
source Data the pivot summarizes.
source: PivotSource;
anchor Top-left output cell on the owning sheet.
anchor: { row: number; col: number };

Top-left output cell on the owning sheet. Deleting the anchor's row or column keeps the pivot and moves the anchor to the first surviving cell at the deletion position.

rows Source field indices that group the output rows, outermost first.
rows: number[];
columns Source field indices that group the output columns, outermost first.
columns: number[];
values Aggregated fields, in output order.
values: PivotValueField[];
filters Keep-lists that limit which source rows contribute; at most one per field.
filters?: PivotFilter[];
sort Label order of grouped fields; each key names a field that groups its axis.
sort?: PivotSort[];
rowTotals Grand-total row at the bottom (PIVOTBY rowtotaldepth; OOXML colGrandTotals).
rowTotals?: boolean;

Grand-total row at the bottom (PIVOTBY `row_total_depth`; OOXML `colGrandTotals`). Default `true`.

columnTotals Grand-total column at the right (PIVOTBY coltotaldepth; OOXML rowGrandTotals).
columnTotals?: boolean;

Grand-total column at the right (PIVOTBY `col_total_depth`; OOXML `rowGrandTotals`). Default `true`.

subtotals Subtotal rows and columns for each outer group of a multi-field axis.
subtotals?: boolean;

Subtotal rows and columns for each outer group of a multi-field axis. Default `true`.

layout Default "compact".
layout?: PivotLayout;
savedOutput Output cells a file saved for this pivot, row-major from anchor: for example the cells Excel rendered.
savedOutput?: { rows: number; cols: number; cells: CellScalar[] };

Output cells a file saved for this pivot, row-major from `anchor`: for example the cells Excel rendered. At most 1,000,000 cells, and `cells.length` is `rows * cols`.

  • The default engine computes no pivots, so it shows these values from the anchor. Formulas read them, and local writes into them are refused. A source cell, formula or spill in the rectangle shows #SPILL! at the anchor until it is cleared.
  • The full engine ignores these values and recalculates the output.
  • setPivot on the Grid or store removes them, because the saved values no longer match a changed definition. A row or column edit keeps them only when the output rectangle moves without a change; an edit inside the rectangle removes them.
  • Snapshots, sync and XLSX export keep them on every engine.

Declaration

View full TypeScript declaration
export interface PivotDefinition {
id: string;
name: string;
source: PivotSource;
anchor: {
row: number;
col: number;
};
rows: number[];
columns: number[];
values: PivotValueField[];
filters?: PivotFilter[];
sort?: PivotSort[];
rowTotals?: boolean;
columnTotals?: boolean;
subtotals?: boolean;
layout?: PivotLayout;
savedOutput?: {
rows: number;
cols: number;
cells: CellScalar[];
};
}

Referenced by

Workspace packages depending on @sheetwrite/core

  • @sheetwrite/benchdependency
  • @sheetwrite/chartsdependency
  • @sheetwrite/docs-startdependency
  • @sheetwrite/reactdependency
  • @sheetwrite/sveltedependency
  • @sheetwrite/vuedependency
  • @sheetwrite/xlsxdependency

Public exports naming PivotDefinition

Documentation