Excel.PivotLayout class

Representa o layout visual da Tabela Dinâmica.

Extends

Propriedades

context

O contexto de solicitação associado ao objeto. Isso conecta o processo do suplemento ao processo do aplicativo host do Office.

layoutType

Essa propriedade indica o PivotLayoutType de todos os campos da Tabela Dinâmica. Se os campos têm diferentes estados, ele será nulo.

showColumnGrandTotals

Especifica se o relatório de Tabela Dinâmica mostra totais gerais para colunas.

showRowGrandTotals

Especifica se o relatório de Tabela Dinâmica mostra totais gerais para linhas.

subtotalLocation

Esta propriedade indica a SubtotalLocationType de todos os campos na Tabela Dinâmica. Se os campos tiverem estados diferentes, será null.

Métodos

getColumnLabelRange()

Retorna o intervalo onde residem os rótulos de coluna da Tabela Dinâmica.

getDataBodyRange()

Retorna o intervalo onde residem os valores de dados da tabela dinâmica.

getFilterAxisRange()

Retorna o intervalo de área de filtro da Tabela Dinâmica.

getRange()

Retorna o intervalo em que a Tabela Dinâmica existe, excluindo a área de filtro.

getRowLabelRange()

Retorna o intervalo onde residem os rótulos de linha da Tabela Dinâmica.

load(options)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

load(propertyNames)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

load(propertyNamesAndPaths)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

set(properties, options)

Define várias propriedades de um objeto ao mesmo tempo. Você pode passar um objeto simples com as propriedades apropriadas ou outro objeto de API do mesmo tipo.

set(properties)

Define várias propriedades no objeto ao mesmo tempo, com base em um objeto carregado existente.

toJSON()

Substitui o método JavaScript toJSON() para fornecer uma saída mais útil quando um objeto de API é passado para JSON.stringify(). (JSON.stringify, por sua vez, chama o toJSON método do objeto que é passado para ele.) Enquanto o objeto original Excel.PivotLayout é um objeto de API, o toJSON método retorna um objeto JavaScript simples (digitado como Excel.Interfaces.PivotLayoutData) que contém cópias superficiais de todas as propriedades filho carregadas do objeto original.

Detalhes da propriedade

context

O contexto de solicitação associado ao objeto. Isso conecta o processo do suplemento ao processo do aplicativo host do Office.

context: RequestContext;

Valor da propriedade

layoutType

Essa propriedade indica o PivotLayoutType de todos os campos da Tabela Dinâmica. Se os campos têm diferentes estados, ele será nulo.

layoutType: Excel.PivotLayoutType | "Compact" | "Tabular" | "Outline";

Valor da propriedade

Excel.PivotLayoutType | "Compact" | "Tabular" | "Outline"

Comentários

Conjunto de APIs: ExcelApi 1.8

Exemplos

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml

await Excel.run(async (context) => {
  // Change the PivotLayout.type to a new type.
  const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales");
  pivotTable.layout.load("layoutType");
  await context.sync();

  // Cycle between the three layout types.
  if (pivotTable.layout.layoutType === "Compact") {
    pivotTable.layout.layoutType = "Outline";
  } else if (pivotTable.layout.layoutType === "Outline") {
    pivotTable.layout.layoutType = "Tabular";
  } else {
    pivotTable.layout.layoutType = "Compact";
  }

  await context.sync();
  console.log("Pivot layout is now " + pivotTable.layout.layoutType);
});

showColumnGrandTotals

Especifica se o relatório de Tabela Dinâmica mostra totais gerais para colunas.

showColumnGrandTotals: boolean;

Valor da propriedade

boolean

Comentários

Conjunto de APIs: ExcelApi 1.8

Exemplos

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml

await Excel.run(async (context) => {
  // Turn the grand totals on and off for the rows and columns.
  const pivotTable = context.workbook.pivotTables.getItem("Farm Sales");
  const pivotLayout = pivotTable.layout;

  pivotLayout.load(["showRowGrandTotals", "showColumnGrandTotals"]);
  await context.sync();

  let showColumnTotals = !pivotLayout.showColumnGrandTotals;
  let showRowTotals = !pivotLayout.showRowGrandTotals;
  console.log(`Show column grand totals? - ${showColumnTotals}`);
  console.log(`Show row grand totals? - ${showRowTotals}`);

  pivotLayout.showColumnGrandTotals = showColumnTotals;
  pivotLayout.showRowGrandTotals = showRowTotals;

  await context.sync();
});

showRowGrandTotals

Especifica se o relatório de Tabela Dinâmica mostra totais gerais para linhas.

showRowGrandTotals: boolean;

Valor da propriedade

boolean

Comentários

Conjunto de APIs: ExcelApi 1.8

Exemplos

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml

await Excel.run(async (context) => {
  // Turn the grand totals on and off for the rows and columns.
  const pivotTable = context.workbook.pivotTables.getItem("Farm Sales");
  const pivotLayout = pivotTable.layout;

  pivotLayout.load(["showRowGrandTotals", "showColumnGrandTotals"]);
  await context.sync();

  let showColumnTotals = !pivotLayout.showColumnGrandTotals;
  let showRowTotals = !pivotLayout.showRowGrandTotals;
  console.log(`Show column grand totals? - ${showColumnTotals}`);
  console.log(`Show row grand totals? - ${showRowTotals}`);

  pivotLayout.showColumnGrandTotals = showColumnTotals;
  pivotLayout.showRowGrandTotals = showRowTotals;

  await context.sync();
});

subtotalLocation

Esta propriedade indica a SubtotalLocationType de todos os campos na Tabela Dinâmica. Se os campos tiverem estados diferentes, será null.

subtotalLocation: Excel.SubtotalLocationType | "AtTop" | "AtBottom" | "Off";

Valor da propriedade

Excel.SubtotalLocationType | "AtTop" | "AtBottom" | "Off"

Comentários

Conjunto de APIs: ExcelApi 1.8

Detalhes do método

getColumnLabelRange()

Retorna o intervalo onde residem os rótulos de coluna da Tabela Dinâmica.

getColumnLabelRange(): Excel.Range;

Retornos

Comentários

Conjunto de APIs: ExcelApi 1.8

getDataBodyRange()

Retorna o intervalo onde residem os valores de dados da tabela dinâmica.

getDataBodyRange(): Excel.Range;

Retornos

Comentários

Conjunto de APIs: ExcelApi 1.8

Exemplos

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-filters-and-summaries.yaml

await Excel.run(async (context) => {
    const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales");

    // The layout controls the ranges used by the PivotTable.
    const range = pivotTable.layout.getDataBodyRange();

    // Get all the data hierarchy totals.
    const grandTotalRange = range.getLastRow();
    grandTotalRange.load("address");
    await context.sync();
    
    // Use the wholesale and farm sale totals to make a final sum.
    const masterTotalRange = context.workbook.worksheets.getActiveWorksheet().getRange("B27:C27");
    masterTotalRange.formulas = [["All Crates", "=SUM(" + grandTotalRange.address + ")"]];
    await context.sync();
});

getFilterAxisRange()

Retorna o intervalo de área de filtro da Tabela Dinâmica.

getFilterAxisRange(): Excel.Range;

Retornos

Comentários

Conjunto de APIs: ExcelApi 1.8

getRange()

Retorna o intervalo em que a Tabela Dinâmica existe, excluindo a área de filtro.

getRange(): Excel.Range;

Retornos

Comentários

Conjunto de APIs: ExcelApi 1.8

getRowLabelRange()

Retorna o intervalo onde residem os rótulos de linha da Tabela Dinâmica.

getRowLabelRange(): Excel.Range;

Retornos

Comentários

Conjunto de APIs: ExcelApi 1.8

load(options)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

load(options?: Excel.Interfaces.PivotLayoutLoadOptions): Excel.PivotLayout;

Parâmetros

options
Excel.Interfaces.PivotLayoutLoadOptions

Fornece opções para quais propriedades do objeto devem ser carregadas.

Retornos

load(propertyNames)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

load(propertyNames?: string | string[]): Excel.PivotLayout;

Parâmetros

propertyNames

string | string[]

Uma cadeia de caracteres delimitada por vírgula ou uma matriz de cadeias de caracteres que especifica as propriedades a serem carregadas.

Retornos

load(propertyNamesAndPaths)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): Excel.PivotLayout;

Parâmetros

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select é uma cadeia de caracteres delimitada por vírgula que especifica as propriedades a serem carregadas e propertyNamesAndPaths.expand é uma cadeia de caracteres delimitada por vírgula que especifica as propriedades de navegação a serem carregadas.

Retornos

set(properties, options)

Define várias propriedades de um objeto ao mesmo tempo. Você pode passar um objeto simples com as propriedades apropriadas ou outro objeto de API do mesmo tipo.

set(properties: Interfaces.PivotLayoutUpdateData, options?: OfficeExtension.UpdateOptions): void;

Parâmetros

properties
Excel.Interfaces.PivotLayoutUpdateData

Um objeto JavaScript com propriedades estruturadas isomorficamente para as propriedades do objeto no qual o método é chamado.

options
OfficeExtension.UpdateOptions

Fornece uma opção para suprimir erros se o objeto de propriedades tentar definir propriedades somente leitura.

Retornos

void

set(properties)

Define várias propriedades no objeto ao mesmo tempo, com base em um objeto carregado existente.

set(properties: Excel.PivotLayout): void;

Parâmetros

properties
Excel.PivotLayout

Retornos

void

toJSON()

Substitui o método JavaScript toJSON() para fornecer uma saída mais útil quando um objeto de API é passado para JSON.stringify(). (JSON.stringify, por sua vez, chama o toJSON método do objeto que é passado para ele.) Enquanto o objeto original Excel.PivotLayout é um objeto de API, o toJSON método retorna um objeto JavaScript simples (digitado como Excel.Interfaces.PivotLayoutData) que contém cópias superficiais de todas as propriedades filho carregadas do objeto original.

toJSON(): Excel.Interfaces.PivotLayoutData;

Retornos