ExcelScript.RowColumnPivotHierarchy interface

Represents the Excel RowColumnPivotHierarchy.

Remarks

Examples

/**
 *  This sample sorts the rows of a PivotTable.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get an existing PivotTable.
  const pivotTable = workbook.getPivotTable("Farm Sales");

  // Get the data hierarchy to use as the basis of the sort.
  const valueFieldToSortOn: ExcelScript.DataPivotHierarchy = pivotTable.getDataHierarchy("Sum of Crates Sold Wholesale");

  // Get the row to sort.
  const rowToSort: ExcelScript.RowColumnPivotHierarchy = pivotTable.getRowHierarchy("Farm");

  // Sort the "Farm" row's only field by the values in "Sum of Crates Sold Wholesale".
  rowToSort.getFields()[0].sortByValues(ExcelScript.SortBy.descending, valueFieldToSortOn);
}

Methods

getFields()

Returns the PivotFields associated with the RowColumnPivotHierarchy.

getId()

ID of the RowColumnPivotHierarchy.

getName()

Name of the RowColumnPivotHierarchy.

getPivotField(name)

Gets a PivotField by name. If the PivotField does not exist, then this method returns undefined.

getPosition()

Position of the RowColumnPivotHierarchy.

setName(name)

Name of the RowColumnPivotHierarchy.

setPosition(position)

Position of the RowColumnPivotHierarchy.

setToDefault()

Reset the RowColumnPivotHierarchy back to its default values.

Method Details

getFields()

Returns the PivotFields associated with the RowColumnPivotHierarchy.

getFields(): PivotField[];

Returns

getId()

ID of the RowColumnPivotHierarchy.

getId(): string;

Returns

string

getName()

Name of the RowColumnPivotHierarchy.

getName(): string;

Returns

string

getPivotField(name)

Gets a PivotField by name. If the PivotField does not exist, then this method returns undefined.

getPivotField(name: string): PivotField | undefined;

Parameters

name

string

Name of the PivotField to be retrieved.

Returns

getPosition()

Position of the RowColumnPivotHierarchy.

getPosition(): number;

Returns

number

setName(name)

Name of the RowColumnPivotHierarchy.

setName(name: string): void;

Parameters

name

string

Returns

void

setPosition(position)

Position of the RowColumnPivotHierarchy.

setPosition(position: number): void;

Parameters

position

number

Returns

void

setToDefault()

Reset the RowColumnPivotHierarchy back to its default values.

setToDefault(): void;

Returns

void