Excel.ShowAsRule interface

注釈

[ API セット: ExcelApi 1.8 ]

プロパティ

baseField

計算の ShowAs 基となる PivotField (該当する場合は型に従います)。それ以外の ShowAsCalculation 場合 nullは 。

baseItem

計算の ShowAs 基準となる項目 (型に応じて該当する ShowAsCalculation 場合は )。それ以外の場合 nullは 。

calculation

ShowAs PivotField に使用する計算。 詳細は「Excel.ShowAsCalculation」をご覧ください。

プロパティの詳細

baseField

計算の ShowAs 基となる PivotField (該当する場合は型に従います)。それ以外の ShowAsCalculation 場合 nullは 。

baseField?: Excel.PivotField;

プロパティ値

注釈

[ API セット: ExcelApi 1.8 ]

baseItem

計算の ShowAs 基準となる項目 (型に応じて該当する ShowAsCalculation 場合は )。それ以外の場合 nullは 。

baseItem?: Excel.PivotItem;

プロパティ値

注釈

[ API セット: ExcelApi 1.8 ]

// 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 difference between crate sales of the "A Farms" and the other farms.
    // This difference is both aggregated and shown for individual fruit types (where applicable).
    let farmShowAs = farmDataHierarchy.showAs;
    farmShowAs.calculation = Excel.ShowAsCalculation.differenceFrom;
    farmShowAs.baseField = pivotTable.rowHierarchies.getItem("Farm").fields.getItem("Farm");
    farmShowAs.baseItem = pivotTable.rowHierarchies.getItem("Farm").fields.getItem("Farm").items.getItem("A Farms");
    farmDataHierarchy.showAs = farmShowAs;

    let wholesaleShowAs = wholesaleDataHierarchy.showAs;
    wholesaleShowAs.calculation = Excel.ShowAsCalculation.differenceFrom;
    wholesaleShowAs.baseField = pivotTable.rowHierarchies.getItem("Farm").fields.getItem("Farm");
    wholesaleShowAs.baseItem = pivotTable.rowHierarchies.getItem("Farm").fields.getItem("Farm").items.getItem("A Farms");
    wholesaleDataHierarchy.showAs = wholesaleShowAs;
    await context.sync();
});

calculation

ShowAs PivotField に使用する計算。 詳細は「Excel.ShowAsCalculation」をご覧ください。

calculation: Excel.ShowAsCalculation | "Unknown" | "None" | "PercentOfGrandTotal" | "PercentOfRowTotal" | "PercentOfColumnTotal" | "PercentOfParentRowTotal" | "PercentOfParentColumnTotal" | "PercentOfParentTotal" | "PercentOf" | "RunningTotal" | "PercentRunningTotal" | "DifferenceFrom" | "PercentDifferenceFrom" | "RankAscending" | "RankDecending" | "Index";

プロパティ値

Excel.ShowAsCalculation | "Unknown" | "None" | "PercentOfGrandTotal" | "PercentOfRowTotal" | "PercentOfColumnTotal" | "PercentOfParentRowTotal" | "PercentOfParentColumnTotal" | "PercentOfParentTotal" | "PercentOf" | "RunningTotal" | "PercentRunningTotal" | "DifferenceFrom" | "PercentDifferenceFrom" | "RankAscending" | "RankDecending" | "Index"

注釈

[ API セット: ExcelApi 1.8 ]