Edit

Excel.PivotLayout class

Represents the visual layout of the PivotTable.

Extends

Remarks

[Api set: ExcelApi 1.8]

Properties

altTextDescription

The alt text description of the PivotTable.

Alt text provides alternative, text-based representations of the information contained in the PivotTable. This information is useful for people with vision or cognitive impairments who may not be able to see or understand the table. A title can be read to a person with a disability and is used to determine whether they wish to hear the description of the content.

altTextTitle

The alt text title of the PivotTable.

Alt text provides alternative, text-based representations of the information contained in the PivotTable. This information is useful for people with vision or cognitive impairments who may not be able to see or understand the table. A title can be read to a person with a disability and is used to determine whether they wish to hear the description of the content.

autoFormat

Specifies if formatting will be automatically formatted when it's refreshed or when fields are moved.

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

emptyCellText

The text that is automatically filled into any empty cell in the PivotTable if fillEmptyCells == true. Note that this value persists if fillEmptyCells is set to false, and that setting this value does not set that property to true. By default, this is an empty string.

enableFieldList

Specifies if the field list can be shown in the UI.

fillEmptyCells

Specifies whether empty cells in the PivotTable should be populated with the emptyCellText. Default is false. Note that the value of emptyCellText persists when this property is set to false.

layoutType

This property indicates the PivotLayoutType of all fields on the PivotTable. If fields have different states, this will be null.

preserveFormatting

Specifies if formatting is preserved when the report is refreshed or recalculated by operations such as pivoting, sorting, or changing page field items.

showColumnGrandTotals

Specifies if the PivotTable report shows grand totals for columns.

showFieldHeaders

Specifies whether the PivotTable displays field headers (field captions and filter drop-downs).

showRowGrandTotals

Specifies if the PivotTable report shows grand totals for rows.

subtotalLocation

This property indicates the SubtotalLocationType of all fields on the PivotTable. If fields have different states, this will be null.

Methods

displayBlankLineAfterEachItem(display)

Sets whether or not to display a blank line after each item. This is set at the global level for the PivotTable and applied to individual PivotFields. This function overwrites the setting for all fields in the PivotTable to the value of display parameter.

getColumnLabelRange()

Returns the range where the PivotTable's column labels reside.

getDataBodyRange()

Returns the range where the PivotTable's data values reside.

getDataHierarchy(cell)

Gets the DataHierarchy that is used to calculate the value in a specified range within the PivotTable.

getFilterAxisRange()

Returns the range of the PivotTable's filter area.

getPivotItems(axis, cell)

Gets the PivotItems from an axis that make up the value in a specified range within the PivotTable.

getPivotItems(axis, cell)

Gets the PivotItems from an axis that make up the value in a specified range within the PivotTable.

getRange()

Returns the range the PivotTable exists on, excluding the filter area.

getRowLabelRange()

Returns the range where the PivotTable's row labels reside.

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

repeatAllItemLabels(repeatLabels)

Sets the "repeat all item labels" setting across all fields in the PivotTable.

set(properties, options)

Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties)

Sets multiple properties on the object at the same time, based on an existing loaded object.

setAutoSortOnCell(cell, sortBy)

Sets the PivotTable to automatically sort using the specified cell to automatically select all necessary criteria and context. This behaves identically to applying an autosort from the UI.

setAutoSortOnCell(cell, sortBy)

Sets the PivotTable to automatically sort using the specified cell to automatically select all necessary criteria and context. This behaves identically to applying an autosort from the UI.

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that's passed to it.) Whereas the original Excel.PivotLayout object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.PivotLayoutData) that contains shallow copies of any loaded child properties from the original object.

Property Details

altTextDescription

The alt text description of the PivotTable.

Alt text provides alternative, text-based representations of the information contained in the PivotTable. This information is useful for people with vision or cognitive impairments who may not be able to see or understand the table. A title can be read to a person with a disability and is used to determine whether they wish to hear the description of the content.

altTextDescription: string;

Property Value

string

Remarks

[Api set: ExcelApi 1.13]

altTextTitle

The alt text title of the PivotTable.

Alt text provides alternative, text-based representations of the information contained in the PivotTable. This information is useful for people with vision or cognitive impairments who may not be able to see or understand the table. A title can be read to a person with a disability and is used to determine whether they wish to hear the description of the content.

altTextTitle: string;

Property Value

string

Remarks

[Api set: ExcelApi 1.13]

autoFormat

Specifies if formatting will be automatically formatted when it's refreshed or when fields are moved.

autoFormat: boolean;

Property Value

boolean

Remarks

[Api set: ExcelApi 1.9]

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

context: RequestContext;

Property Value

emptyCellText

The text that is automatically filled into any empty cell in the PivotTable if fillEmptyCells == true. Note that this value persists if fillEmptyCells is set to false, and that setting this value does not set that property to true. By default, this is an empty string.

emptyCellText: string;

Property Value

string

Remarks

[Api set: ExcelApi 1.13]

enableFieldList

Specifies if the field list can be shown in the UI.

enableFieldList: boolean;

Property Value

boolean

Remarks

[Api set: ExcelApi 1.10]

fillEmptyCells

Specifies whether empty cells in the PivotTable should be populated with the emptyCellText. Default is false. Note that the value of emptyCellText persists when this property is set to false.

fillEmptyCells: boolean;

Property Value

boolean

Remarks

[Api set: ExcelApi 1.13]

layoutType

This property indicates the PivotLayoutType of all fields on the PivotTable. If fields have different states, this will be null.

layoutType: Excel.PivotLayoutType | "Compact" | "Tabular" | "Outline";

Property Value

Excel.PivotLayoutType | "Compact" | "Tabular" | "Outline"

Remarks

[Api set: ExcelApi 1.8]

preserveFormatting

Specifies if formatting is preserved when the report is refreshed or recalculated by operations such as pivoting, sorting, or changing page field items.

preserveFormatting: boolean;

Property Value

boolean

Remarks

[Api set: ExcelApi 1.9]

showColumnGrandTotals

Specifies if the PivotTable report shows grand totals for columns.

showColumnGrandTotals: boolean;

Property Value

boolean

Remarks

[Api set: ExcelApi 1.8]

showFieldHeaders

Specifies whether the PivotTable displays field headers (field captions and filter drop-downs).

showFieldHeaders: boolean;

Property Value

boolean

Remarks

[Api set: ExcelApi 1.13]

showRowGrandTotals

Specifies if the PivotTable report shows grand totals for rows.

showRowGrandTotals: boolean;

Property Value

boolean

Remarks

[Api set: ExcelApi 1.8]

subtotalLocation

This property indicates the SubtotalLocationType of all fields on the PivotTable. If fields have different states, this will be null.

subtotalLocation: Excel.SubtotalLocationType | "AtTop" | "AtBottom" | "Off";

Property Value

Excel.SubtotalLocationType | "AtTop" | "AtBottom" | "Off"

Remarks

[Api set: ExcelApi 1.8]

Method Details

displayBlankLineAfterEachItem(display)

Sets whether or not to display a blank line after each item. This is set at the global level for the PivotTable and applied to individual PivotFields. This function overwrites the setting for all fields in the PivotTable to the value of display parameter.

displayBlankLineAfterEachItem(display: boolean): void;

Parameters

display

boolean

True turns on the blank-line display setting. False turns it off.

Returns

void

Remarks

[Api set: ExcelApi 1.13]

getColumnLabelRange()

Returns the range where the PivotTable's column labels reside.

getColumnLabelRange(): Excel.Range;

Returns

Remarks

[Api set: ExcelApi 1.8]

getDataBodyRange()

Returns the range where the PivotTable's data values reside.

getDataBodyRange(): Excel.Range;

Returns

Remarks

[Api set: ExcelApi 1.8]

getDataHierarchy(cell)

Gets the DataHierarchy that is used to calculate the value in a specified range within the PivotTable.

getDataHierarchy(cell: Range | string): Excel.DataPivotHierarchy;

Parameters

cell

Excel.Range | string

A single cell within the PivotTable data body.

Returns

The DataPivotHierarchy object used to calculate the value in the specified cell.

Remarks

[Api set: ExcelApi 1.9]

getFilterAxisRange()

Returns the range of the PivotTable's filter area.

getFilterAxisRange(): Excel.Range;

Returns

Remarks

[Api set: ExcelApi 1.8]

getPivotItems(axis, cell)

Gets the PivotItems from an axis that make up the value in a specified range within the PivotTable.

getPivotItems(axis: Excel.PivotAxis, cell: Range | string): Excel.PivotItemCollection;

Parameters

axis
Excel.PivotAxis

The axis from which to get the PivotItems. Must be either "row" or "column."

cell

Excel.Range | string

A single cell within the PivotTable's data body.

Returns

A PivotItemCollection of the PivotItems that are used to calculate the values in the specified row.

Remarks

[Api set: ExcelApi 1.9]

getPivotItems(axis, cell)

Gets the PivotItems from an axis that make up the value in a specified range within the PivotTable.

getPivotItems(axis: "Unknown" | "Row" | "Column" | "Data" | "Filter", cell: Range | string): Excel.PivotItemCollection;

Parameters

axis

"Unknown" | "Row" | "Column" | "Data" | "Filter"

The axis from which to get the PivotItems. Must be either "row" or "column."

cell

Excel.Range | string

A single cell within the PivotTable's data body.

Returns

A PivotItemCollection of the PivotItems that are used to calculate the values in the specified row.

Remarks

[Api set: ExcelApi 1.9]

getRange()

Returns the range the PivotTable exists on, excluding the filter area.

getRange(): Excel.Range;

Returns

Remarks

[Api set: ExcelApi 1.8]

getRowLabelRange()

Returns the range where the PivotTable's row labels reside.

getRowLabelRange(): Excel.Range;

Returns

Remarks

[Api set: ExcelApi 1.8]

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(options?: Excel.Interfaces.PivotLayoutLoadOptions): Excel.PivotLayout;

Parameters

options
Excel.Interfaces.PivotLayoutLoadOptions

Provides options for which properties of the object to load.

Returns

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames?: string | string[]): Excel.PivotLayout;

Parameters

propertyNames

string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): Excel.PivotLayout;

Parameters

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.

Returns

repeatAllItemLabels(repeatLabels)

Sets the "repeat all item labels" setting across all fields in the PivotTable.

repeatAllItemLabels(repeatLabels: boolean): void;

Parameters

repeatLabels

boolean

True turns on the label-repetition display setting. False turns it off.

Returns

void

Remarks

[Api set: ExcelApi 1.13]

set(properties, options)

Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties: Interfaces.PivotLayoutUpdateData, options?: OfficeExtension.UpdateOptions): void;

Parameters

properties
Excel.Interfaces.PivotLayoutUpdateData

A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called.

options
OfficeExtension.UpdateOptions

Provides an option to suppress errors if the properties object tries to set any read-only properties.

Returns

void

set(properties)

Sets multiple properties on the object at the same time, based on an existing loaded object.

set(properties: Excel.PivotLayout): void;

Parameters

properties
Excel.PivotLayout

Returns

void

setAutoSortOnCell(cell, sortBy)

Sets the PivotTable to automatically sort using the specified cell to automatically select all necessary criteria and context. This behaves identically to applying an autosort from the UI.

setAutoSortOnCell(cell: Range | string, sortBy: Excel.SortBy): void;

Parameters

cell

Excel.Range | string

A single cell to use get the criteria from for applying the autosort.

sortBy
Excel.SortBy

The direction of the sort.

Returns

void

Remarks

[Api set: ExcelApi 1.9]

setAutoSortOnCell(cell, sortBy)

Sets the PivotTable to automatically sort using the specified cell to automatically select all necessary criteria and context. This behaves identically to applying an autosort from the UI.

setAutoSortOnCell(cell: Range | string, sortBy: "Ascending" | "Descending"): void;

Parameters

cell

Excel.Range | string

A single cell to use get the criteria from for applying the autosort.

sortBy

"Ascending" | "Descending"

The direction of the sort.

Returns

void

Remarks

[Api set: ExcelApi 1.9]

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that's passed to it.) Whereas the original Excel.PivotLayout object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.PivotLayoutData) that contains shallow copies of any loaded child properties from the original object.

toJSON(): Excel.Interfaces.PivotLayoutData;

Returns