[]
        
(Showing Draft Content)

IPivotCaches

Interface IPivotCaches

All Superinterfaces:
Iterable<IPivotCache>

public interface IPivotCaches extends Iterable<IPivotCache>
Represents the collection of memory caches for PivotTable reports in a workbook.

An IPivotCaches collection provides access to all IPivotCache objects in the workbook. Use this interface to retrieve an existing cache by index, get the number of caches, or create a new cache from a worksheet range or table before creating PivotTable reports.


 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()
      Gets the number of IPivotCache objects in this collection.

      Use this method to determine how many PivotTable caches are currently available in the workbook.

      
       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:
      The number of PivotTable caches in the collection.
    • get

      IPivotCache get(int index)
      Gets the IPivotCache at the specified index.

      Use this method to retrieve a PivotCache from the workbook's IPivotCaches collection after it has been created with create(Object).

      
       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 - The index of the PivotCache to retrieve.
      Returns:
      The IPivotCache at the specified index.
    • create

      IPivotCache create(Object SourceData)
      Creates a new PivotCache from a source range or table.

      Use this method to build a PivotCache that can later be used to create a PivotTable. The source data must be an IRange or an 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 - The source data for the new PivotCache. This must be an IRange or an ITable; null is not supported.
      Returns:
      A new IPivotCache created from the specified source data.
      Throws:
      IllegalArgumentException - If SourceData is not an IRange or an ITable.