ExcelScript.PivotHierarchy interface

表示 Excel PivotHierarchy。

注解

示例

/**
 * This script creates a PivotTable from an existing table and adds it to a new worksheet.
 * This script assumes there is a table in the current worksheet with columns named "Type" and "Sales".
 */
function main(workbook: ExcelScript.Workbook) {
  // Create a PivotTable based on a table in the current worksheet.
  let sheet = workbook.getActiveWorksheet();
  let table = sheet.getTables()[0];

  // Add the PivotTable to a new worksheet.
  let newSheet = workbook.addWorksheet("Pivot");
  let pivotTable = newSheet.addPivotTable("My Pivot", table, "A1");

  // Add fields to the PivotTable to show "Sales" per "Type".
  pivotTable.addRowHierarchy(pivotTable.getHierarchy("Type"));
  pivotTable.addDataHierarchy(pivotTable.getHierarchy("Sales"));
}

方法

getFields()

返回与 PivotHierarchy 相关联的 PivotFields。

getId()

PivotHierarchy 的 ID。

getName()

PivotHierarchy 的名称。

getPivotField(name)

按名称获取透视字段。 如果 PivotField 不存在,则此方法返回 undefined

setName(name)

PivotHierarchy 的名称。

方法详细信息

getFields()

返回与 PivotHierarchy 相关联的 PivotFields。

getFields(): PivotField[];

返回

getId()

PivotHierarchy 的 ID。

getId(): string;

返回

string

getName()

PivotHierarchy 的名称。

getName(): string;

返回

string

getPivotField(name)

按名称获取透视字段。 如果 PivotField 不存在,则此方法返回 undefined

getPivotField(name: string): PivotField | undefined;

参数

name

string

要检索的 PivotField 的名称。

返回

setName(name)

PivotHierarchy 的名称。

setName(name: string): void;

参数

name

string

返回

void