> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reducto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Other classes: PivotTables and slicers

## `CalculatedField`

One calculated field.

Import from `@reductoai/xlsx/officejs`.

### CalculatedField properties

| Name | Type | Description |
| - | - | - |
| `name` | `string` | read-only |
| `formula` | `string` | The formula with its `=`, as Excel's Insert Calculated Field window shows it. |

### `CalculatedField.delete()`

```ts theme={null}
delete(): void
```

Removes the field from the cache and from the values of every table on it.

## `CalculatedFieldCollection`

The cache's calculated fields; Office.js has none, so the names follow VBA.

Import from `@reductoai/xlsx/officejs`.

### CalculatedFieldCollection properties

| Name | Type | Description |
| - | - | - |
| `items` | `CalculatedField[]` | read-only |

### `CalculatedFieldCollection.add()`

```ts theme={null}
add(name: string, formula: string): CalculatedField
```

Adds a field such as `add("Margin", "=(Revenue-'Unit Cost')/Revenue")`. Each field name in the
formula stands for that field's sum on a cell; a name with a space goes in single quotes.
The field starts off every axis: add it with `dataHierarchies.add`.

### `CalculatedFieldCollection.getCount()`

```ts theme={null}
getCount(): ClientResult<number>
```

### `CalculatedFieldCollection.getItem()`

```ts theme={null}
getItem(name: string): CalculatedField
```

### `CalculatedFieldCollection.getItemOrNullObject()`

```ts theme={null}
getItemOrNullObject(name: string): Nullable<CalculatedField>
```

## `ChartPivotOptions`

The field buttons a pivot chart shows (`c14:pivotOptions`).

Import from `@reductoai/xlsx/officejs`.

### ChartPivotOptions properties

| Name | Type | Description |
| - | - | - |
| `showAxisFieldButtons` | `boolean` | |
| `showLegendFieldButtons` | `boolean` | |
| `showReportFilterFieldButtons` | `boolean` | |
| `showValueFieldButtons` | `boolean` | |

### `ChartPivotOptions.set()`

```ts theme={null}
set(properties: UpdateData<ChartPivotOptions>, options?: UpdateOptions): void
```

## `DataPivotHierarchyCollection`

`Excel.DataPivotHierarchyCollection`: the value fields.

Import from `@reductoai/xlsx/officejs`.

### DataPivotHierarchyCollection properties

| Name | Type | Description |
| - | - | - |
| `items` | `DataPivotHierarchy[]` | read-only |

### `DataPivotHierarchyCollection.add()`

```ts theme={null}
add(hierarchy: PivotHierarchy): DataPivotHierarchy
```

A value field over `hierarchy`: Sum when every value is a number, otherwise Count.

### `DataPivotHierarchyCollection.getCount()`

```ts theme={null}
getCount(): ClientResult<number>
```

### `DataPivotHierarchyCollection.getItem()`

```ts theme={null}
getItem(name: string): DataPivotHierarchy
```

### `DataPivotHierarchyCollection.getItemOrNullObject()`

```ts theme={null}
getItemOrNullObject(name: string): Nullable<DataPivotHierarchy>
```

### `DataPivotHierarchyCollection.remove()`

```ts theme={null}
remove(hierarchy: DataPivotHierarchy): void
```

## `FilterPivotHierarchy`

A field on the filter axis.

Import from `@reductoai/xlsx/officejs`. Extends [`PivotHierarchy`](https://docs.reducto.ai/office/xlsx/api/pivots#pivothierarchy).

### FilterPivotHierarchy properties

| Name | Type | Description |
| - | - | - |
| `name` | `string` | read-only |
| `enableMultipleFilterItems` | `boolean` | Several items can be shown at once; turning it off shows every item. |
| `fields` | `PivotFieldCollection` | read-only `RowColumnPivotHierarchy.fields`: the one field of a source column. |
| `id` | `string` | read-only |
| `position` | `number` | Place on its axis, from 0. |

### `FilterPivotHierarchy.set()`

```ts theme={null}
set(
  properties: PivotHierarchy | UpdateData<PivotHierarchy>,
  options?: UpdateOptions,
): void
```

Sets several properties at once; a navigation member takes a nested batch.

### `FilterPivotHierarchy.setToDefault()`

```ts theme={null}
setToDefault(): void
```

## `FilterPivotHierarchyCollection`

`Excel.PivotHierarchyCollection` (every source field) and the row, column and filter
collections, which `add` a field to their axis and `remove` it.

Import from `@reductoai/xlsx/officejs`. Extends `PivotHierarchyCollection<FilterPivotHierarchy>`.

### FilterPivotHierarchyCollection properties

| Name | Type | Description |
| - | - | - |
| `items` | `H[]` | read-only |

### `FilterPivotHierarchyCollection.add()`

```ts theme={null}
add(hierarchy: PivotHierarchy): FilterPivotHierarchy
```

Places the field last on this axis, taking it off any other axis it was on.

### `FilterPivotHierarchyCollection.getCount()`

```ts theme={null}
getCount(): ClientResult<number>
```

### `FilterPivotHierarchyCollection.getItem()`

```ts theme={null}
getItem(name: string): FilterPivotHierarchy
```

### `FilterPivotHierarchyCollection.getItemOrNullObject()`

```ts theme={null}
getItemOrNullObject(name: string): Nullable<FilterPivotHierarchy>
```

### `FilterPivotHierarchyCollection.remove()`

```ts theme={null}
remove(hierarchy: PivotHierarchy): void
```

## `PivotFieldCollection`

`Excel.PivotFieldCollection`: a hierarchy's fields; a source column has one.

Import from `@reductoai/xlsx/officejs`.

### PivotFieldCollection properties

| Name | Type | Description |
| - | - | - |
| `items` | `PivotField[]` | read-only |

### `PivotFieldCollection.getCount()`

```ts theme={null}
getCount(): ClientResult<number>
```

### `PivotFieldCollection.getItem()`

```ts theme={null}
getItem(name: string): PivotField
```

### `PivotFieldCollection.getItemOrNullObject()`

```ts theme={null}
getItemOrNullObject(name: string): Nullable<PivotField>
```

## `PivotHierarchyCollection`

`Excel.PivotHierarchyCollection` (every source field) and the row, column and filter
collections, which `add` a field to their axis and `remove` it.

Import from `@reductoai/xlsx/officejs`.

### PivotHierarchyCollection properties

| Name | Type | Description |
| - | - | - |
| `items` | `H[]` | read-only |

### `PivotHierarchyCollection.add()`

```ts theme={null}
add(hierarchy: PivotHierarchy): H
```

Places the field last on this axis, taking it off any other axis it was on.

### `PivotHierarchyCollection.getCount()`

```ts theme={null}
getCount(): ClientResult<number>
```

### `PivotHierarchyCollection.getItem()`

```ts theme={null}
getItem(name: string): H
```

### `PivotHierarchyCollection.getItemOrNullObject()`

```ts theme={null}
getItemOrNullObject(name: string): Nullable<H>
```

### `PivotHierarchyCollection.remove()`

```ts theme={null}
remove(hierarchy: PivotHierarchy): void
```

## `PivotItem`

`Excel.PivotItem`: shown or hidden by its field's filter, expanded or collapsed.

Import from `@reductoai/xlsx/officejs`.

### PivotItem properties

| Name | Type | Description |
| - | - | - |
| `name` | `string` | read-only |
| `id` | `string` | read-only |
| `isExpanded` | `boolean` | Whether the item shows its inner items; collapsed, its line shows its totals. |
| `visible` | `boolean` | |

### `PivotItem.set()`

```ts theme={null}
set(properties: PivotItem | UpdateData<PivotItem>, options?: UpdateOptions): void
```

Sets several properties at once; a navigation member takes a nested batch.

## `PivotItemCollection`

`Excel.PivotItemCollection`: a row, column or filter field's items.

Import from `@reductoai/xlsx/officejs`.

### PivotItemCollection properties

| Name | Type | Description |
| - | - | - |
| `items` | `PivotItem[]` | read-only |

### `PivotItemCollection.getCount()`

```ts theme={null}
getCount(): ClientResult<number>
```

### `PivotItemCollection.getItem()`

```ts theme={null}
getItem(name: string): PivotItem
```

### `PivotItemCollection.getItemOrNullObject()`

```ts theme={null}
getItemOrNullObject(name: string): Nullable<PivotItem>
```

## `PivotTableScopedCollection`

`Excel.PivotTableScopedCollection`: the pivot tables that meet a range.

Not exported by name. You get it from the API.

### PivotTableScopedCollection properties

| Name | Type | Description |
| - | - | - |
| `count` | `number` | read-only |
| `items` | `ExcelPivotTable[]` | read-only |

### `PivotTableScopedCollection.getCount()`

```ts theme={null}
getCount(): ClientResult<number>
```

### `PivotTableScopedCollection.getFirst()`

```ts theme={null}
getFirst(): ExcelPivotTable
```

The first in the workbook's order; throws when none meets the range.

### `PivotTableScopedCollection.getFirstOrNullObject()`

```ts theme={null}
getFirstOrNullObject(): Nullable<ExcelPivotTable>
```

### `PivotTableScopedCollection.getItem()`

```ts theme={null}
getItem(name: string): ExcelPivotTable
```

### `PivotTableScopedCollection.getItemOrNullObject()`

```ts theme={null}
getItemOrNullObject(name: string): Nullable<ExcelPivotTable>
```

## `PivotTableStyle`

A table, pivot, slicer or timeline style: built-in ones are read-only.

Import from `@reductoai/xlsx/officejs`.

### PivotTableStyle properties

| Name | Type | Description |
| - | - | - |
| `name` | `string` | |
| `readOnly` | `boolean` | read-only |

### `PivotTableStyle.delete()`

```ts theme={null}
delete(): void
```

### `PivotTableStyle.duplicate()`

```ts theme={null}
duplicate(): this
```

A copy named "\<name> 2"; a built-in table or pivot style copies its formats.

### `PivotTableStyle.set()`

```ts theme={null}
set(properties: Record<string, unknown>, options?: UpdateOptions): void
```

## `PivotTableStyleCollection`

The styles of one kind: built-in ones, then the workbook's own.

Import from `@reductoai/xlsx/officejs`.

### PivotTableStyleCollection properties

| Name | Type | Description |
| - | - | - |
| `items` | `StyleOf<K>[]` | read-only |

### `PivotTableStyleCollection.add()`

```ts theme={null}
add(name: string, makeUniqueName?: boolean): PivotTableStyle
```

A blank style; `makeUniqueName` numbers a name already in use instead of throwing.

### `PivotTableStyleCollection.getCount()`

```ts theme={null}
getCount(): ClientResult<number>
```

### `PivotTableStyleCollection.getDefault()`

```ts theme={null}
getDefault(): PivotTableStyle
```

### `PivotTableStyleCollection.getItem()`

```ts theme={null}
getItem(name: string): PivotTableStyle
```

### `PivotTableStyleCollection.getItemOrNullObject()`

```ts theme={null}
getItemOrNullObject(name: string): Nullable<PivotTableStyle>
```

### `PivotTableStyleCollection.setDefault()`

```ts theme={null}
setDefault(newDefaultStyle: string | PivotTableStyle): void
```

## `RowColumnPivotHierarchyCollection`

`Excel.PivotHierarchyCollection` (every source field) and the row, column and filter
collections, which `add` a field to their axis and `remove` it.

Import from `@reductoai/xlsx/officejs`. Extends `PivotHierarchyCollection<RowColumnPivotHierarchy>`.

### RowColumnPivotHierarchyCollection properties

| Name | Type | Description |
| - | - | - |
| `items` | `H[]` | read-only |

### `RowColumnPivotHierarchyCollection.add()`

```ts theme={null}
add(hierarchy: PivotHierarchy): RowColumnPivotHierarchy
```

Places the field last on this axis, taking it off any other axis it was on.

### `RowColumnPivotHierarchyCollection.getCount()`

```ts theme={null}
getCount(): ClientResult<number>
```

### `RowColumnPivotHierarchyCollection.getItem()`

```ts theme={null}
getItem(name: string): RowColumnPivotHierarchy
```

### `RowColumnPivotHierarchyCollection.getItemOrNullObject()`

```ts theme={null}
getItemOrNullObject(name: string): Nullable<RowColumnPivotHierarchy>
```

### `RowColumnPivotHierarchyCollection.remove()`

```ts theme={null}
remove(hierarchy: PivotHierarchy): void
```

## `Slicer`

A slicer: a button panel that filters a table column or a pivot field.

Import from `@reductoai/xlsx/officejs`.

### Slicer properties

| Name | Type | Description |
| - | - | - |
| `buttonHeight` | `number` | Buttons > Height in points; an extension (VBA's `RowHeight`). |
| `buttonWidth` | `number` | Buttons > Width in points, from the frame's width; setting it resizes the frame, as in Excel. |
| `caption` | `string` | |
| `columnCount` | `number` | Buttons > Columns; an extension (VBA's `NumberOfColumns`). |
| `crossFilter` | `SlicerCrossFilter` | Slicer Settings' items with no data; an extension (VBA's `SlicerCache.CrossFilterType`). |
| `formulaName` | `string` | read-only Slicer Settings' Name to use in formulas: the slicer cache's name; an extension. |
| `height` | `number` | |
| `id` | `string` | read-only |
| `isFilterCleared` | `boolean` | read-only |
| `left` | `number` | |
| `name` | `string` | |
| `showHeader` | `boolean` | Slicer Settings' Display header; an extension (VBA's `DisplayHeader`). |
| `showItemsDeleted` | `boolean` | Slicer Settings' Show items deleted from the data source; an extension (VBA's `SlicerCache.ShowAllItems`). |
| `slicerItems` | `SlicerItemCollection` | read-only |
| `sortBy` | `SlicerSortType` | Items keep the order their values sort in; a source order exists only for OLAP data. |
| `sortUsingCustomLists` | `boolean` | Slicer Settings' Use Custom Lists when sorting; an extension (VBA's `SlicerCache.SortUsingCustomLists`). |
| `sourceName` | `string` | read-only Slicer Settings' Source Name: the table column or pivot field; an extension. |
| `style` | `string` | |
| `top` | `number` | |
| `width` | `number` | |
| `worksheet` | `ExcelWorksheet` | read-only |

### `Slicer.clearFilters()`

```ts theme={null}
clearFilters(): void
```

### `Slicer.delete()`

```ts theme={null}
delete(): void
```

### `Slicer.getConnectablePivotTables()`

```ts theme={null}
getConnectablePivotTables(): ExcelPivotTable[]
```

Extension: the pivot tables Report Connections offers, those on the slicer's pivot cache.

### `Slicer.getPivotTables()`

```ts theme={null}
getPivotTables(): ExcelPivotTable[]
```

Extension (VBA's `SlicerCache.PivotTables`): the pivot tables this slicer filters.

### `Slicer.getSelectedItems()`

```ts theme={null}
getSelectedItems(): ClientResult<string[]>
```

### `Slicer.selectItems()`

```ts theme={null}
selectItems(items?: string[]): void
```

Shows the named items; no list, or an empty one, shows them all.

### `Slicer.set()`

```ts theme={null}
set(properties: UpdateData<Slicer>, options?: UpdateOptions): void
```

### `Slicer.setPivotTables()`

```ts theme={null}
setPivotTables(pivotTables: (string | ExcelPivotTable)[]): void
```

Extension (Report Connections): the slicer filters exactly these pivot tables. One it gains takes
the slicer's filter; one it loses keeps its own.

## `SlicerCollection`

The slicers of the workbook, or of one worksheet.

Import from `@reductoai/xlsx/officejs`.

### SlicerCollection properties

| Name | Type | Description |
| - | - | - |
| `items` | `Slicer[]` | read-only |

### `SlicerCollection.add()`

```ts theme={null}
add(
  slicerSource: string | ExcelTable | ExcelPivotTable,
  sourceField: string | number | TableColumn | PivotField,
  slicerDestination?: string | ExcelWorksheet,
): Slicer
```

A slicer on a table column or a pivot field, on `slicerDestination` or this sheet.

### `SlicerCollection.getCount()`

```ts theme={null}
getCount(): ClientResult<number>
```

### `SlicerCollection.getItem()`

```ts theme={null}
getItem(key: string): Slicer
```

### `SlicerCollection.getItemAt()`

```ts theme={null}
getItemAt(index: number): Slicer
```

### `SlicerCollection.getItemOrNullObject()`

```ts theme={null}
getItemOrNullObject(key: string): Nullable<Slicer>
```

## `SlicerItem`

One button of a slicer.

Import from `@reductoai/xlsx/officejs`.

### SlicerItem properties

| Name | Type | Description |
| - | - | - |
| `hasData` | `boolean` | read-only |
| `isSelected` | `boolean` | Selecting adds the item to the selection; clearing the last one is refused, as in Excel. |
| `key` | `string` | read-only |
| `name` | `string` | read-only |

### `SlicerItem.set()`

```ts theme={null}
set(properties: UpdateData<SlicerItem>, options?: UpdateOptions): void
```

## `SlicerItemCollection`

Import from `@reductoai/xlsx/officejs`.

### SlicerItemCollection properties

| Name | Type | Description |
| - | - | - |
| `items` | `SlicerItem[]` | read-only |

### `SlicerItemCollection.getCount()`

```ts theme={null}
getCount(): ClientResult<number>
```

### `SlicerItemCollection.getItem()`

```ts theme={null}
getItem(key: string): SlicerItem
```

### `SlicerItemCollection.getItemAt()`

```ts theme={null}
getItemAt(index: number): SlicerItem
```

### `SlicerItemCollection.getItemOrNullObject()`

```ts theme={null}
getItemOrNullObject(key: string): Nullable<SlicerItem>
```

## `SlicerStyle`

A table, pivot, slicer or timeline style: built-in ones are read-only.

Import from `@reductoai/xlsx/officejs`.

### SlicerStyle properties

| Name | Type | Description |
| - | - | - |
| `name` | `string` | |
| `readOnly` | `boolean` | read-only |

### `SlicerStyle.delete()`

```ts theme={null}
delete(): void
```

### `SlicerStyle.duplicate()`

```ts theme={null}
duplicate(): this
```

A copy named "\<name> 2"; a built-in table or pivot style copies its formats.

### `SlicerStyle.set()`

```ts theme={null}
set(properties: Record<string, unknown>, options?: UpdateOptions): void
```

## `SlicerStyleCollection`

The styles of one kind: built-in ones, then the workbook's own.

Import from `@reductoai/xlsx/officejs`.

### SlicerStyleCollection properties

| Name | Type | Description |
| - | - | - |
| `items` | `StyleOf<K>[]` | read-only |

### `SlicerStyleCollection.add()`

```ts theme={null}
add(name: string, makeUniqueName?: boolean): SlicerStyle
```

A blank style; `makeUniqueName` numbers a name already in use instead of throwing.

### `SlicerStyleCollection.getCount()`

```ts theme={null}
getCount(): ClientResult<number>
```

### `SlicerStyleCollection.getDefault()`

```ts theme={null}
getDefault(): SlicerStyle
```

### `SlicerStyleCollection.getItem()`

```ts theme={null}
getItem(name: string): SlicerStyle
```

### `SlicerStyleCollection.getItemOrNullObject()`

```ts theme={null}
getItemOrNullObject(name: string): Nullable<SlicerStyle>
```

### `SlicerStyleCollection.setDefault()`

```ts theme={null}
setDefault(newDefaultStyle: string | SlicerStyle): void
```

## `TimelineStyle`

A table, pivot, slicer or timeline style: built-in ones are read-only.

Import from `@reductoai/xlsx/officejs`.

### TimelineStyle properties

| Name | Type | Description |
| - | - | - |
| `name` | `string` | |
| `readOnly` | `boolean` | read-only |

### `TimelineStyle.delete()`

```ts theme={null}
delete(): void
```

### `TimelineStyle.duplicate()`

```ts theme={null}
duplicate(): this
```

A copy named "\<name> 2"; a built-in table or pivot style copies its formats.

### `TimelineStyle.set()`

```ts theme={null}
set(properties: Record<string, unknown>, options?: UpdateOptions): void
```

## `TimelineStyleCollection`

The styles of one kind: built-in ones, then the workbook's own.

Import from `@reductoai/xlsx/officejs`.

### TimelineStyleCollection properties

| Name | Type | Description |
| - | - | - |
| `items` | `StyleOf<K>[]` | read-only |

### `TimelineStyleCollection.add()`

```ts theme={null}
add(name: string, makeUniqueName?: boolean): TimelineStyle
```

A blank style; `makeUniqueName` numbers a name already in use instead of throwing.

### `TimelineStyleCollection.getCount()`

```ts theme={null}
getCount(): ClientResult<number>
```

### `TimelineStyleCollection.getDefault()`

```ts theme={null}
getDefault(): TimelineStyle
```

### `TimelineStyleCollection.getItem()`

```ts theme={null}
getItem(name: string): TimelineStyle
```

### `TimelineStyleCollection.getItemOrNullObject()`

```ts theme={null}
getItemOrNullObject(name: string): Nullable<TimelineStyle>
```

### `TimelineStyleCollection.setDefault()`

```ts theme={null}
setDefault(newDefaultStyle: string | TimelineStyle): void
```
