ExcelScript.PivotTable interface

Représente un tableau croisé dynamique Excel.

Remarques

Exemples

/**
 * 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éthodes

addColumnHierarchy(pivotHierarchy)

Ajoute le PivotHierarchy à l’axe en cours. Si la hiérarchie apparaît ailleurs sur la ligne, colonne ou axe de filtre, celle-ci est supprimée de cet emplacement.

addDataHierarchy(pivotHierarchy)

Ajoute le PivotHierarchy à l’axe en cours.

addFilterHierarchy(pivotHierarchy)

Ajoute le PivotHierarchy à l’axe en cours. Si la hiérarchie apparaît ailleurs sur la ligne, colonne ou axe de filtre, celle-ci est supprimée de cet emplacement.

addRowHierarchy(pivotHierarchy)

Ajoute le PivotHierarchy à l’axe en cours. Si la hiérarchie apparaît ailleurs sur la ligne, colonne ou axe de filtre, celle-ci est supprimée de cet emplacement.

delete()

Supprime le tableau croisé dynamique.

getAllowMultipleFiltersPerField()

Spécifie si le tableau croisé dynamique autorise l’application de plusieurs filtres croisés dynamiques sur un champ de tableau croisé dynamique donné dans la table.

getColumnHierarchies()

Les hiérarchies de colonne de tableau croisé dynamique.

getColumnHierarchy(name)

Obtient une RowColumnPivotHierarchy par nom. Si rowColumnPivotHierarchy n’existe pas, cette méthode retourne undefined.

getDataHierarchies()

Les hiérarchies de données de tableau croisé dynamique.

getDataHierarchy(name)

Obtient une DataPivotHierarchy par nom. Si DataPivotHierarchy n’existe pas, cette méthode retourne undefined.

getEnableDataValueEditing()

Spécifie si le tableau croisé dynamique autorise la modification des valeurs du corps des données par l’utilisateur.

getFilterHierarchies()

Les hiérarchies de filtre de tableau croisé dynamique.

getFilterHierarchy(name)

Obtient un FilterPivotHierarchy par nom. Si l’objet FilterPivotHierarchy n’existe pas, cette méthode retourne undefined.

getHierarchies()

Les hiérarchies Pivot de tableau croisé dynamique.

getHierarchy(name)

Obtient une PivotHierarchy par nom. Si pivotHierarchy n’existe pas, cette méthode retourne undefined.

getId()

ID du tableau croisé dynamique.

getLayout()

Le PivotLayout décrivant la disposition et la structure visuelle de tableau croisé dynamique.

getName()

Nom du tableau croisé dynamique.

getRowHierarchies()

Les hiérarchies de lignes de tableau croisé dynamique.

getRowHierarchy(name)

Obtient une RowColumnPivotHierarchy par nom. Si rowColumnPivotHierarchy n’existe pas, cette méthode retourne undefined.

getUseCustomSortLists()

Spécifie si le tableau croisé dynamique utilise des listes personnalisées lors du tri.

getWorksheet()

Feuille de calcul contenant le tableau croisé dynamique.

refresh()

Actualise le tableau croisé dynamique.

removeColumnHierarchy(rowColumnPivotHierarchy)

Supprime le PivotHierarchy de l’axe en cours.

removeDataHierarchy(DataPivotHierarchy)

Supprime le PivotHierarchy de l’axe en cours.

removeFilterHierarchy(filterPivotHierarchy)

Supprime le PivotHierarchy de l’axe en cours.

removeRowHierarchy(rowColumnPivotHierarchy)

Supprime le PivotHierarchy de l’axe en cours.

setAllowMultipleFiltersPerField(allowMultipleFiltersPerField)

Spécifie si le tableau croisé dynamique autorise l’application de plusieurs filtres croisés dynamiques sur un champ de tableau croisé dynamique donné dans la table.

setEnableDataValueEditing(enableDataValueEditing)

Spécifie si le tableau croisé dynamique autorise la modification des valeurs du corps des données par l’utilisateur.

setName(name)

Nom du tableau croisé dynamique.

setUseCustomSortLists(useCustomSortLists)

Spécifie si le tableau croisé dynamique utilise des listes personnalisées lors du tri.

Détails de la méthode

addColumnHierarchy(pivotHierarchy)

Ajoute le PivotHierarchy à l’axe en cours. Si la hiérarchie apparaît ailleurs sur la ligne, colonne ou axe de filtre, celle-ci est supprimée de cet emplacement.

addColumnHierarchy(
            pivotHierarchy: PivotHierarchy
        ): RowColumnPivotHierarchy;

Paramètres

Retours

Exemples

/**
 * This script adds a row hierarchy to the PivotTable on the current worksheet.
 * This assumes the source data has columns named 
 * "Type", "Classification", and "Sales".
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the PivotTable on the current worksheet.
  let sheet = workbook.getActiveWorksheet();
  let pivotTable = sheet.getPivotTables()[0];

  // Add the field "Type" to the PivotTable as a row hierarchy.
  pivotTable.addRowHierarchy(pivotTable.getHierarchy("Type"));

  // Add the field "Classification" to the PivotTable as a column hierarchy.
  pivotTable.addColumnHierarchy(pivotTable.getHierarchy("Classification"));

  // Add the field "Sales" to the PivotTable as a data hierarchy.
  // By default, this displays the sums of the values in "Sales" based on the "Type".
  pivotTable.addDataHierarchy(pivotTable.getHierarchy("Sales"));
}

addDataHierarchy(pivotHierarchy)

Ajoute le PivotHierarchy à l’axe en cours.

addDataHierarchy(pivotHierarchy: PivotHierarchy): DataPivotHierarchy;

Paramètres

Retours

Exemples

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

addFilterHierarchy(pivotHierarchy)

Ajoute le PivotHierarchy à l’axe en cours. Si la hiérarchie apparaît ailleurs sur la ligne, colonne ou axe de filtre, celle-ci est supprimée de cet emplacement.

addFilterHierarchy(
            pivotHierarchy: PivotHierarchy
        ): FilterPivotHierarchy;

Paramètres

Retours

Exemples

/**
 * This script adds a manual filter to a PivotTable. 
 */
function main(workbook: ExcelScript.Workbook)
{
  // Get the first PivotTable in the workbook.
  const pivot = workbook.getPivotTables()[0];

  // Get the hierarchy to use as the filter.
  const location = pivot.getHierarchy("Location");

  // Use "Location" as the FilterHierarchy.
  pivot.addFilterHierarchy(location);

  // Select items for the filter.
  // Note that hierarchies and fields have a 1:1 relationship in Excel,
  // so `getFields()[0]` always gets the correct field.
  location.getFields()[0].applyFilter({
    manualFilter: {
      selectedItems: ["Seattle", "Chicago"]
    }
  });
}

addRowHierarchy(pivotHierarchy)

Ajoute le PivotHierarchy à l’axe en cours. Si la hiérarchie apparaît ailleurs sur la ligne, colonne ou axe de filtre, celle-ci est supprimée de cet emplacement.

addRowHierarchy(
            pivotHierarchy: PivotHierarchy
        ): RowColumnPivotHierarchy;

Paramètres

Retours

Exemples

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

delete()

Supprime le tableau croisé dynamique.

delete(): void;

Retours

void

getAllowMultipleFiltersPerField()

Spécifie si le tableau croisé dynamique autorise l’application de plusieurs filtres croisés dynamiques sur un champ de tableau croisé dynamique donné dans la table.

getAllowMultipleFiltersPerField(): boolean;

Retours

boolean

getColumnHierarchies()

Les hiérarchies de colonne de tableau croisé dynamique.

getColumnHierarchies(): RowColumnPivotHierarchy[];

Retours

getColumnHierarchy(name)

Obtient une RowColumnPivotHierarchy par nom. Si rowColumnPivotHierarchy n’existe pas, cette méthode retourne undefined.

getColumnHierarchy(name: string): RowColumnPivotHierarchy | undefined;

Paramètres

name

string

Nom de la RowColumnPivotHierarchy à récupérer.

Retours

getDataHierarchies()

Les hiérarchies de données de tableau croisé dynamique.

getDataHierarchies(): DataPivotHierarchy[];

Retours

getDataHierarchy(name)

Obtient une DataPivotHierarchy par nom. Si DataPivotHierarchy n’existe pas, cette méthode retourne undefined.

getDataHierarchy(name: string): DataPivotHierarchy | undefined;

Paramètres

name

string

Nom de la DataPivotHierarchy à récupérer.

Retours

getEnableDataValueEditing()

Spécifie si le tableau croisé dynamique autorise la modification des valeurs du corps des données par l’utilisateur.

getEnableDataValueEditing(): boolean;

Retours

boolean

getFilterHierarchies()

Les hiérarchies de filtre de tableau croisé dynamique.

getFilterHierarchies(): FilterPivotHierarchy[];

Retours

getFilterHierarchy(name)

Obtient un FilterPivotHierarchy par nom. Si l’objet FilterPivotHierarchy n’existe pas, cette méthode retourne undefined.

getFilterHierarchy(name: string): FilterPivotHierarchy | undefined;

Paramètres

name

string

Nom de l’objet FilterPivotHierarchy à récupérer.

Retours

getHierarchies()

Les hiérarchies Pivot de tableau croisé dynamique.

getHierarchies(): PivotHierarchy[];

Retours

getHierarchy(name)

Obtient une PivotHierarchy par nom. Si pivotHierarchy n’existe pas, cette méthode retourne undefined.

getHierarchy(name: string): PivotHierarchy | undefined;

Paramètres

name

string

Nom de la PivotHierarchy à récupérer.

Retours

getId()

ID du tableau croisé dynamique.

getId(): string;

Retours

string

getLayout()

Le PivotLayout décrivant la disposition et la structure visuelle de tableau croisé dynamique.

getLayout(): PivotLayout;

Retours

Exemples

/**
 * This script sets the layout of the "Farms Sales" PivotTable to the "tabular"
 * setting. This places the fields from the Rows area in separate columns.
 */ 
function main(workbook: ExcelScript.Workbook) {
  // Get the PivotTable named "Farm Sales".
  const pivot = workbook.getPivotTable("Farm Sales");

  // Get the PivotLayout object.
  const layout = pivot.getLayout();

  // Set the layout type to "tabular".
  layout.setLayoutType(ExcelScript.PivotLayoutType.tabular);
}

getName()

Nom du tableau croisé dynamique.

getName(): string;

Retours

string

getRowHierarchies()

Les hiérarchies de lignes de tableau croisé dynamique.

getRowHierarchies(): RowColumnPivotHierarchy[];

Retours

getRowHierarchy(name)

Obtient une RowColumnPivotHierarchy par nom. Si rowColumnPivotHierarchy n’existe pas, cette méthode retourne undefined.

getRowHierarchy(name: string): RowColumnPivotHierarchy | undefined;

Paramètres

name

string

Nom de la RowColumnPivotHierarchy à récupérer.

Retours

Exemples

/**
 * 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 = pivotTable.getDataHierarchy("Sum of Crates Sold Wholesale");

  // Get the row to sort.
  const rowToSort = 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);
}

getUseCustomSortLists()

Spécifie si le tableau croisé dynamique utilise des listes personnalisées lors du tri.

getUseCustomSortLists(): boolean;

Retours

boolean

getWorksheet()

Feuille de calcul contenant le tableau croisé dynamique.

getWorksheet(): Worksheet;

Retours

refresh()

Actualise le tableau croisé dynamique.

refresh(): void;

Retours

void

removeColumnHierarchy(rowColumnPivotHierarchy)

Supprime le PivotHierarchy de l’axe en cours.

removeColumnHierarchy(
            rowColumnPivotHierarchy: RowColumnPivotHierarchy
        ): void;

Paramètres

rowColumnPivotHierarchy
ExcelScript.RowColumnPivotHierarchy

Retours

void

removeDataHierarchy(DataPivotHierarchy)

Supprime le PivotHierarchy de l’axe en cours.

removeDataHierarchy(DataPivotHierarchy: DataPivotHierarchy): void;

Paramètres

DataPivotHierarchy
ExcelScript.DataPivotHierarchy

Retours

void

removeFilterHierarchy(filterPivotHierarchy)

Supprime le PivotHierarchy de l’axe en cours.

removeFilterHierarchy(filterPivotHierarchy: FilterPivotHierarchy): void;

Paramètres

filterPivotHierarchy
ExcelScript.FilterPivotHierarchy

Retours

void

removeRowHierarchy(rowColumnPivotHierarchy)

Supprime le PivotHierarchy de l’axe en cours.

removeRowHierarchy(
            rowColumnPivotHierarchy: RowColumnPivotHierarchy
        ): void;

Paramètres

rowColumnPivotHierarchy
ExcelScript.RowColumnPivotHierarchy

Retours

void

setAllowMultipleFiltersPerField(allowMultipleFiltersPerField)

Spécifie si le tableau croisé dynamique autorise l’application de plusieurs filtres croisés dynamiques sur un champ de tableau croisé dynamique donné dans la table.

setAllowMultipleFiltersPerField(
            allowMultipleFiltersPerField: boolean
        ): void;

Paramètres

allowMultipleFiltersPerField

boolean

Retours

void

setEnableDataValueEditing(enableDataValueEditing)

Spécifie si le tableau croisé dynamique autorise la modification des valeurs du corps des données par l’utilisateur.

setEnableDataValueEditing(enableDataValueEditing: boolean): void;

Paramètres

enableDataValueEditing

boolean

Retours

void

setName(name)

Nom du tableau croisé dynamique.

setName(name: string): void;

Paramètres

name

string

Retours

void

setUseCustomSortLists(useCustomSortLists)

Spécifie si le tableau croisé dynamique utilise des listes personnalisées lors du tri.

setUseCustomSortLists(useCustomSortLists: boolean): void;

Paramètres

useCustomSortLists

boolean

Retours

void