Excel.ShowAsRule interface

属性

baseField

基于 ShowAs 计算的基础 PivotField,如适用,基于 ShowAsCalculation 类型,否则为 null。The base PivotField to base the ShowAs calculation, if applicable based on the ShowAsCalculation type, else null.

[API 集: ExcelApi 1.8][ API set: ExcelApi 1.8 ]

baseItem

基于 ShowAs 计算的基础 Item,如适用,基于 ShowAsCalculation 类型,否则为 null。The base Item to base the ShowAs calculation on, if applicable based on the ShowAsCalculation type, else null.

[API 集: ExcelApi 1.8][ API set: ExcelApi 1.8 ]

calculation

数据 PivotField 使用的 ShowAs 计算。The ShowAs Calculation to use for the Data PivotField. 有关详细信息, 请参阅 ShowAsCalculation。See Excel.ShowAsCalculation for Details.

[API 集: ExcelApi 1.8][ API set: ExcelApi 1.8 ]

属性详细信息

baseField

基于 ShowAs 计算的基础 PivotField,如适用,基于 ShowAsCalculation 类型,否则为 null。The base PivotField to base the ShowAs calculation, if applicable based on the ShowAsCalculation type, else null.

[API 集: ExcelApi 1.8][ API set: ExcelApi 1.8 ]

baseField?: Excel.PivotField;

属性值

baseItem

基于 ShowAs 计算的基础 Item,如适用,基于 ShowAsCalculation 类型,否则为 null。The base Item to base the ShowAs calculation on, if applicable based on the ShowAsCalculation type, else null.

[API 集: ExcelApi 1.8][ API set: ExcelApi 1.8 ]

baseItem?: Excel.PivotItem;

属性值

示例Examples

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

数据 PivotField 使用的 ShowAs 计算。The ShowAs Calculation to use for the Data PivotField. 有关详细信息, 请参阅 ShowAsCalculation。See Excel.ShowAsCalculation for Details.

[API 集: ExcelApi 1.8][ API set: ExcelApi 1.8 ]

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"