Compartilhar via


ExcelScript.PivotHierarchy interface

Representa o Excel PivotHierarchy.

Comentários

Exemplos

/**
 * 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"));
}

Métodos

getFields()

Retorna PivotFields associados a PivotHierarchy.

getId()

ID da PivotHierarchy.

getName()

Nome do PivotHierarchy.

getPivotField(name)

Obtém um PivotField pelo nome. Se o PivotField não existir, esse método retornará undefined.

setName(name)

Nome do PivotHierarchy.

Detalhes do método

getFields()

Retorna PivotFields associados a PivotHierarchy.

getFields(): PivotField[];

Retornos

getId()

ID da PivotHierarchy.

getId(): string;

Retornos

string

getName()

Nome do PivotHierarchy.

getName(): string;

Retornos

string

getPivotField(name)

Obtém um PivotField pelo nome. Se o PivotField não existir, esse método retornará undefined.

getPivotField(name: string): PivotField | undefined;

Parâmetros

name

string

Nome do PivotField a ser recuperado.

Retornos

setName(name)

Nome do PivotHierarchy.

setName(name: string): void;

Parâmetros

name

string

Retornos

void