# PivotTableCollection

> PivotTableCollection class in the TX Sheet Control JavaScript API for the browser, with its syntax and a JavaScript example.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Class
- **Path:** TX Sheet Control > API Reference > JavaScript API > Browser Editor > PivotTableCollection
- **1009 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/llms-full.txt

---

Workbook-wide or worksheet-scoped pivot collection. All indices are zero-based and returned settings are detached.

Package: `@txtextcontrol/tx-sheet-control`. Obtain operational handles through `workbook.pivotTables`; settings and results are detached values.

### Members

| Member | Description |
|---|---|
| [count](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/count-property/llms-full.txt) | Number of pivots in this collection. |
| [list](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/list-method/llms-full.txt) | Detached definitions in workbook order, restricted to the destination worksheet when scoped. |
| [at](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/at-method/llms-full.txt) | Resolve a zero-based collection index; throws if out of range. |
| [get](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/get-method/llms-full.txt) | Resolve a workbook-unique name or stable ID; throws if absent. |
| [add](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/add-method/llms-full.txt) | Create and materialize a pivot. Destination must fit and contain no unrelated cells, tables, merges or pivots. |
| [remove](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/remove-method/llms-full.txt) | Remove one pivot. keepValues retains its static report; otherwise clears cells and pivot formatting. |
| [refreshAll](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/refreshall-method/llms-full.txt) | Refresh every pivot in one undoable workbook transaction. |

### Examples

In a browser use `const workbook = editor.workbook`. In Node.js use your server control workbook.

```javascript
import { Workbook as ExampleWorkbook } from '@txtextcontrol/tx-sheet-control';
const workbook = new ExampleWorkbook();
const source = workbook.sheets.at(0);
source.range('A1:D5').setValues([
    ['Region', 'Category', 'Revenue', 'Cost'],
    ['Europe', 'Software', 1250, 500],
    ['Europe', 'Services', 700, 350],
    ['Americas', 'Software', 1800, 900],
    ['Americas', 'Services', 950, 400]
]);
const report = workbook.sheets.add('Sales Summary');
const pivot = report.pivotTables.add({
    name: 'RegionalSales',
    source: { sheetId: source.id, range: 'A1:D5' },
    destination: { sheetId: report.id, cell: 'B3' },
    rows: [{ field: 'Region' }],
    columns: [{ field: 'Category' }],
    values: [{ field: 'Revenue', caption: 'Sales', numberFormatCode: '$#,##0.00' }],
    layout: 'tabular', style: { rowBanding: true }
});
```

See [Pivot Tables](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/pivot-tables/llms-full.txt) for filtering, calculated values and output.

- [sheetId](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/sheetid-property/llms-full.txt) — Stable report or collection scope identity.

---

## In This Section

- [PivotTableCollection.add Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/add-method/llms-full.txt): PivotTableCollection.add method in the TX Sheet Control JavaScript API for the browser, with its syntax and a JavaScript example.
- [PivotTableCollection.at Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/at-method/llms-full.txt): PivotTableCollection.at method in the TX Sheet Control JavaScript API for the browser: Resolve a zero-based collection index; throws if out of range.
- [PivotTableCollection.count Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/count-property/llms-full.txt): PivotTableCollection.count property in the TX Sheet Control JavaScript API for the browser: Number of pivots in this collection.
- [PivotTableCollection.get Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/get-method/llms-full.txt): PivotTableCollection.get method in the TX Sheet Control JavaScript API for the browser: Resolve a workbook-unique name or stable ID; throws if absent.
- [PivotTableCollection.list Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/list-method/llms-full.txt): PivotTableCollection.list method in the TX Sheet Control JavaScript API for the browser, with its syntax and a JavaScript example.
- [PivotTableCollection.refreshAll Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/refreshall-method/llms-full.txt): PivotTableCollection.refreshAll method in the TX Sheet Control JavaScript API for the browser: Refresh every pivot in one undoable workbook transaction.
- [PivotTableCollection.remove Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/remove-method/llms-full.txt): PivotTableCollection.remove method in the TX Sheet Control JavaScript API for the browser, with its syntax and a JavaScript example.
- [PivotTableCollection.sheetId Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/sheetid-property/llms-full.txt): PivotTableCollection.sheetId property in the TX Sheet Control JavaScript API for the browser, with a JavaScript example.

---

## Nearby

- **Previous:** [PivotTable.id Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/id-property/llms-full.txt)
- **Next:** [PivotTableCollection.count Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottablecollection/count-property/llms-full.txt)
