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

IPivotCaches

Interface IPivotCaches

All Superinterfaces:
Iterable<IPivotCache>

public interface IPivotCaches extends Iterable<IPivotCache>
表示工作簿中数据透视表报表的内存缓存集合。

IPivotCaches 集合提供对工作簿中所有 IPivotCache 对象的访问。使用此接口可按索引检索现有缓存、获取缓存数量,或在创建数据透视表报表之前从工作表区域或表创建新缓存。


 worksheet.getRange("A1:C4").setValue(new Object[][] {
     {"Product", "Category", "Amount"},
     {"Carrots", "Vegetables", 1200},
     {"Broccoli", "Vegetables", 850},
     {"Bananas", "Fruit", 640}
 });
 IPivotCaches pivotCaches = workbook.getPivotCaches();
 IPivotCache pivotCache = pivotCaches.create(worksheet.getRange("A1:C4"));
 
  • Method Details

    • getCount

      int getCount()
      获取此集合中 IPivotCache 对象的数量。

      使用此方法可确定工作簿中当前可用的 PivotTable 缓存数量。

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Product", "Amount"},
           {"Apple", 100},
           {"Banana", 200}
       });
       worksheet.getRange("D1:E3").setValue(new Object[][] {
           {"Region", "Sales"},
           {"East", 300},
           {"West", 250}
       });
       IPivotCaches pivotCaches = workbook.getPivotCaches();
       pivotCaches.create(worksheet.getRange("A1:B3"));
       pivotCaches.create(worksheet.getRange("D1:E3"));
       int count = pivotCaches.getCount();
       
      Returns:
      集合中 PivotTable 缓存的数量。
    • get

      IPivotCache get(int index)
      获取指定索引处的 IPivotCache。

      使用 create(Object) 创建后,可使用此方法从工作簿的 IPivotCaches 集合中检索 PivotCache。

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Beverages", 100},
           {"Snacks", 200}
       });
       IPivotCaches pivotCaches = workbook.getPivotCaches();
       pivotCaches.create(worksheet.getRange("A1:B3"));
       IPivotCache pivotCache = pivotCaches.get(0);
       
      Parameters:
      index - 要检索的 PivotCache 的索引。
      Returns:
      指定索引处的 IPivotCache。
    • create

      IPivotCache create(Object SourceData)
      从源区域或表创建新的 PivotCache。

      使用此方法可生成稍后用于创建 PivotTable 的 PivotCache。源数据必须是 IRange 或 ITable。

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Region", "Sales"},
           {"East", 120},
           {"West", 150},
           {"East", 90}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       
      Parameters:
      SourceData - 新 PivotCache 的源数据。此值必须是 IRange 或 ITable;不支持 null。
      Returns:
      从指定源数据创建的新 IPivotCache。
      Throws:
      IllegalArgumentException - 如果 SourceData 不是 IRange 或 ITable。