Excel.ShowAsCalculation enum
Fonction de calcul ShowAs pour dataPivotField.
Remarques
[ Ensemble d’API : ExcelApi 1.8 ]
Exemples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-calculations.yaml
await Excel.run(async (context) => {
const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales");
const farmDataHierarchy: Excel.DataPivotHierarchy = pivotTable.dataHierarchies.getItem("Sum of Crates Sold at Farm");
const wholesaleDataHierarchy: Excel.DataPivotHierarchy = pivotTable.dataHierarchies.getItem("Sum of Crates Sold Wholesale");
farmDataHierarchy.load("showAs");
wholesaleDataHierarchy.load("showAs");
await context.sync();
// Show the crates of each fruit type sold at the farm as a percentage of the column's total.
let farmShowAs = farmDataHierarchy.showAs;
farmShowAs.calculation = Excel.ShowAsCalculation.percentOfColumnTotal;
farmShowAs.baseField = pivotTable.rowHierarchies.getItem("Type").fields.getItem("Type");
farmDataHierarchy.showAs = farmShowAs;
let wholesaleShowAs = wholesaleDataHierarchy.showAs;
wholesaleShowAs.calculation = Excel.ShowAsCalculation.percentOfColumnTotal;
wholesaleShowAs.baseField = pivotTable.rowHierarchies.getItem("Type").fields.getItem("Type");
wholesaleDataHierarchy.showAs = wholesaleShowAs;
await context.sync();
});
Champs
| differenceFrom = "DifferenceFrom" | Différence par rapport au champ de base et à l’élément de base spécifiés. |
| index = "Index" | Calcule les valeurs comme suit : ((valeur dans la cellule) x (Total général des totaux généraux)) / ((Total de la ligne générale) x (Total de la colonne générale)) |
| none = "None" | Aucun calcul n’est appliqué. |
| percentDifferenceFrom = "PercentDifferenceFrom" | Différence par rapport au champ de base et à l’élément de base spécifiés. |
| percentOf = "PercentOf" | Pourcentage du champ de base et de l’élément de base spécifiés. |
| percentOfColumnTotal = "PercentOfColumnTotal" | Pourcentage du total des colonnes. |
| percentOfGrandTotal = "PercentOfGrandTotal" | Pourcentage du total général. |
| percentOfParentColumnTotal = "PercentOfParentColumnTotal" | Pourcentage du total des colonnes pour le champ de base spécifié. |
| percentOfParentRowTotal = "PercentOfParentRowTotal" | Pourcentage du total de lignes pour le champ de base spécifié. |
| percentOfParentTotal = "PercentOfParentTotal" | Pourcentage du total général pour le champ de base spécifié. |
| percentOfRowTotal = "PercentOfRowTotal" | Pourcentage du total de la ligne. |
| percentRunningTotal = "PercentRunningTotal" | Pourcentage total en cours d’exécution du champ de base spécifié. |
| rankAscending = "RankAscending" | Classement croissant du champ De base spécifié. |
| rankDecending = "RankDecending" | Rang décroissant du champ De base spécifié. |
| runningTotal = "RunningTotal" | Total en cours d’exécution du champ de base spécifié. |
| unknown = "Unknown" | Le calcul est inconnu ou non pris en charge. |