[]
        
首页
开发者学堂
文档
论坛
市场
生态机会
活动
立即试用
(Showing Draft Content)

IPivotTable

Interface IPivotTable


public interface IPivotTable
表示工作表上的数据透视表报表。

IPivotTable 是 IPivotTables 集合的成员,用于汇总和分析工作表上来自 IPivotCache 的数据。


 worksheet.getRange("A1:B4").setValue(new Object[][] {
     {"Name", "Value"},
     {"A", 100},
     {"B", 200},
     {"A", 100}
 });
 IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
 IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "PivotTable1");
 pivotTable.setName("SalesPivot");
 
  • Method Details

    • getColumnGrand

      boolean getColumnGrand()
      获取数据透视表报表是否显示列总计。

      此属性指示是否为数据透视表报表的列区域显示总计。默认值为 true。

      
       worksheet.getRange("A1:B5").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 120},
           {"Fruit", 80},
           {"Vegetables", 95},
           {"Vegetables", 60}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.ColumnField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       boolean showColumnGrand = pivotTable.getColumnGrand();
       
      Returns:
      如果显示列总计,则为 true;否则为 false。
    • setColumnGrand

      void setColumnGrand(boolean value)
      设置数据透视表报告是否显示列的总计。

      此属性指示是否在数据透视表报告的列区域显示总计。默认值为 true。

      
       worksheet.getRange("A1:B5").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 120},
           {"Fruit", 80},
           {"Vegetables", 95},
           {"Vegetables", 60}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.ColumnField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       pivotTable.setColumnGrand(true);
       
      Parameters:
      value - 数据透视表报告是否显示列的总计。
    • getColumnFields

      IPivotFields getColumnFields()
      获取当前在数据透视表报告中显示为列字段的字段集合。

      返回的集合为只读,并包含方向设置为列字段的字段。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Category", "Region", "Amount"},
           {"Beverages", "East", 120},
           {"Beverages", "West", 80},
           {"Snacks", "East", 95},
           {"Snacks", "West", 110}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.ColumnField);
       IPivotFields columnFields = pivotTable.getColumnFields();
       
      Returns:
      当前在数据透视表报告中显示为列字段的字段集合。 返回的集合为只读,并包含方向设置为列字段的字段。
    • getColumnRange

      IRange getColumnRange()
      获取包含数据透视表报告中列区域的区域。

      返回的区域涵盖当前数据透视表布局中用于列字段的单元格。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Category", "Region", "Amount"},
           {"Beverages", "East", 120},
           {"Beverages", "West", 80},
           {"Snacks", "East", 95},
           {"Snacks", "West", 110}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.ColumnField);
       pivotTable.addDataField(pivotTable.getPivotFields().get("Amount"), "Sum of Amount", ConsolidationFunction.Sum);
       IRange range = pivotTable.getColumnRange();
       String address = range.getAddress();
       
      Returns:
      包含数据透视表报告中列区域的区域。 返回的区域涵盖当前数据透视表布局中用于列字段的单元格。
    • getCompactRowIndent

      int getCompactRowIndent()
      获取启用紧凑行布局时数据透视项的缩进增量。

      当数据透视表报告使用紧凑行布局时,此值控制每个嵌套数据透视项的缩进量。

      
       worksheet.getRange("A1:B5").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 120},
           {"Fruit", 80},
           {"Vegetables", 95},
           {"Vegetables", 60}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.setCompactRowIndent(2);
       int indent = pivotTable.getCompactRowIndent();
       
      Returns:
      启用紧凑行布局时数据透视项的缩进增量。
    • setCompactRowIndent

      void setCompactRowIndent(int value)
      设置启用紧凑行布局时数据透视项的缩进增量。

      当数据透视表报告使用紧凑行布局时,此值控制每个嵌套数据透视项的缩进量。

      
       worksheet.getRange("A1:B5").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 120},
           {"Fruit", 80},
           {"Vegetables", 95},
           {"Vegetables", 60}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.setCompactRowIndent(2);
       
      Parameters:
      value - 启用紧凑行布局时数据透视项的缩进增量。
    • getDataBodyRange

      IRange getDataBodyRange()
      获取包含 PivotTable 报告数据区域的区域。

      返回的区域表示标题区域和插入行之间的单元格。

      
       worksheet.getRange("A1:B5").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 120},
           {"Fruit", 80},
           {"Vegetables", 95},
           {"Vegetables", 60}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.addDataField(pivotTable.getPivotFields().get("Amount"), "Sum of Amount", ConsolidationFunction.Sum);
       IRange range = pivotTable.getDataBodyRange();
       
      Returns:
      包含 PivotTable 报告数据区域的区域。 返回的区域表示标题区域和插入行之间的单元格。
    • getDataFields

      IPivotFields getDataFields()
      获取当前在 PivotTable 报告中显示为数据字段的字段集合。

      返回的集合为只读,包含放置在 PivotTable“值”区域中的字段。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Fruit", 80},
           {"Vegetables", 60}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.addDataField(pivotTable.getPivotFields().get("Amount"), "Sum of Amount", ConsolidationFunction.Sum);
       IPivotFields dataFields = pivotTable.getDataFields();
       String caption = dataFields.get(0).getName();
       
      Returns:
      当前在 PivotTable 报告中显示为数据字段的字段集合。 返回的集合为只读,包含放置在 PivotTable“值”区域中的字段。
    • getDeferLayoutUpdate

      boolean getDeferLayoutUpdate()
      获取 PivotTable 的布局更新是否推迟。

      当此属性为 true 时,可以累积布局更改,然后通过调用 update() 应用这些更改。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Category", "Product", "Amount"},
           {"Beverages", "Tea", 100},
           {"Beverages", "Coffee", 200},
           {"Snacks", "Biscuits", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "PivotTable1");
       pivotTable.setDeferLayoutUpdate(true);
       boolean deferred = pivotTable.getDeferLayoutUpdate();
       
      Returns:
      如果 Defer Layout Update 为真,则为 true;否则为 false。
    • setDeferLayoutUpdate

      void setDeferLayoutUpdate(boolean value)
      设置是否推迟 PivotTable 的布局更新。

      当此属性为 true 时,可以累积布局更改,然后通过调用 update() 应用这些更改。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Category", "Product", "Amount"},
           {"Beverages", "Tea", 100},
           {"Beverages", "Coffee", 200},
           {"Snacks", "Biscuits", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "PivotTable1");
       pivotTable.setDeferLayoutUpdate(true);
       
      Parameters:
      value - 是否推迟 PivotTable 的布局更新。
    • getDisplayContextTooltips

      boolean getDisplayContextTooltips()
      获取是否为数据透视表单元格显示工具提示。

      此属性指示是否为数据透视表报表中的单元格显示上下文工具提示。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Name", "Amount"},
           {"A", 100},
           {"B", 200},
           {"A", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       boolean displayContextTooltips = pivotTable.getDisplayContextTooltips();
       
      Returns:
      如果为数据透视表单元格显示上下文工具提示,则为 true;否则为 false。
    • setDisplayContextTooltips

      void setDisplayContextTooltips(boolean value)
      设置是否为 PivotTable 单元格显示工具提示。

      此属性指示是否为 PivotTable 报表中的单元格显示上下文工具提示。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Name", "Amount"},
           {"A", 100},
           {"B", 200},
           {"A", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setDisplayContextTooltips(true);
       
      Parameters:
      value - 是否为 PivotTable 单元格显示工具提示。
    • getDisplayErrorString

      boolean getDisplayErrorString()
      获取数据透视表报告是否在包含错误的单元格中显示自定义错误字符串。

      当此属性为 true 时,数据透视表会对包含错误的单元格使用 getErrorString() 指定的字符串。默认值为 false。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"A", 10},
           {"B", 20},
           {"A", 15}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "PivotTable1");
       pivotTable.setDisplayErrorString(true);
       boolean displayErrorString = pivotTable.getDisplayErrorString();
       
      Returns:
      如果数据透视表报告在包含错误的单元格中显示自定义错误字符串,则为 true;否则为 false。
    • setDisplayErrorString

      void setDisplayErrorString(boolean value)
      设置数据透视表报告是否在包含错误的单元格中显示自定义错误字符串。

      当此属性为 true 时,数据透视表会对包含错误的单元格使用 getErrorString() 指定的字符串。默认值为 false。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"A", 10},
           {"B", 20},
           {"A", 15}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "PivotTable1");
       pivotTable.setDisplayErrorString(true);
       
      Parameters:
      value - 数据透视表报告是否在包含错误的单元格中显示自定义错误字符串。
    • getDisplayMemberPropertyTooltips

      boolean getDisplayMemberPropertyTooltips()
      获取是否在数据透视表工具提示中显示成员属性。

      当此属性为 true 时,工具提示可包含数据透视表项的成员属性信息。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"A", 100},
           {"B", 200},
           {"A", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setDisplayMemberPropertyTooltips(true);
       boolean displayMemberPropertyTooltips = pivotTable.getDisplayMemberPropertyTooltips();
       
      Returns:
      如果在数据透视表工具提示中显示成员属性。 当此属性为 时,工具提示可包含数据透视表项的成员属性信息,则为 true;否则为 false。
    • setDisplayMemberPropertyTooltips

      void setDisplayMemberPropertyTooltips(boolean value)
      设置是否在数据透视表工具提示中显示成员属性。

      当此属性为 true 时,工具提示可包含数据透视表项的成员属性信息。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"A", 100},
           {"B", 200},
           {"A", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setDisplayMemberPropertyTooltips(true);
       
      Parameters:
      value - 是否在数据透视表工具提示中显示成员属性。
    • getDisplayNullString

      boolean getDisplayNullString()
      获取数据透视表报表是否在包含 null 值的单元格中显示自定义字符串。

      当此属性为 true 时,数据透视表对包含 null 值的单元格使用由 getNullString() 指定的字符串。默认值为 true。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Name", "Value"},
           {"A", 100},
           {"B", null},
           {"A", 200}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "PivotTable1");
       boolean displayNullString = pivotTable.getDisplayNullString();
       
      Returns:
      如果在包含 null 值的单元格中显示自定义字符串,则为 true;否则为 false。
    • setDisplayNullString

      void setDisplayNullString(boolean value)
      设置数据透视表报表是否在包含空值的单元格中显示自定义字符串。

      当此属性为 true 时,数据透视表会对包含空值的单元格使用由 getNullString() 指定的字符串。默认值为 true。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Name", "Value"},
           {"A", 100},
           {"B", null},
           {"A", 200}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "PivotTable1");
       pivotTable.setDisplayNullString(true);
       
      Parameters:
      value - 数据透视表报表是否在包含空值的单元格中显示自定义字符串。
    • getErrorString

      String getErrorString()
      获取启用自定义错误字符串显示时,在包含错误的单元格中显示的字符串。

      默认值为空字符串("")。使用 setErrorString(String) 可以指定数据透视表为错误单元格显示的自定义错误文本。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"A", 10},
           {"B", 20},
           {"A", 15}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "PivotTable1");
       pivotTable.setDisplayErrorString(true);
       pivotTable.setErrorString("Invalid");
       String errorString = pivotTable.getErrorString();
       
      Returns:
      启用自定义错误字符串显示时,在包含错误的单元格中显示的字符串。
    • setErrorString

      void setErrorString(String value)
      设置启用自定义错误字符串显示时,在包含错误的单元格中显示的字符串。

      默认值为空字符串("")。使用 setErrorString(String) 指定数据透视表为错误单元格显示的自定义错误文本。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"A", 10},
           {"B", 20},
           {"A", 15}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "PivotTable1");
       pivotTable.setDisplayErrorString(true);
       pivotTable.setErrorString("Invalid");
       
      Parameters:
      value - 启用自定义错误字符串显示时,在包含错误的单元格中显示的字符串。
    • getGrandTotalName

      String getGrandTotalName()
      获取数据透视表报告的总计行标题或总计列标题中显示的文本标签。

      默认标签为 "Grand Total"。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Region", "Sales"},
           {"East", 100},
           {"West", 200},
           {"East", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       String grandTotalName = pivotTable.getGrandTotalName();
       
      Returns:
      数据透视表报告的总计行标题或总计列标题中显示的文本标签。
    • setGrandTotalName

      void setGrandTotalName(String value)
      设置数据透视表报告的总计行标题或总计列标题中显示的文本标签。

      默认标签为 "Grand Total"。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Region", "Sales"},
           {"East", 100},
           {"West", 200},
           {"East", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setGrandTotalName("Sample");
       
      Parameters:
      value - 数据透视表报告的总计行标题或总计列标题中显示的文本标签。
    • getLayoutRowDefault

      LayoutRowType getLayoutRowDefault()
      获取首次将 PivotFields 添加到 PivotTable 时应用的默认行布局类型。

      此设置确定新添加 PivotFields 使用的初始行布局,例如紧凑、大纲或表格布局。

      
       worksheet.getRange("A1:C4").setValue(new Object[][] {
           {"Region", "Product", "Amount"},
           {"East", "Apple", 120},
           {"West", "Apple", 80},
           {"East", "Orange", 90}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.setLayoutRowDefault(LayoutRowType.TabularRow);
       LayoutRowType layoutType = pivotTable.getLayoutRowDefault();
       
      Returns:
      首次将 PivotFields 添加到 PivotTable 时应用的默认行布局类型。 此设置确定新添加 PivotFields 使用的初始行布局,例如紧凑、大纲或表格布局。
    • setLayoutRowDefault

      void setLayoutRowDefault(LayoutRowType value)
      设置 IPivotField 对象首次添加到 IPivotTable 时的默认布局行类型。

      此设置适用于新添加的 PivotFields。若要同时更改现有 PivotFields 的布局,请使用 setRowAxisLayout(LayoutRowType)。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Region", "Product", "Amount"},
           {"East", "Apple", 100},
           {"East", "Pear", 80},
           {"West", "Apple", 120},
           {"West", "Pear", 90}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.setLayoutRowDefault(LayoutRowType.TabularRow);
       pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.RowField);
       
      Parameters:
      value - PivotField 首次添加到 PivotTable 时要应用的默认布局行类型。
    • getMergeLabels

      boolean getMergeLabels()
      获取指定数据透视表报表是否对外部行项、列项、小计和总计标签使用合并单元格。

      使用此属性可以确定 数据透视表布局中的重复标签是否通过合并相邻单元格显示。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Region", "Product", "Amount"},
           {"East", "Apple", 100},
           {"East", "Pear", 200},
           {"West", "Apple", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Product").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       pivotTable.setMergeLabels(true);
       boolean mergeLabels = pivotTable.getMergeLabels();
       
      Returns:
      如果对外部行项、列项、小计和总计标签使用合并单元格,则为 true;否则为 false。
    • setMergeLabels

      void setMergeLabels(boolean value)
      设置指定的数据透视表报表是否对其外部行项目、列项目、小计和总计标签使用合并单元格。

      使用此属性可设置数据透视表布局中的重复标签是否通过合并相邻单元格来显示。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Region", "Product", "Amount"},
           {"East", "Apple", 100},
           {"East", "Pear", 200},
           {"West", "Apple", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Product").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       pivotTable.setMergeLabels(true);
       
      Parameters:
      value - 指定的数据透视表报表是否对其外部行项目、列项目、小计和总计标签使用合并单元格。
    • getName

      String getName()
      获取数据透视表的名称。

      该名称用于在工作表中标识数据透视表,并可用于以编程方式引用数据透视表。

      
       worksheet.getRange("A1:C4").setValue(new Object[][] {
           {"Region", "Product", "Amount"},
           {"East", "Apple", 120},
           {"West", "Apple", 80},
           {"East", "Orange", 90}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       String name = pivotTable.getName();
       
      Returns:
      数据透视表名称。
    • setName

      void setName(String value)
      设置数据透视表的名称。

      该名称用于标识工作表上的数据透视表,并可用于以编程方式引用该数据透视表。

      
       worksheet.getRange("A1:C4").setValue(new Object[][] {
           {"Region", "Product", "Amount"},
           {"East", "Apple", 120},
           {"West", "Apple", 80},
           {"East", "Orange", 90}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.setName("Sample");
       
      Parameters:
      value - 数据透视表名称。
    • getNullString

      String getNullString()
      获取启用自定义空值字符串显示时,在包含 null 值的数据透视表单元格中显示的字符串。

      默认值为空字符串("")。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Name", "Value"},
           {"A", 100},
           {"B", null},
           {"A", 200}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setDisplayNullString(true);
       pivotTable.setNullString("(blank)");
       String nullString = pivotTable.getNullString();
       
      Returns:
      启用自定义空值字符串显示时,在包含 null 值的数据透视表单元格中显示的字符串。
    • setNullString

      void setNullString(String value)
      设置启用自定义空值字符串显示时,在包含 null 值的数据透视表单元格中显示的字符串。

      默认值为空字符串("")。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Name", "Value"},
           {"A", 100},
           {"B", null},
           {"A", 200}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setDisplayNullString(true);
       pivotTable.setNullString("(blank)");
       
      Parameters:
      value - 启用自定义空值字符串显示时,在包含 null 值的数据透视表单元格中显示的字符串。
    • getPageFieldOrder

      Order getPageFieldOrder()
      获取页字段添加到数据透视表报告布局中的顺序。

      返回值是 Order 常量之一:Order.DownThenOver 或 Order.OverThenDown。默认值为 Order.DownThenOver。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Region", "Product", "Amount"},
           {"East", "Apple", 100},
           {"East", "Pear", 80},
           {"West", "Apple", 90},
           {"West", "Pear", 70}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.PageField);
       pivotTable.setPageFieldOrder(Order.OverThenDown);
       Order order = pivotTable.getPageFieldOrder();
       
      Returns:
      页字段添加到数据透视表报告布局中的顺序。
    • setPageFieldOrder

      void setPageFieldOrder(Order value)
      设置页字段添加到数据透视表报告布局中的顺序。

      使用 Order.DownThenOver 可以在移至下一列之前沿每列向下放置页字段,或使用 Order.OverThenDown 可以在移至下一行之前沿每行横向放置页字段。默认值为 Order.DownThenOver。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Region", "Product", "Amount"},
           {"East", "Apple", 100},
           {"East", "Pear", 80},
           {"West", "Apple", 90},
           {"West", "Pear", 70}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.PageField);
       pivotTable.setPageFieldOrder(Order.OverThenDown);
       
      Parameters:
      value - 页字段布局顺序。使用 Order.DownThenOver 或 Order.OverThenDown;如果指定 null,则将其视为 Order.DownThenOver。
    • getPageFields

      IPivotFields getPageFields()
      获取当前在 PivotTable 中显示为页字段的字段集合。

      返回的集合为只读,包含方向设置为 PivotTable 报告页面区域的字段。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Region", "Product", "Amount"},
           {"East", "Apple", 100},
           {"East", "Pear", 80},
           {"West", "Apple", 90},
           {"West", "Pear", 70}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.PageField);
       IPivotFields pageFields = pivotTable.getPageFields();
       
      Returns:
      当前在 PivotTable 中显示为页字段的字段集合。 返回的集合为只读,包含方向设置为 PivotTable 报告页面区域的字段。
    • getPageFieldWrapCount

      int getPageFieldWrapCount()
      获取数据透视表报告中每列或每行显示的页字段数量。

      当数据透视表包含多个页字段时,此值确定页字段在报告筛选区域中的换行方式。使用 setPageFieldWrapCount(int) 可以更改布局。

      
       worksheet.getRange("A1:D5").setValue(new Object[][] {
           {"Region", "Product", "Quarter", "Amount"},
           {"East", "Apple", "Q1", 120},
           {"East", "Pear", "Q2", 95},
           {"West", "Apple", "Q1", 80},
           {"West", "Pear", "Q2", 110}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:D5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("F1"), "SalesPivot");
       pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.PageField);
       pivotTable.getPivotFields().get("Quarter").setOrientation(PivotFieldOrientation.PageField);
       pivotTable.setPageFieldWrapCount(1);
       int wrapCount = pivotTable.getPageFieldWrapCount();
       
      Returns:
      数据透视表报告中每列或每行显示的页字段数量。
    • setPageFieldWrapCount

      void setPageFieldWrapCount(int value)
      设置数据透视表报告中每列或每行显示的页字段数量。

      当数据透视表包含多个页字段时,此值决定这些页字段在报表筛选区域中的换行方式。使用 setPageFieldWrapCount(int) 更改布局。

      
       worksheet.getRange("A1:D5").setValue(new Object[][] {
           {"Region", "Product", "Quarter", "Amount"},
           {"East", "Apple", "Q1", 120},
           {"East", "Pear", "Q2", 95},
           {"West", "Apple", "Q1", 80},
           {"West", "Pear", "Q2", 110}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:D5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("F1"), "SalesPivot");
       pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.PageField);
       pivotTable.getPivotFields().get("Quarter").setOrientation(PivotFieldOrientation.PageField);
       pivotTable.setPageFieldWrapCount(1);
       
      Parameters:
      value - 数据透视表报告中每列或每行显示的页字段数量。
    • getPageRange

      IRange getPageRange()
      获取包含 PivotTable 报告中页面区域的区域。

      页面区域是报表筛选区域,用于显示方向设置为页字段的字段。如果 PivotTable 当前没有页面区域,此方法返回 null。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Region", "Product", "Amount"},
           {"East", "Apple", 100},
           {"East", "Pear", 80},
           {"West", "Apple", 90},
           {"West", "Pear", 70}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.PageField);
       IRange pageRange = pivotTable.getPageRange();
       
      Returns:
      包含 PivotTable 报告中页面区域的区域。 页面区域是报表筛选区域,用于显示方向设置为页字段的字段。如果 PivotTable 当前没有页面区域,此方法返回。
    • getPivotColumnAxis

      IPivotAxis getPivotColumnAxis()
      获取表示数据透视表报表整个列轴的 IPivotAxis 对象。

      使用此轴可以处理数据透视表的列侧结构,例如报告顶部显示的数据透视线。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Category", "Region", "Amount"},
           {"Beverages", "East", 120},
           {"Beverages", "West", 80},
           {"Snacks", "East", 95},
           {"Snacks", "West", 110}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.ColumnField);
       IPivotAxis columnAxis = pivotTable.getPivotColumnAxis();
       IPivotLines lines = columnAxis.getPivotLines();
       
      Returns:
      表示数据透视表报表整个列轴的 IPivotAxis 对象。
    • getPivotRowAxis

      IPivotAxis getPivotRowAxis()
      获取表示数据透视表报表整个行轴的 IPivotAxis 对象。

      使用此轴可以处理数据透视表的行侧结构,例如报告左侧向下显示的数据透视线。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Category", "Region", "Amount"},
           {"Beverages", "East", 120},
           {"Beverages", "West", 80},
           {"Snacks", "East", 95},
           {"Snacks", "West", 110}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       IPivotAxis rowAxis = pivotTable.getPivotRowAxis();
       IPivotLines lines = rowAxis.getPivotLines();
       
      Returns:
      表示数据透视表报表整个行轴的 IPivotAxis 对象。
    • getRowFields

      IPivotFields getRowFields()
      获取当前在 PivotTable 报告中显示为行字段的字段集合。

      返回的 IPivotFields 集合为只读,包含方向设置为行字段的字段。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Region", "Product", "Amount"},
           {"East", "Apple", 120},
           {"East", "Pear", 80},
           {"West", "Apple", 95},
           {"West", "Pear", 110}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Product").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       IPivotFields rowFields = pivotTable.getRowFields();
       String firstFieldName = rowFields.get(0).getName();
       
      Returns:
      当前显示为行字段的 IPivotFields 集合;请参阅 IPivotFields。返回的 IPivotFields 集合为只读,包含方向设置为行字段的字段。
    • getRowGrand

      boolean getRowGrand()
      获取数据透视表报表是否显示行总计。

      使用此方法可以确定数据透视表是否为行字段显示总计行。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Region", "Amount"},
           {"East", 120},
           {"West", 150},
           {"East", 90}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       boolean showRowGrand = pivotTable.getRowGrand();
       
      Returns:
      如果显示行总计,则为 true;否则为 false。
    • setRowGrand

      void setRowGrand(boolean value)
      设置 PivotTable 报表是否显示行总计。

      使用此方法可设置 PivotTable 是否为行字段显示总计行。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Region", "Amount"},
           {"East", 120},
           {"West", 150},
           {"East", 90}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       pivotTable.setRowGrand(value);
       
      Parameters:
      value - PivotTable 报表是否显示行总计。
    • getRowRange

      IRange getRowRange()
      获取包含数据透视表报告中行区域的区域。

      返回的区域表示当前数据透视表布局中行字段和行项使用的单元格。

      
       worksheet.getRange("A1:B5").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 120},
           {"Fruit", 80},
           {"Vegetables", 95},
           {"Vegetables", 60}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       IRange rowRange = pivotTable.getRowRange();
       
      Returns:
      包含数据透视表报告中行区域的区域。 返回的区域表示当前数据透视表布局中行字段和行项使用的单元格。
    • getShowTableStyleColumnHeaders

      boolean getShowTableStyleColumnHeaders()
      获取是否在数据透视表中显示列标题。

      此属性指示数据透视表是否使用当前表样式设置显示其列标题区域。

      
       worksheet.getRange("A1:D5").setValue(new Object[][] {
           {"Category", "Product", "Amount", "Region"},
           {"Beverages", "Tea", 100, "East"},
           {"Beverages", "Coffee", 200, "West"},
           {"Snacks", "Chips", 150, "East"},
           {"Snacks", "Nuts", 120, "West"}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:D5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("F1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.ColumnField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       boolean showColumnHeaders = pivotTable.getShowTableStyleColumnHeaders();
       
      Returns:
      如果在数据透视表中显示列标题。 此属性指示数据透视表是否使用当前表样式设置显示其列标题区域,则为 true;否则为 false。
    • setShowTableStyleColumnHeaders

      void setShowTableStyleColumnHeaders(boolean value)
      设置是否在 PivotTable 中显示列标题。

      此属性表示 PivotTable 是否使用当前表样式设置显示其列标题区域。

      
       worksheet.getRange("A1:D5").setValue(new Object[][] {
           {"Category", "Product", "Amount", "Region"},
           {"Beverages", "Tea", 100, "East"},
           {"Beverages", "Coffee", 200, "West"},
           {"Snacks", "Chips", 150, "East"},
           {"Snacks", "Nuts", 120, "West"}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:D5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("F1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.ColumnField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       pivotTable.setShowTableStyleColumnHeaders(value);
       
      Parameters:
      value - 是否在 PivotTable 中显示列标题。
    • getShowTableStyleColumnStripes

      boolean getShowTableStyleColumnStripes()
      获取是否在 PivotTable 样式中显示带状列。

      当此属性为 true 时,偶数列与奇数列使用不同格式,使 PivotTable 更易于阅读。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Drink", 200},
           {"Fruit", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setShowTableStyleColumnStripes(true);
       boolean showColumnStripes = pivotTable.getShowTableStyleColumnStripes();
       
      Returns:
      如果在 PivotTable 样式中显示带状列。 当此属性为 时,偶数列与奇数列使用不同格式,使 PivotTable 更易于阅读,则为 true;否则为 false。
    • setShowTableStyleColumnStripes

      void setShowTableStyleColumnStripes(boolean value)
      设置是否在 PivotTable 样式中显示带状列。

      当此属性为 true 时,偶数列的格式与奇数列不同,以使 PivotTable 更易于阅读。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Drink", 200},
           {"Fruit", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setShowTableStyleColumnStripes(true);
       
      Parameters:
      value - 是否在 PivotTable 样式中显示带状列。
    • getShowTableStyleLastColumn

      boolean getShowTableStyleLastColumn()
      获取是否在 PivotTable 中显示最后一列样式。

      此属性指示 PivotTable 样式是否应用于 PivotTable 报告的最后一列。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Drink", 200},
           {"Fruit", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       pivotTable.setShowTableStyleLastColumn(true);
       boolean showLastColumnStyle = pivotTable.getShowTableStyleLastColumn();
       
      Returns:
      如果在 PivotTable 中显示最后一列样式。 此属性指示 PivotTable 样式是否应用于 PivotTable 报告的最后一列,则为 true;否则为 false。
    • setShowTableStyleLastColumn

      void setShowTableStyleLastColumn(boolean value)
      设置是否在 PivotTable 中显示最后一列样式。

      此属性指示是否将 PivotTable 样式应用于 PivotTable 报表的最后一列。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Drink", 200},
           {"Fruit", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       pivotTable.setShowTableStyleLastColumn(true);
       
      Parameters:
      value - 是否在 PivotTable 中显示最后一列样式。
    • getShowTableStyleRowHeaders

      boolean getShowTableStyleRowHeaders()
      获取是否在 PivotTable 样式中显示行标题。

      使用此方法可以确定当前 PivotTable 样式是否显示行标题格式。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Drink", 200},
           {"Fruit", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setShowTableStyleRowHeaders(true);
       boolean showRowHeaders = pivotTable.getShowTableStyleRowHeaders();
       
      Returns:
      如果在 PivotTable 样式中显示行标题。 使用此方法可以确定当前 PivotTable 样式是否显示行标题格式,则为 true;否则为 false。
    • setShowTableStyleRowHeaders

      void setShowTableStyleRowHeaders(boolean value)
      设置是否在 PivotTable 样式中显示行标题。

      使用此方法可设置 PivotTable 样式是否显示行标题格式。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Drink", 200},
           {"Fruit", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setShowTableStyleRowHeaders(true);
       
      Parameters:
      value - 是否在 PivotTable 样式中显示行标题。
    • getShowTableStyleRowStripes

      boolean getShowTableStyleRowStripes()
      获取是否在数据透视表中显示带状行,使偶数行的格式与奇数行不同。

      当此属性为 true 时,数据透视表样式会应用交替行格式以提高可读性。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Beverages", 120},
           {"Snacks", 95},
           {"Beverages", 80}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       boolean showRowStripes = pivotTable.getShowTableStyleRowStripes();
       
      Returns:
      如果在数据透视表中显示带状行,使偶数行的格式与奇数行不同。 当此属性为 时,数据透视表样式会应用交替行格式以提高可读性,则为 true;否则为 false。
    • setShowTableStyleRowStripes

      void setShowTableStyleRowStripes(boolean value)
      设置是否在 PivotTable 中显示带状行,以便偶数行与奇数行采用不同的格式。

      当此属性为 true 时,PivotTable 样式会应用交替的行格式以提高可读性。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Beverages", 120},
           {"Snacks", 95},
           {"Beverages", 80}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       pivotTable.setShowTableStyleRowStripes(value);
       
      Parameters:
      value - 是否在 PivotTable 中显示带状行,以便偶数行与奇数行采用不同的格式。
    • getTableRange1

      IRange getTableRange1()
      获取包含整个 PivotTable 报告但不包括页字段的区域。

      使用此方法可以访问呈现的 PivotTable 区域,而不包括与主报告分开显示的任何页字段区域。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Fruit", 200},
           {"Vegetable", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       IRange range = pivotTable.getTableRange1();
       String address = range.toString();
       
      Returns:
      包含整个 PivotTable 报告但不包括页字段的区域。 使用此方法可以访问呈现的 PivotTable 区域,而不包括与主报告分开显示的任何页字段区域。
    • getTableRange2

      IRange getTableRange2()
      获取包含整个数据透视表报告(包括页字段)的区域。

      使用此方法可以检索完整显示的数据透视表区域(包括筛选区域),而不只是主体报告区域。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Beverages", 120},
           {"Beverages", 80},
           {"Snacks", 50}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D2"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       IRange range = pivotTable.getTableRange2();
       
      Returns:
      包含整个数据透视表报告(包括页字段)的区域。 使用此方法可以检索完整显示的数据透视表区域(包括筛选区域),而不只是主体报告区域。
    • getTableStyle

      String getTableStyle()
      获取数据透视表报告主体中使用的样式。

      默认值为空字符串,表示未应用任何样式。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Beverages", 120},
           {"Beverages", 80},
           {"Snacks", 95}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setTableStyle("PivotStyleMedium9");
       String styleName = pivotTable.getTableStyle();
       
      Returns:
      数据透视表报告主体中使用的样式。 默认值为空字符串,表示未应用任何样式。
    • setTableStyle

      void setTableStyle(String value)
      设置在 PivotTable 报告正文中使用的样式。

      默认值为空字符串,表示不应用任何样式。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Beverages", 120},
           {"Beverages", 80},
           {"Snacks", 95}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setTableStyle("PivotStyleMedium9");
       
      Parameters:
      value - 在 PivotTable 报告正文中使用的样式。
    • getTag

      String getTag()
      获取随数据透视表报告一起保存的字符串。

      使用此属性可以检索与数据透视表报告关联的自定义文本元数据。要存储值,请使用 setTag(String)。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Region", "Amount"},
           {"East", 120},
           {"West", 80},
           {"East", 90}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setTag("Monthly sales summary");
       String tag = pivotTable.getTag();
       
      Returns:
      随数据透视表报告一起保存的字符串。
    • setTag

      void setTag(String value)
      设置与数据透视表报表关联的自定义文本元数据。

      该值随数据透视表报表一起保存。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Region", "Amount"},
           {"East", 120},
           {"West", 80},
           {"East", 90}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setTag("Monthly sales summary");
       
      Parameters:
      value - 要与数据透视表报表关联的自定义文本元数据。
    • addDataField

      IPivotField addDataField(IPivotField field, String caption, ConsolidationFunction function)
      向数据透视表报告添加数据字段。

      使用此方法可以将源字段添加到值区域,并指定该数据字段使用的汇总函数。

      
       Object[][] sourceData = {
           {"Region", "Product", "Amount"},
           {"East", "Apple", 120},
           {"West", "Apple", 80},
           {"East", "Orange", 90}
       };
       worksheet.getRange("A1:C4").setValue(sourceData);
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.addDataField(pivotTable.getPivotFields().get("Amount"), "Sum of Amount", ConsolidationFunction.Sum);
       
      Parameters:
      field - 服务器上的唯一字段。如果源数据为 OLAP,则此字段是多维数据集字段;否则,它是数据透视表字段。
      caption - 数据透视表报告中用于标识所添加数据字段的标签。
      function - 在添加的数据字段中执行的函数。
      Returns:
      添加的 IPivotField 对象。
    • getCalculatedFields

      ICalculatedFields getCalculatedFields()
      获取此 PivotTable 报告中的计算字段集合。

      使用返回的 ICalculatedFields 集合可以访问或添加当前 PivotTable 的计算字段。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Product", "Amount"},
           {"Apple", 120},
           {"Orange", 90},
           {"Apple", 80}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       ICalculatedFields calculatedFields = pivotTable.getCalculatedFields();
       calculatedFields.add("DoubleAmount", "=Amount*2");
       
      Returns:
      此 PivotTable 报告中的 ICalculatedFields 集合;请参阅 ICalculatedFields。使用返回的 ICalculatedFields 集合可以访问或添加当前 PivotTable 的计算字段。
    • clearAllFilters

      void clearAllFilters()
      删除当前应用于数据透视表的所有筛选器。

      此方法会移除数据透视表筛选器集合中的筛选器,清除手动筛选,并将报告筛选区域中的所有数据透视字段重置为其默认项。

      
       Object[][] sourceData = {
           {"Product", "Country", "Amount"},
           {"Apple", "Canada", 120},
           {"Apple", "France", 150},
           {"Banana", "Canada", 90}
       };
       worksheet.getRange("A1:C4").setValue(sourceData);
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "PivotTable1");
       IPivotField fieldProduct = pivotTable.getPivotFields().get("Product");
       fieldProduct.setOrientation(PivotFieldOrientation.RowField);
       IPivotField fieldAmount = pivotTable.getPivotFields().get("Amount");
       fieldAmount.setOrientation(PivotFieldOrientation.DataField);
       fieldProduct.getPivotFilters().add(PivotFilterType.CaptionContains, "pp");
       pivotTable.clearAllFilters();
       
    • clearTable

      void clearTable()
      清除 PivotTable。

      清除 PivotTable 会移除所有字段,并删除应用于报告的所有筛选和排序。此方法会将 PivotTable 重置为刚创建后、添加任何字段之前的状态。

      
       Object[][] sourceData = {
           {"Product", "Region", "Amount"},
           {"Apple", "East", 120},
           {"Pear", "West", 80}
       };
       worksheet.getRange("A1:C3").setValue(sourceData);
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C3"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "PivotTable1");
       pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.addDataField(pivotTable.getPivotFields().get("Amount"), "Sum of Amount", ConsolidationFunction.Sum);
       pivotTable.clearTable();
       
    • getPivotCache

      IPivotCache getPivotCache()
      获取此数据透视表报告使用的 IPivotCache。

      返回的缓存表示与数据透视表关联的源数据缓存。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Product", "Sales"},
           {"Apple", 100},
           {"Orange", 200},
           {"Pear", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       IPivotCache cache = pivotTable.getPivotCache();
       
      Returns:
      此数据透视表报告使用的 IPivotCache 对象。
    • getPivotFields

      IPivotFields getPivotFields()
      获取数据透视表报告中的数据透视表字段集合。

      返回的 IPivotFields 集合包含数据透视表数据源中的可见字段和隐藏字段。可以使用此集合访问单个字段并配置它们在报告布局中的使用方式。

      
       worksheet.getRange("A1:B5").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 120},
           {"Fruit", 80},
           {"Vegetables", 95},
           {"Vegetables", 60}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       IPivotFields pivotFields = pivotTable.getPivotFields();
       pivotFields.get("Category").setOrientation(PivotFieldOrientation.RowField);
       
      Returns:
      数据透视表报告中的 IPivotFields 集合;请参阅 IPivotFields。返回的 IPivotFields 集合包含数据透视表数据源中的可见字段和隐藏字段。
    • pivotValueCell

      IPivotValueCell pivotValueCell(int rowline, int columnline)
      检索 PivotTable 数据区域中指定行和列位置的 IPivotValueCell。

      使用此方法可以访问 PivotTable 报告中的计算值单元格,然后检查其值或相关的 IPivotCell 信息。

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Region", "Amount"},
           {"East", 100},
           {"West", 200}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B3"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"));
       pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       IPivotValueCell valueCell = pivotTable.pivotValueCell(0, 0);
       Object value = valueCell.getValue();
       
      Parameters:
      rowline - 数据区域中的行位置。
      columnline - 数据区域中的列位置。
      Returns:
      指定位置的 IPivotValueCell 对象。
    • refresh

      boolean refresh()
      从其源数据刷新 PivotTable 报表。

      当源数据已更改并且需要 PivotTable 反映最新数据时,请使用此方法。

      此方法执行以下操作:

      1. 刷新底层 IPivotCache。
      2. 将 IPivotFields 与已刷新的缓存同步。
      3. 重新计算并更新工作表上的 PivotTable 报表。

      如果仅 PivotTable 布局或显示设置已更改,而源数据未更改,请改用 update()。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Product", "Amount"},
           {"Apple", 100},
           {"Apple", 200},
           {"Orange", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "PivotTable1");
       pivotTable.getPivotFields().get("Product").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       worksheet.getRange("B2").setValue(120);
       boolean refreshed = pivotTable.refresh();
       
      Returns:
      如果刷新成功,则为 true。
      Throws:
      IllegalStateException - 如果找不到 PivotTable 的源工作表。
    • repeatAllLabels

      void repeatAllLabels(PivotFieldRepeatLabels repeat)
      设置是否为此数据透视表中的所有数据透视字段重复项目标签。

      此设置会应用于数据透视表中的所有现有数据透视字段。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Category", "Product", "Amount"},
           {"Beverages", "Tea", 100},
           {"Beverages", "Coffee", 200},
           {"Snacks", "Chips", 150},
           {"Snacks", "Nuts", 120}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Product").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.repeatAllLabels(PivotFieldRepeatLabels.RepeatLabels);
       
      Parameters:
      repeat - 指定是否为数据透视表中的所有数据透视字段重复项目标签。
    • setRowAxisLayout

      void setRowAxisLayout(LayoutRowType rowLayout)
      设置数据透视表中所有现有 PivotFields 的行轴布局。

      使用此方法可以一次性将单个 LayoutRowType 应用于当前行字段。要为以后添加的 PivotFields 设置默认布局,请使用 setLayoutRowDefault(LayoutRowType)。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Region", "Product", "Amount"},
           {"East", "Apple", 120},
           {"West", "Apple", 80},
           {"East", "Orange", 90},
           {"West", "Orange", 110}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Product").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       pivotTable.setRowAxisLayout(LayoutRowType.TabularRow);
       
      Parameters:
      rowLayout - 要应用于所有现有 PivotFields 的行轴布局类型。
    • subtotalLocation

      void subtotalLocation(SubtotalLocationType location)
      更改所有现有数据透视字段的小计位置。

      更改小计位置只会立即影响大纲形式中的字段视觉效果,但此设置也会应用于表格形式中的字段。

      如果行轴布局为 LayoutRowType.TabularRow,则 location 必须为 SubtotalLocationType.Bottom。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Beverages", 100},
           {"Snacks", 200},
           {"Beverages", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"));
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       pivotTable.subtotalLocation(SubtotalLocationType.Bottom);
       
      Parameters:
      location - 要应用于所有现有数据透视字段的小计位置。
      Throws:
      IllegalArgumentException - 如果行轴布局为 LayoutRowType.TabularRow,且 location 不是 SubtotalLocationType.Bottom。
    • update

      void update()
      更新数据透视表的布局和显示结果。

      常见用法是启用 setDeferLayoutUpdate(boolean),进行多个布局更改后,再调用此方法一次性应用所有的更改。

      此方法不会从源数据刷新 IPivotCache。如果源数据已更改且必须先刷新缓存,请改为调用 refresh()。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Category", "Product", "Amount"},
           {"Beverages", "Tea", 100},
           {"Beverages", "Coffee", 200},
           {"Snacks", "Biscuits", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "PivotTable1");
       pivotTable.setDeferLayoutUpdate(true);
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       pivotTable.update();
       
    • getStyle

      ITableStyle getStyle()
      获取应用于数据透视表的样式。

      此方法返回与数据透视表关联的当前 ITableStyle。如果未应用任何样式,则此方法返回 null。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Name", "Amount"},
           {"A", 100},
           {"B", 200},
           {"A", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setStyle(workbook.getTableStyles().get("PivotStyleMedium3"));
       ITableStyle style = pivotTable.getStyle();
       String styleName = style.getName();
       
      Returns:
      应用于数据透视表的样式。 此方法返回与数据透视表关联的当前 。如果未应用任何样式,则此方法返回。
    • setStyle

      void setStyle(ITableStyle style)
      设置应用于数据透视表的样式。

      此方法设置与数据透视表关联的当前 ITableStyle。如果尚未应用任何样式,此方法将设置 null。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Name", "Amount"},
           {"A", 100},
           {"B", 200},
           {"A", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setStyle(workbook.getTableStyles().get("PivotStyleMedium3"));
       String styleName = style.getName();
       
      Parameters:
      style - 应用于数据透视表的样式。
    • getPivotFormulas

      IPivotFormulas getPivotFormulas()
      获取指定 PivotTable 报告的公式集合。

      使用此方法可以访问 IPivotFormulas 集合,该集合包含为 PivotTable 定义的自定义公式,例如由计算项创建的公式。

      
       worksheet.getRange("A1:C4").setValue(new Object[][] {
           {"Product", "Category", "Amount"},
           {"Apple", "Fruit", 120},
           {"Banana", "Fruit", 80},
           {"Bran", "Snack", 60}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.getPivotFields().get("Product").setOrientation(PivotFieldOrientation.RowField);
       pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
       pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.ColumnField);
       pivotTable.getPivotFields().get("Product").getCalculatedItems().add("TotalFruit", "=Product[Apple] + Product[Banana]");
       IPivotFormulas formulas = pivotTable.getPivotFormulas();
       IPivotFormula formula = formulas.get(0);
       
      Returns:
      指定 PivotTable 报告的公式集合。 使用此方法可以访问 集合,该集合包含为 PivotTable 定义的自定义公式,例如由计算项创建的公式。
    • getAllowMultipleFilters

      boolean getAllowMultipleFilters()
      获取数据透视表中的数据透视字段是否可以同时应用多个筛选器。

      使用此属性可以确定数据透视表是否允许单个数据透视字段同时保留多个筛选条件。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Category", "Product", "Amount"},
           {"Fruit", "Apple", 120},
           {"Fruit", "Banana", 90},
           {"Drink", "Tea", 60},
           {"Drink", "Coffee", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.setAllowMultipleFilters(true);
       boolean allowMultipleFilters = pivotTable.getAllowMultipleFilters();
       
      Returns:
      如果数据透视表中的数据透视字段可以同时应用多个筛选器,则为 true;否则为 false。
    • setAllowMultipleFilters

      void setAllowMultipleFilters(boolean allowMultipleFilters)
      设置数据透视表中的数据透视字段是否可以同时应用多个筛选器。

      使用此属性可设置数据透视表是否允许单个数据透视字段同时保留多个筛选条件。

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Category", "Product", "Amount"},
           {"Fruit", "Apple", 120},
           {"Fruit", "Banana", 90},
           {"Drink", "Tea", 60},
           {"Drink", "Coffee", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C5"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.setAllowMultipleFilters(true);
       
      Parameters:
      allowMultipleFilters - 数据透视表中的数据透视字段是否可以同时应用多个筛选器。
    • getHasAutoFormat

      boolean getHasAutoFormat()
      获取一个值,指示数据透视表报表在刷新时是否自动调整列宽。

      默认值为 true。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Product", "Amount"},
           {"Apple", 100},
           {"Orange", 200},
           {"Apple", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       boolean hasAutoFormat = pivotTable.getHasAutoFormat();
       
      Returns:
      如果刷新时自动调整列宽,则为 true;否则为 false。
    • setHasAutoFormat

      void setHasAutoFormat(boolean value)
      设置一个值,指示 PivotTable 报表在刷新时是否自动调整列宽。

      默认值为 true。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Product", "Amount"},
           {"Apple", 100},
           {"Orange", 200},
           {"Apple", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
       pivotTable.setHasAutoFormat(true);
       
      Parameters:
      value - PivotTable 报表在刷新时是否自动调整列宽。
    • getDisplayFieldCaptions

      boolean getDisplayFieldCaptions()
      获取是否在网格中显示行和列的筛选按钮以及数据透视字段标题。默认值为 true。
      
       worksheet.getRange("A1:B4").setValue(new Object[][] {{"Category", "Amount"}, {"Fruit", 120}, {"Fruit", 80}, {"Drink", 50}});
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setDisplayFieldCaptions(false);
       boolean displayFieldCaptions = pivotTable.getDisplayFieldCaptions();
       
      Returns:
      如果在网格中显示行和列的筛选按钮以及数据透视字段标题,则为 true;否则为 false。
    • setDisplayFieldCaptions

      void setDisplayFieldCaptions(boolean displayFieldCaptions)
      设置是否在网格中显示行和列的筛选按钮以及数据透视字段标题。
      
       worksheet.getRange("A1:B4").setValue(new Object[][] {{"Category", "Amount"}, {"Fruit", 120}, {"Fruit", 80}, {"Drink", 50}});
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       pivotTable.setDisplayFieldCaptions(false);
       
      Parameters:
      displayFieldCaptions - true 表示显示筛选按钮和字段标题;否则为 false。