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
get |
Returns the PivotFields associated with the RowColumnPivotHierarchy. |
get |
ID of the RowColumnPivotHierarchy. |
get |
Name of the RowColumnPivotHierarchy. |
get |
Gets a PivotField by name. If the PivotField does not exist, then this method returns |
get |
Position of the RowColumnPivotHierarchy. |
set |
Name of the RowColumnPivotHierarchy. |
set |
Position of the RowColumnPivotHierarchy. |
set |
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
ExcelScript.PivotField | undefined
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
Office Scripts