Excel.ShowAsCalculation enum

Fonction de calcul ShowAs pour DataPivotField.

Remarques

Jeu d’API : ExcelApi 1.8

Utilisateur

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 entre le champ de base spécifié et l’élément de base.

index = "Index"

Calcule les valeurs comme suit : ((valeur dans la cellule) x (total général des totaux généraux)) / ((total ligne générale) x (total colonne générale))

none = "None"

Aucun calcul n’est appliqué.

percentDifferenceFrom = "PercentDifferenceFrom"

Différence entre le champ de base spécifié et l’élément de base.

percentOf = "PercentOf"

Pourcentage du champ de base spécifié et de l’élément de base.

percentOfColumnTotal = "PercentOfColumnTotal"

Pourcentage du total de la colonne.

percentOfGrandTotal = "PercentOfGrandTotal"

Pourcentage du total général.

percentOfParentColumnTotal = "PercentOfParentColumnTotal"

Pourcentage du total de la colonne pour le champ de base spécifié.

percentOfParentRowTotal = "PercentOfParentRowTotal"

Pourcentage du total de la ligne 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 du résultat cumulé du champ de base spécifié.

rankAscending = "RankAscending"

Rang croissant du champ de base spécifié.

rankDecending = "RankDecending"

Rang décroissant du champ de base spécifié.

runningTotal = "RunningTotal"

Total cumulé du champ de base spécifié.

unknown = "Unknown"

Le calcul est inconnu ou non pris en charge.