Edit

Share via


ExcelScript.RowColumnPivotHierarchy interface

Represents the Excel RowColumnPivotHierarchy.

Remarks

Examples

TypeScript
/**
 *  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.

TypeScript
getFields(): PivotField[];

Returns

getId()

ID of the RowColumnPivotHierarchy.

TypeScript
getId(): string;

Returns

string

getName()

Name of the RowColumnPivotHierarchy.

TypeScript
getName(): string;

Returns

string

getPivotField(name)

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

TypeScript
getPivotField(name: string): PivotField | undefined;

Parameters

name

string

Name of the PivotField to be retrieved.

Returns

getPosition()

Position of the RowColumnPivotHierarchy.

TypeScript
getPosition(): number;

Returns

number

setName(name)

Name of the RowColumnPivotHierarchy.

TypeScript
setName(name: string): void;

Parameters

name

string

Returns

void

setPosition(position)

Position of the RowColumnPivotHierarchy.

TypeScript
setPosition(position: number): void;

Parameters

position

number

Returns

void

setToDefault()

Reset the RowColumnPivotHierarchy back to its default values.

TypeScript
setToDefault(): void;

Returns

void