Share via


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 に関連付けられているピボット フィールドを返します。

getId()

PivotHierarchy の ID。

getName()

PivotHierarchy の名前。

getPivotField(name)

名前で PivotField を取得します。 PivotField が存在しない場合、このメソッドは を返します undefined

setName(name)

PivotHierarchy の名前。

メソッドの詳細

getFields()

PivotHierarchy に関連付けられているピボット フィールドを返します。

getFields(): PivotField[];

戻り値

getId()

PivotHierarchy の ID。

getId(): string;

戻り値

string

getName()

PivotHierarchy の名前。

getName(): string;

戻り値

string

getPivotField(name)

名前で PivotField を取得します。 PivotField が存在しない場合、このメソッドは を返します undefined

getPivotField(name: string): PivotField | undefined;

パラメーター

name

string

取得する PivotField の名前。

戻り値

setName(name)

PivotHierarchy の名前。

setName(name: string): void;

パラメーター

name

string

戻り値

void