# PivotTable

> PivotTable class in the browser JavaScript API: An operational PivotTable. Handles are invalid after removal or document replacement; snapshots are detached.

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

---

An operational PivotTable. Handles are invalid after removal or document replacement; snapshots are detached.

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

### Members

| Member | Description |
|---|---|
| [snapshot](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/snapshot-property/llms-full.txt) | Returns current persisted settings, including the materialized output range. |
| [name](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/name-property/llms-full.txt) | Current workbook-unique name. Rename through update({name}). |
| [getFields](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/getfields-method/llms-full.txt) | Available source and calculated fields; table growth is resolved each time. |
| [getItems](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/getitems-method/llms-full.txt) | Distinct typed/grouped members in source order, including blanks. |
| [update](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/update-method/llms-full.txt) | Replace supplied settings and refresh atomically. Invalid settings, overlap or protection leave the workbook intact. |
| [refresh](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/refresh-method/llms-full.txt) | Re-read live source values and rewrite the output in one undoable transaction. |
| [getResult](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/getresult-method/llms-full.txt) | Compute detached output without modifying cells or undo history. |
| [setFilters](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/setfilters-method/llms-full.txt) | Replace report/member/value filters; supplying \[\] clears all filters. |
| [setFields](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/setfields-method/llms-full.txt) | Configure one axis, including order, sorting and grouping, using the same validation as the field panel. |
| [setExpanded](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/setexpanded-method/llms-full.txt) | Expand/collapse a grouped member path. Paths contain grouped item values, not display indentation. |
| [drillThrough](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/drillthrough-method/llms-full.txt) | Returns filtered source records contributing to an axis intersection, at most limit (default 1,000; maximum 100,000). |
| [getData](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/getdata-method/llms-full.txt) | Read an aggregate by its value caption and row/column paths. Paths may identify parent totals. |
| [createChart](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/createchart-method/llms-full.txt) | Creates a worksheet chart whose data range follows this pivot after refresh or relocation. |
| [remove](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/remove-method/llms-full.txt) | Remove this pivot and optionally preserve its rendered cells as a static report. |

### 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.

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

---

## In This Section

- [PivotTable.createChart Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/createchart-method/llms-full.txt): PivotTable.createChart method in the TX Sheet Control JavaScript API for the browser, with the return type Chart and a JavaScript example.
- [PivotTable.drillThrough Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/drillthrough-method/llms-full.txt): PivotTable.drillThrough method in the TX Sheet Control JavaScript API for the browser, with its syntax and a JavaScript example.
- [PivotTable.getData Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/getdata-method/llms-full.txt): PivotTable.getData method in the browser JavaScript API: Read an aggregate by its value caption and row/column paths. Paths may identify parent totals.
- [PivotTable.getFields Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/getfields-method/llms-full.txt): PivotTable.getFields method in the TX Sheet Control JavaScript API for the browser: Available source and calculated fields; table growth is resolved each time.
- [PivotTable.getItems Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/getitems-method/llms-full.txt): PivotTable.getItems method in the TX Sheet Control JavaScript API for the browser: Distinct typed/grouped members in source order, including blanks.
- [PivotTable.getResult Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/getresult-method/llms-full.txt): PivotTable.getResult method in the TX Sheet Control JavaScript API for the browser: Compute detached output without modifying cells or undo history.
- [PivotTable.id Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/id-property/llms-full.txt): PivotTable.id property in the TX Sheet Control JavaScript API for the browser: The stable pivot identity within this workbook.
- [PivotTable.name Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/name-property/llms-full.txt): PivotTable.name property in the TX Sheet Control JavaScript API for the browser: Current workbook-unique name. Rename through update({name}).
- [PivotTable.refresh Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/refresh-method/llms-full.txt): PivotTable.refresh method in the TX Sheet Control JavaScript API for the browser: Re-read live source values and rewrite the output in one undoable transaction.
- [PivotTable.remove Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/remove-method/llms-full.txt): PivotTable.remove method in the browser JavaScript API: Remove this pivot and optionally preserve its rendered cells as a static report.
- [PivotTable.setExpanded Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/setexpanded-method/llms-full.txt): PivotTable.setExpanded method in the TX Sheet Control JavaScript API for the browser, with its syntax and a JavaScript example.
- [PivotTable.setFields Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/setfields-method/llms-full.txt): PivotTable.setFields method in the TX Sheet Control JavaScript API for the browser, with its syntax and a JavaScript example.
- [PivotTable.setFilters Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/setfilters-method/llms-full.txt): PivotTable.setFilters method in the TX Sheet Control JavaScript API for the browser: Replace report/member/value filters; supplying [] clears all filters.
- [PivotTable.snapshot Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/snapshot-property/llms-full.txt): PivotTable.snapshot property in the browser JavaScript API: Returns current persisted settings, including the materialized output range.
- [PivotTable.update Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/update-method/llms-full.txt): PivotTable.update method in the TX Sheet Control JavaScript API for the browser, with its syntax and a JavaScript example.

---

## Nearby

- **Previous:** [barcodeCheckDigit Function](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/barcodecheckdigit-function/llms-full.txt)
- **Next:** [PivotTable.snapshot Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/pivottable/snapshot-property/llms-full.txt)
