SheetXL - v1.0.2
    Preparing search index...

    Interface IPivotTableCollection

    Holds pivot tables — a sheet's, or every sheet's in the workbook.

    interface IPivotTableCollection {
        isICollection: true;
        isIPivotTableCollection: true;
        length: number;
        "[iterator]"(): IterableIterator<IPivotTable>;
        add(
            source: IPivotTableCollection.Source,
            location: ICellRange.Address,
            options?: IPivotTableCollection.AddOptions,
        ): Promise<IPivotTable>;
        addListeners(
            listeners: ICollection.IListeners,
            options?: IListener.Options,
        ): Remove;
        at(index: number): IPivotTable | undefined;
        every(
            predicate: (
                value: IPivotTable,
                index: number,
                items: readonly IPivotTable[],
            ) => boolean,
        ): boolean;
        filter<S extends IPivotTable>(
            predicate: (
                value: IPivotTable,
                index: number,
                items: readonly IPivotTable[],
            ) => value is S,
        ): S[];
        filter(
            predicate: (
                value: IPivotTable,
                index: number,
                items: readonly IPivotTable[],
            ) => boolean,
        ): IPivotTable[];
        find<S extends IPivotTable>(
            predicate: (
                value: IPivotTable,
                index: number,
                items: readonly IPivotTable[],
            ) => value is S,
        ): S | undefined;
        find(
            predicate: (
                value: IPivotTable,
                index: number,
                items: readonly IPivotTable[],
            ) => boolean,
        ): IPivotTable | undefined;
        findIndex(
            predicate: (
                value: IPivotTable,
                index: number,
                items: readonly IPivotTable[],
            ) => boolean,
        ): number;
        forEach(
            fn: (
                value: IPivotTable,
                index: number,
                items: readonly IPivotTable[],
            ) => void,
        ): void;
        getByName(name: string): IPivotTable | null;
        getCount(): number;
        getItems(options?: ICollection.GetItemsOptions): IPivotTable[];
        indexOf(item: IPivotTable): number;
        isClosed(): boolean;
        map<U>(
            fn: (
                value: IPivotTable,
                index: number,
                items: readonly IPivotTable[],
            ) => U,
        ): U[];
        refreshAll(options?: RefreshOptions): Promise<void>;
        some(
            predicate: (
                value: IPivotTable,
                index: number,
                items: readonly IPivotTable[],
            ) => boolean,
        ): boolean;
        toArray(): IPivotTable[];
        readonly [index: number]: IPivotTable;
    }

    Hierarchy (View Summary)

    Indexable

    • readonly [index: number]: IPivotTable

      The item at the given index, or undefined if there is none — wb.getWorksheets()[0].

      Read-only and live: each read is against the collection as it is now. Assigning through an index throws.

    Index
    isICollection: true

    For runtime type checking.

    isIPivotTableCollection: true

    For runtime type checking.

    length: number

    The number of items — the same as getCount.

    • Iterates the collection's items.

      Returns IterableIterator<IPivotTable>

      The unfiltered walk — for (const sheet of wb.getWorksheets()). Every other iterable surface in the SDK (ICellRange, ICellRegions, ICellRanges) reads this way, so a collection that did not was a trap: for…of over one is the obvious line to write and it threw at runtime with nothing in the types to warn first.

      getItems remains the call that takes options — filtering, ordering, anything parameterized. This is sugar over the unfiltered case, not a replacement for it.

    • Adds a pivot table on this sheet, as one step that can be undone.

      Parameters

      • source: IPivotTableCollection.Source

        The cells to summarize, their first row the field names: a range, a table, or a table's or defined name's name. A table already summarizing the same source shares its cache unless the source was edited since, so they refresh together.

      • location: ICellRange.Address

        Where the table's top-left cell goes. Filters sit above it, a blank row between; at the top of a sheet the table moves down to make room for them.

      • Optionaloptions: IPivotTableCollection.AddOptions

        The fields to place. With none, the table is empty and holds 18 rows by 3 columns.

      Returns Promise<IPivotTable>

      The cells the table needs, its filters' included, must hold no value, unless IPivotTableCollection.AddOptions.discardValues clears them. Another pivot table or an array's cells there always refuse it.

      const pivot = await sheet.getPivotTables().add('Data!A1:H500', 'A3', {
      rows: ['Region'],
      columns: ['Year'],
      values: ['Sales', { field: 'Sales', function: 'average' }]
      });

      When the cells it needs hold a value, an array or another pivot table, a field or the source does not exist, the source has no row of data, the name is taken on this sheet or the sheet is locked; and on the workbook's collection, which holds no sheet to add to.

    • Returns the item at the given index, or undefined if there is none.

      Parameters

      • index: number

        The position in iteration order. A negative index counts back from the end, as Array.prototype.at does.

      Returns IPivotTable | undefined

    • Returns true if the predicate accepts every item, including when there are none.

      Parameters

      • predicate: (value: IPivotTable, index: number, items: readonly IPivotTable[]) => boolean

        Called once per item in iteration order until it returns false.

      Returns boolean

    • Returns the items the predicate accepts, in iteration order.

      Type Parameters

      Parameters

      • predicate: (value: IPivotTable, index: number, items: readonly IPivotTable[]) => value is S

        Called once per item.

      Returns S[]

    • Returns the items the predicate accepts, in iteration order.

      Parameters

      • predicate: (value: IPivotTable, index: number, items: readonly IPivotTable[]) => boolean

        Called once per item.

      Returns IPivotTable[]

    • Returns the first item the predicate accepts, or undefined if it accepts none.

      Type Parameters

      Parameters

      • predicate: (value: IPivotTable, index: number, items: readonly IPivotTable[]) => value is S

        Called once per item in iteration order until it returns true.

      Returns S | undefined

    • Returns the first item the predicate accepts, or undefined if it accepts none.

      Parameters

      • predicate: (value: IPivotTable, index: number, items: readonly IPivotTable[]) => boolean

        Called once per item in iteration order until it returns true.

      Returns IPivotTable | undefined

    • Returns the index of the first item the predicate accepts, or -1 if it accepts none.

      Parameters

      • predicate: (value: IPivotTable, index: number, items: readonly IPivotTable[]) => boolean

        Called once per item in iteration order until it returns true.

      Returns number

    • Calls the function once per item, in iteration order.

      Parameters

      Returns void

    • Returns the pivot table with the given name, or null if there is none.

      Parameters

      • name: string

        The name of the pivot table. This is case insensitive.

      Returns IPivotTable | null

      A name is unique only on its sheet, so the workbook's collection returns the first table with that name in sheet order. Ask the sheet's collection to find one table for certain.

    • Returns the total items available.

      Returns number

      returns the total number of items available.

    • Returns the index of the item in iteration order, or -1 if it is not in the collection.

      Parameters

      Returns number

    • Returns true once the collection has been closed.

      Returns boolean

      A closed collection is empty and announces nothing further. Collections that are closed by their owner (the workbook's names, functions and modules, when the workbook closes) announce it once with ICollection.Events.onClose; the others are never closed and always return false.

    • Returns the result of calling the function on every item, in iteration order.

      Type Parameters

      • U

      Parameters

      Returns U[]

    • Refreshes every table (IPivotTable.refresh) as one step that can be undone.

      Parameters

      Returns Promise<void>

      A table that cannot be refreshed refuses the whole step, and nothing changes.

    • Returns true if the predicate accepts at least one item.

      Parameters

      • predicate: (value: IPivotTable, index: number, items: readonly IPivotTable[]) => boolean

        Called once per item in iteration order until it returns true.

      Returns boolean

    • Returns the items as a fresh array, in iteration order.

      Returns IPivotTable[]

      The call to make when an array is really wanted. The array is the caller's: changing it does not change the collection, and it does not follow later changes to the collection.