[]
        
(Showing Draft Content)

ISlicerCaches

Interface ISlicerCaches

All Superinterfaces:
Iterable<ISlicerCache>

public interface ISlicerCaches extends Iterable<ISlicerCache>
Represents a collection of slicer caches associated with a workbook.

Use this collection to create, retrieve, and enumerate ISlicerCache objects that are based on workbook data sources such as tables.


 worksheet.getRange("A1:B4").setValue(new Object[][] {
     {"Category", "Amount"},
     {"Fruit", 100},
     {"Vegetable", 200},
     {"Fruit", 150}
 });
 ITable table = worksheet.getTables().add(worksheet.getRange("A1:B4"), true);
 ISlicerCaches slicerCaches = workbook.getSlicerCaches();
 ISlicerCache slicerCache = slicerCaches.add(table, "Category");
 
  • Method Details

    • getCount

      int getCount()
      Gets the number of slicer caches in this collection.

      This method returns the number of ISlicerCache objects in the ISlicerCaches collection associated with a workbook.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Category", "Value"},
           {"Beverages", 100},
           {"Produce", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       workbook.getSlicerCaches().add(table, "Category");
       int count = workbook.getSlicerCaches().getCount();
       
      Returns:
      The number of slicer caches in this collection. Returns 0 if the collection contains no slicer caches.
    • get

      ISlicerCache get(int index)
      Gets the ISlicerCache with the specified index.
      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Product", "Category"},
           {"Apple", "Fruit"},
           {"Carrot", "Vegetable"}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       ISlicerCache slicerCache = workbook.getSlicerCaches().get(0);
       
      Parameters:
      index - The zero-based index of the slicer cache.
      Returns:
      The ISlicerCache at the specified index.
    • get

      ISlicerCache get(String name)
      Gets the ISlicerCache with the specified name.

      If a slicer cache has already been added to the workbook's ISlicerCaches collection, use this method to retrieve it.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Vegetable", 200},
           {"Fruit", 150}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B4"), true);
       workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       ISlicerCache slicerCache = workbook.getSlicerCaches().get("categoryCache");
       
      Parameters:
      name - The name of the slicer cache to retrieve.
      Returns:
      The ISlicerCache with the specified name.
    • add

      ISlicerCache add(Object source, String sourceField)
      Adds a new ISlicerCache object to the collection.

      Creates a slicer cache based on the specified data source and field. The data source can be a supported object such as a table or PivotTable, and sourceField identifies the field used by the slicer cache.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Vegetable", 200},
           {"Fruit", 150}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B4"), true);
       ISlicerCache slicerCache = workbook.getSlicerCaches().add(table, "Category");
       
      Parameters:
      source - The data source that the new ISlicerCache will be based on.
      sourceField - The name of the field in the data source to filter by.
      Returns:
      The new ISlicerCache.
    • add

      ISlicerCache add(Object source, String sourceField, String name)
      Adds a new ISlicerCache object to the collection.

      Creates a slicer cache based on the specified data source and field. The name parameter is used to reference the created slicer cache through the ISlicerCache name property.

      
       Object[][] sourceData = new Object[][] {
           {"Product", "Category", "Amount"},
           {"Apple", "Fruit", 100},
           {"Carrot", "Vegetable", 200}
       };
       worksheet.getRange("A1:C3").setValue(sourceData);
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:C3"), true);
       ISlicerCache cache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       
      Parameters:
      source - The data source that the new ISlicerCache will be based on.
      sourceField - The name of the field in the data source to filter by.
      name - The name used to reference the slicer cache.
      Returns:
      The new ISlicerCache.