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
add |
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. |
add |
Ajoute le PivotHierarchy à l’axe en cours. |
add |
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. |
add |
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. |
get |
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. |
get |
Les hiérarchies de colonne de tableau croisé dynamique. |
get |
Obtient une RowColumnPivotHierarchy par nom. Si rowColumnPivotHierarchy n’existe pas, cette méthode retourne |
get |
Les hiérarchies de données de tableau croisé dynamique. |
get |
Obtient une DataPivotHierarchy par nom. Si DataPivotHierarchy n’existe pas, cette méthode retourne |
get |
Spécifie si le tableau croisé dynamique autorise la modification des valeurs du corps des données par l’utilisateur. |
get |
Les hiérarchies de filtre de tableau croisé dynamique. |
get |
Obtient un FilterPivotHierarchy par nom. Si l’objet FilterPivotHierarchy n’existe pas, cette méthode retourne |
get |
Les hiérarchies Pivot de tableau croisé dynamique. |
get |
Obtient une PivotHierarchy par nom. Si pivotHierarchy n’existe pas, cette méthode retourne |
get |
ID du tableau croisé dynamique. |
get |
Le PivotLayout décrivant la disposition et la structure visuelle de tableau croisé dynamique. |
get |
Nom du tableau croisé dynamique. |
get |
Les hiérarchies de lignes de tableau croisé dynamique. |
get |
Obtient une RowColumnPivotHierarchy par nom. Si rowColumnPivotHierarchy n’existe pas, cette méthode retourne |
get |
Spécifie si le tableau croisé dynamique utilise des listes personnalisées lors du tri. |
get |
Feuille de calcul contenant le tableau croisé dynamique. |
refresh() | Actualise le tableau croisé dynamique. |
remove |
Supprime le PivotHierarchy de l’axe en cours. |
remove |
Supprime le PivotHierarchy de l’axe en cours. |
remove |
Supprime le PivotHierarchy de l’axe en cours. |
remove |
Supprime le PivotHierarchy de l’axe en cours. |
set |
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. |
set |
Spécifie si le tableau croisé dynamique autorise la modification des valeurs du corps des données par l’utilisateur. |
set |
Nom du tableau croisé dynamique. |
set |
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
- pivotHierarchy
- ExcelScript.PivotHierarchy
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
- pivotHierarchy
- ExcelScript.PivotHierarchy
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
- pivotHierarchy
- ExcelScript.PivotHierarchy
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
- pivotHierarchy
- ExcelScript.PivotHierarchy
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
ExcelScript.RowColumnPivotHierarchy | undefined
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
ExcelScript.DataPivotHierarchy | undefined
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
ExcelScript.FilterPivotHierarchy | undefined
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
ExcelScript.PivotHierarchy | undefined
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
ExcelScript.RowColumnPivotHierarchy | undefined
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
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour