SheetXL - v1.0.2
    Preparing search index...

    Interface IPivotTable

    A pivot table laid out on a sheet, anchored at the top-left cell of its location.

    Until it is refreshed, a table is written back as it was read, with the location restated. Where it sits follows structural edits; an edit that would move only part of it, its page fields included, is refused, as Excel refuses it, and one that takes every cell of it deletes it. While something is in the way of its cells, the table shows #SPILL! at its anchor and covers that cell alone, as in Excel.

    interface IPivotTable {
        isIAnchored: true;
        isIPivotTable: true;
        addDataField(
            field: string | IPivotTable.IField,
            input?: Omit<IPivotTable.IDataField.Input, "field">,
            options?: ITransaction.OperationOptions,
        ): Promise<IPivotTable.IDataField>;
        addListeners(
            listeners: IAnchored.IListeners,
            options?: IListener.Options,
        ): Remove;
        addSlicer(
            field: string | IPivotTable.IField,
            options?: ISlicer.AddOptions,
        ): Promise<ISlicer>;
        close(): void;
        delete(): void;
        getAnchorType?(): IAnchored.Type;
        getBlankRowAfterItems(): boolean | null;
        getBodyAndTotalRange(
            options?: ICellRange.GetRangeOptions,
        ): ICellRange | null;
        getColumnFields(): readonly IPivotTable.IField[];
        getColumnLabelRange(
            options?: ICellRange.GetRangeOptions,
        ): ICellRange | null;
        getDataField(name: string): IPivotTable.IDataField | null;
        getDataFields(): readonly IPivotTable.IDataField[];
        getEmptyCaption(): string | null;
        getErrorCaption(): string | null;
        getField(name: string): IPivotTable.IField | null;
        getFields(): readonly IPivotTable.IField[];
        getForm(): "compact" | PivotForm | null;
        getName(): string;
        getPageFields(): readonly IPivotTable.IField[];
        getPageRange(options?: ICellRange.GetRangeOptions): ICellRange | null;
        getRange(options?: ICellRange.GetRangeOptions): ICellRange;
        getRanges(options?: ICellRange.GetRangeOptions): ICellRanges;
        getRepeatLabels(): boolean | null;
        getRowFields(): readonly IPivotTable.IField[];
        getRowLabelRange(options?: ICellRange.GetRangeOptions): ICellRange | null;
        getSource(): string | null;
        getStyle(): ITableStyle | null;
        getStyleAt(row: number, column: number): ICellStyle;
        getStyleOptions(): IPivotTable.StyleOptions;
        getSubtotalsOnTop(): boolean | null;
        getValuesField(): IValuesField | null;
        getWorksheet(): IWorksheet;
        isAutoFitColumns(): boolean;
        isClosed(): boolean;
        isDeleted(): boolean;
        isHiddenDrillIndicators(): boolean;
        isHiddenFieldHeaders(): boolean;
        isMultipleFiltersPerField(): boolean;
        isPreserveFormatting(): boolean;
        isProtected(): boolean;
        isShowColumnGrandTotals(): boolean;
        isShowRowGrandTotals(): boolean;
        isStale(): boolean;
        moveTo(cell: ICellRange.Address, options?: MoveOptions): Promise<void>;
        refresh(options?: RefreshOptions): Promise<void>;
        setAutoFitColumns(
            autoFit: boolean,
            options?: ITransaction.OperationOptions,
        ): this;
        setBlankRowAfterItems(
            blank: boolean,
            options?: ITransaction.OperationOptions,
        ): Promise<IPivotTable>;
        setEmptyCaption(
            text: string | null,
            options?: ITransaction.OperationOptions,
        ): Promise<IPivotTable>;
        setErrorCaption(
            text: string | null,
            options?: ITransaction.OperationOptions,
        ): Promise<IPivotTable>;
        setForm(
            form: "compact" | PivotForm,
            options?: ITransaction.OperationOptions,
        ): Promise<IPivotTable>;
        setHiddenDrillIndicators(
            hidden: boolean,
            options?: ITransaction.OperationOptions,
        ): this;
        setHiddenFieldHeaders(
            hidden: boolean,
            options?: ITransaction.OperationOptions,
        ): Promise<IPivotTable>;
        setMultipleFiltersPerField(
            multiple: boolean,
            options?: ITransaction.OperationOptions,
        ): Promise<IPivotTable>;
        setName(
            name: string,
            options?: ITransaction.OperationOptions,
        ): Promise<void>;
        setPreserveFormatting(
            preserve: boolean,
            options?: ITransaction.OperationOptions,
        ): this;
        setRepeatLabels(
            repeat: boolean,
            options?: ITransaction.OperationOptions,
        ): Promise<IPivotTable>;
        setShowColumnGrandTotals(
            show: boolean,
            options?: ITransaction.OperationOptions,
        ): Promise<IPivotTable>;
        setShowRowGrandTotals(
            show: boolean,
            options?: ITransaction.OperationOptions,
        ): Promise<IPivotTable>;
        setSource(
            source: IPivotTableCollection.Source,
            options?: ITransaction.OperationOptions,
        ): Promise<void>;
        setSubtotalsOnTop(
            top: boolean,
            options?: ITransaction.OperationOptions,
        ): Promise<IPivotTable>;
        toJSON(
            toResourceId?: (resource: IResource) => number | null,
        ): IPivotTable.JSON | null;
        updateStyleOptions(
            options: IPivotTable.StyleOptions,
            operation?: ITransaction.OperationOptions,
        ): IPivotTable;
    }

    Hierarchy (View Summary)

    Index
    isIAnchored: true

    For runtime type checking.

    isIPivotTable: true

    For runtime type checking.

    • Adds a slicer that filters one of the table's fields, as one step that can be undone.

      Parameters

      • field: string | IPivotTable.IField

        The field, or its name.

      • Optionaloptions: ISlicer.AddOptions

        Where it goes and how it looks. Sized 192 × 280 pixels and centered in the view unless bounds says otherwise; placed on the table's sheet unless sheet says otherwise.

      Returns Promise<ISlicer>

      The slicer, named for the field's name in the source (Region, then Region 1), unique in the workbook, and captioned with the field's caption.

      The field need not be on the table. The slicer's selection is the items the field hides.

      ExpectedError When the table has no such field, the name is taken, or the table is not modeled.

      const slicer = await pivot.addSlicer('Region');
      await slicer.selectItems(['East']);
    • Similar to delete but cleans resources and can't be undone.

      Returns void

    • Deletes the anchored item.

      Returns void

    • Returns whether the row and column fields leave a blank line after each item, or null when they differ.

      Returns boolean | null

    • Returns the cells that hold the table's values, its subtotals and grand totals included; null while the table shows #SPILL!.

      Parameters

      Returns ICellRange | null

      Every line below the header rows, right of the label columns. A table with no values still has its lines: then the last column, which holds the labels (as Excel's DataBodyRange).

    • Returns the value with a caption, matched without regard to case, or null when there is none.

      Parameters

      • name: string

      Returns IPivotTable.IDataField | null

    • Returns what a crossing no record falls in shows: this text, empty by default for a blank cell, or null when it shows 0.

      Returns string | null

    • Returns what an error value shows as: this text, or null, the default, when it shows the error.

      Returns string | null

    • Returns the field with a caption, matched without regard to case, or null when there is none.

      Parameters

      • name: string

      Returns IPivotTable.IField | null

    • Returns the table's fields, one per field of its cache, in the cache's order; empty for a table that is not modeled.

      Returns readonly IPivotTable.IField[]

      await pivot.getField('Region').getItem('East').setExpanded(false);
      await pivot.getField('Channel').setCurrentPage('Web');
    • Returns how the table lays out its fields, or null when the row and column fields differ.

      Returns "compact" | PivotForm | null

    • Returns the name.

      Returns string

      Unique on the table's sheet, as Excel keeps it. Tables on different sheets may share a name: a duplicated sheet's tables keep theirs, as they do in Excel.

    • Returns the cells the table is laid out on: its location, without the page fields above it.

      Parameters

      Returns ICellRange

      The anchor cell alone while the table shows #SPILL!. An insert or delete before the table moves it, one taking every cell of it deletes it (IAnchored.isDeleted), and one that would move part of it - a row deleted or inserted inside it or its page fields, a column cut through it - is refused.

    • Returns the ranges this object is anchored to, in authored order.

      Parameters

      Returns ICellRanges

      • Never null. An item whose last range was removed by a row/column delete returns an invalid ranges — ask ICellRanges.isInvalid, the same contract as ITable.getDataRange.
      • This is the general accessor. Most anchored types hold exactly one range and declare their own getRange() for it, but data validations, conditional formats and protected ranges are authored as several, and any single range can become several when a delete splits it.
    • Returns whether the row and column fields repeat their labels, or null when they differ.

      Returns boolean | null

    • Returns the cells the table summarizes, as IPivotTableCollection.add takes them: a table's or defined name's name, or a sheet-qualified range; null when its cache names none, as one from another workbook or a database may not.

      Returns string | null

    • Returns the table's pivot table style, or null when it names none or one the workbook does not have.

      Returns ITableStyle | null

    • Returns the style the table gives the cell at a sheet position: its pivot table style, and the formats its layout sets, such as a row label set left and indented by its level.

      Parameters

      • row: number

        The row on the sheet.

      • column: number

        The column on the sheet.

      Returns ICellStyle

      Not the cell's own formats or any other layer. A cell the table does not cover, or a table that is not laid out, has none of the table's styling.

    • Returns whether the row and column fields show their subtotals on their items' first line, or null when they differ.

      Returns boolean | null

    • Returns where the table's values sit among the fields of an axis; null below two values, when there is nothing for them to be placed among.

      Returns IValuesField | null

    • Returns whether the table fits its columns to its cells each time it is laid out.

      Returns boolean

    • Returns if the model has been closed

      Returns boolean

    • Returns if the model has been deleted

      Returns boolean

    • Returns whether the expand/collapse buttons beside the items are hidden.

      Returns boolean

    • Returns whether the captions over the row and column fields, and their buttons, are hidden.

      Returns boolean

    • Returns whether a field's filters are allowed to combine.

      Returns boolean

    • Returns whether the formats set on the table's cells follow their items through a relayout.

      Returns boolean

    • If the anchor is unable to be modified.

      Returns boolean

    • Returns whether each column shows a grand total: the row of totals at the table's bottom.

      Returns boolean

    • Returns whether each row shows a grand total: the column of totals at the table's right.

      Returns boolean

    • Returns whether the cells the table summarizes have been edited since its cache last read them.

      Returns boolean

      As in Excel, an edit to the source does not change the table; it shows what the cache held until it is refreshed from the source. Every table on the same cache is stale together.

      An edit is a value or formula written or cleared in the source (an undo of one too), a row or column inserted or deleted inside it, or a resize of the table it names. Moving the source whole is not. Neither is a recalculation: a formula in the source that reads cells outside it can change value without the table reading as stale. A source this workbook does not hold, such as another workbook's, never reads as stale.

    • Moves the table on its sheet, as one step that can be undone.

      Parameters

      Returns Promise<void>

      cell takes the table's top-left cell, as IPivotTableCollection.add's location does: page fields sit above it, a blank row between, and at the top of a sheet the table moves down to make room for them. The cells it leaves are cleared. The cells it needs must hold no value, unless IPivotTable.MoveOptions.discardValues clears them; another pivot table or an array's cells there always refuse it. The new place may overlap the old.

      ExpectedError When cell is on another sheet, the cells it needs hold a value, an array or another pivot table, or the table is not modeled; ProtectedError on a locked sheet.

    • Reads the table's source again and lays the table out from it, as one step that can be undone.

      Parameters

      Returns Promise<void>

      The cache is read again from the cells its source names now, and every table on that cache is laid out again with this one, as in Excel. A field follows its column by the header's text (without regard to case): a column whose header changed, or that is gone, takes its field out of every table. Each field keeps its items in their place, with what was hidden, collapsed or renamed; an item no longer in the source is kept, missing, until it comes back, and a new one is added after the others (in its place under a sort), hidden when the field hides items. With source: false the table alone is laid out again from its cache as it is.

      The table takes the cells its layout needs: its range grows or shrinks from its top-left cell, and the cells it gives up are cleared. When a cell it needs holds anything, the table shows #SPILL! in its top-left cell, as a dynamic array does, and is laid out again as soon as the cells are clear.

      When the table is not modeled, on a locked sheet, or its source is not in this workbook or its cache has calculated fields.

    • Sets whether the table fits its columns to its cells each time it is laid out, as one step that can be undone.

      Parameters

      Returns this

      A fit measures only the table's cells, and sets the width of every column the table covers, a width set by hand included. Setting this does not fit the columns; the next layout does.

      When the table is not modeled.

    • Sets whether every field leaves a blank line after each of its items, those off the table too, as one step that can be undone.

      Parameters

      Returns Promise<IPivotTable>

      A blank line shows only after the items of a row field with another row field inside it.

      When the table is not modeled.

    • Sets what a crossing no record falls in shows, as one step that can be undone.

      Parameters

      • text: string | null

        The text; empty for a blank cell; null for 0. Text that reads as a number shows as that number.

      • Optionaloptions: ITransaction.OperationOptions

      Returns Promise<IPivotTable>

      When the table is not modeled.

    • Lays out every field of the table in a form, those off the table too, as one step that can be undone.

      Parameters

      Returns Promise<IPivotTable>

      The table is laid out again from its cache. As with every setting that changes its cells, when a cell it needs holds anything the setting stands and the table shows #SPILL! until the cells are clear.

      ExpectedError For a form that is none, or when the table is not modeled.

    • Sets whether the captions over the row and column fields, and their buttons, are hidden, as one step that can be undone.

      Parameters

      Returns Promise<IPivotTable>

      The table is laid out again from its cache: the caption cells are left blank, and the row of column captions is dropped when nothing else is in it, so the table can shrink by a row, as in Excel. A page field keeps its caption and button.

      When the table is not modeled.

    • Sets whether a field's filters are allowed to combine, as one step that can be undone.

      Parameters

      Returns Promise<IPivotTable>

      Turned off, a field holding more than one filter loses all of them, and the table is laid out again if any went; a field with one keeps it. The flag does not limit IPivotTable.IField.applyFilter.

      When the table is not modeled.

    • Renames the table, as one step that can be undone.

      Parameters

      Returns Promise<void>

      Any text of 1 to 255 characters, spaces and punctuation included, unless another table on this sheet has it, without regard to case. A table on another sheet may have it. Slicers on the table follow it; GETPIVOTDATA names a cell, not the table, so it is unaffected.

      ExpectedError For an empty name, one longer than 255 characters, or one another table on this sheet has.

    • Sets whether the formats set on the table's cells follow their items through a relayout, as one step that can be undone.

      Parameters

      Returns this

      Turned off, the table lets go of the formats it holds, for good: turning it on again does not bring them back. While off, a format set on the cells lasts until the next time the table is laid out, whatever causes that.

      When the table is not modeled.

    • Sets whether every field repeats its item's label on each line the item spans, those off the table too, as one step that can be undone.

      Parameters

      Returns Promise<IPivotTable>

      Nothing shows in compact form, whose labels share a column; the setting stands for a later form.

      When the table is not modeled.

    • Sets whether each column shows a grand total, as one step that can be undone.

      Parameters

      Returns Promise<IPivotTable>

      That is the row of totals at the table's bottom.

      When the table is not modeled.

    • Sets whether each row shows a grand total, as one step that can be undone.

      Parameters

      Returns Promise<IPivotTable>

      That is the column of totals at the table's right, so a table with no column fields has none to show. With the grand total of the whole table gone from the cells, GETPIVOTDATA for it is #REF!.

      When the table is not modeled.

    • Summarizes other cells, as one step that can be undone: the table reads source as a refresh does and is laid out again.

      Parameters

      Returns Promise<void>

      Fields are matched to the new columns by their header, without regard to case. A field whose column is gone, or whose header changed, leaves the table; the rest keep their place, hidden items, filters, captions and formats. Other tables that shared the cache keep the cells they summarized. When the table grows over a value it shows #SPILL!, as after a refresh. A slicer on a field the new source does not have is deleted with it.

      ExpectedError When source names nothing, has no row of data, overlaps the table, the table is not modeled, or a slicer on the table also filters another; ProtectedError on a locked sheet.

    • Sets whether every field shows its subtotals on its items' first line rather than on a line after them, those off the table too, as one step that can be undone.

      Parameters

      Returns Promise<IPivotTable>

      Tabular form always shows them after; the setting stands for a later form.

      When the table is not modeled.