[]
        
(Showing Draft Content)

ISlicerCache

Interface ISlicerCache


public interface ISlicerCache
Represents the current filter state of a slicer cache and information about the data source associated with the slicer.

An ISlicerCache is created from a table or pivot table field and provides access to the slicers and slicer items that use that 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");
 
  • Method Details

    • getFilterCleared

      boolean getFilterCleared()
      Gets whether the slicer cache filter state is cleared.

      Returns true when no slicer items in the cache are excluded by filtering. This value becomes true after calling clearAllFilters().

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Vegetables", 200},
           {"Fruit", 150}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B4"), true);
       ISlicerCache slicerCache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       boolean filterCleared = slicerCache.getFilterCleared();
       
      Returns:
      true if the slicer cache filter state is cleared; otherwise, false.
    • getList

      boolean getList()
      Gets whether this slicer cache is based on a table.

      This method returns true when the slicer cache was created from a table data source, and false when it was created from another supported data source such as a PivotTable.

      
       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");
       boolean isTableSlicerCache = slicerCache.getList();
       
      Returns:
      true if the slicer cache is for a slicer on a table; otherwise, false.
    • getTable

      ITable getTable()
      Gets the table associated with the slicer cache.

      Use this method to access the ITable that supplies the data source for the slicer cache.

      
       Object[][] sourceData = new Object[][] {{"Category"}, {"Fruit"}, {"Vegetables"}};
       worksheet.getRange("A1:A3").setValue(sourceData);
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:A3"), true);
       ISlicerCache slicerCache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       ITable slicerTable = slicerCache.getTable();
       
      Returns:
      The ITable object associated with the slicer cache.
    • getName

      String getName()
      Gets the name of the slicer cache.

      This value is the name used to reference the slicer cache. It can be specified when the cache is created by ISlicerCaches.add(Object,String,String) or changed later by setName(String).

      
       Object[][] sourceData = new Object[][] {{"Category"}, {"Fruit"}, {"Vegetables"}};
       worksheet.getRange("A1:A3").setValue(sourceData);
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:A3"), true);
       ISlicerCache slicerCache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       String name = slicerCache.getName();
       
      Returns:
      The name of the slicer cache.
    • setName

      void setName(String value)
      Sets the name of the slicer cache.
      
       Object[][] sourceData = new Object[][] {{"Category"}, {"Fruit"}, {"Vegetables"}};
       worksheet.getRange("A1:A3").setValue(sourceData);
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:A3"), true);
       ISlicerCache slicerCache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       slicerCache.setName("categoryCacheRenamed");
       
      Parameters:
      value - The name of the slicer cache.
    • getSourceName

      String getSourceName()
      Gets the name of the source field that the slicer cache is connected to.

      This value identifies the field in the underlying table or PivotTable data source that the slicer cache uses for filtering.

      
       Object[][] sourceData = new Object[][] {{"Category"}, {"Fruit"}, {"Vegetables"}};
       worksheet.getRange("A1:A3").setValue(sourceData);
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:A3"), true);
       ISlicerCache slicerCache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       String sourceName = slicerCache.getSourceName();
       
      Returns:
      The name of the source field used by the slicer cache.
    • getPivotTables

      ISlicerPivotTables getPivotTables()
      Gets the ISlicerPivotTables collection that contains the PivotTable objects currently filtered by the slicer cache.

      Use this method to access the PivotTable objects associated with the current slicer cache.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Beverages", 100},
           {"Produce", 200},
           {"Beverages", 150}
       });
       IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
       IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
       ISlicerCache slicerCache = workbook.getSlicerCaches().add(pivotTable, "Category");
       ISlicerPivotTables pivotTables = slicerCache.getPivotTables();
       
      Returns:
      An ISlicerPivotTables collection that contains the PivotTable objects currently filtered by the slicer cache.
    • getSlicerItems

      ISlicerItems getSlicerItems()
      Gets the ISlicerItems collection that contains all items in the slicer cache.

      Use this method to access the cached items for the slicer's source field, including items that can be retrieved by index or by item name.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Drink", 200},
           {"Fruit", 150}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B4"), true);
       ISlicerCache slicerCache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       ISlicerItems slicerItems = slicerCache.getSlicerItems();
       ISlicerItem slicerItem = slicerItems.get("Fruit");
       
      Returns:
      The ISlicerItems collection that contains all items in the slicer cache.
    • getSlicers

      ISlicers getSlicers()
      Gets the ISlicers collection associated with this ISlicerCache.

      The returned collection contains the ISlicer objects that use this slicer cache.

      
       Object[][] sourceData = new Object[][] {{"Category"}, {"Fruit"}, {"Vegetables"}};
       worksheet.getRange("A1:A3").setValue(sourceData);
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:A3"), true);
       ISlicerCache slicerCache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       ISlicers slicers = slicerCache.getSlicers();
       slicers.add(worksheet, "categorySlicer", "Category", 20, 20, 120, 160);
       
      Returns:
      The ISlicers collection that contains the ISlicer objects associated with this ISlicerCache.
    • getSortItems

      SlicerSortOrder getSortItems()
      Gets the sort order of the items in the slicer.

      Use this method to retrieve whether slicer items are currently sorted in ascending or descending order.

      
       Object[][] sourceData = new Object[][] {{"Category"}, {"Fruit"}, {"Vegetables"}};
       worksheet.getRange("A1:A3").setValue(sourceData);
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:A3"), true);
       ISlicerCache slicerCache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       slicerCache.setSortItems(SlicerSortOrder.Descending);
       SlicerSortOrder sortOrder = slicerCache.getSortItems();
       
      Returns:
      The sort order of the items in the slicer.
    • setSortItems

      void setSortItems(SlicerSortOrder value)
      Sets the sort order of the items in the slicer.

      Use this method to control whether slicer items are displayed in ascending or descending order.

      
       Object[][] sourceData = new Object[][] {{"Category"}, {"Fruit"}, {"Vegetables"}};
       worksheet.getRange("A1:A3").setValue(sourceData);
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:A3"), true);
       ISlicerCache slicerCache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       slicerCache.setSortItems(SlicerSortOrder.Descending);
       
      Parameters:
      value - The sort order of the items in the slicer.
    • clearAllFilters

      void clearAllFilters()
      Clears all filters applied through this slicer cache.

      This method removes the current slicer filter state and restores the display of all items according to the slicer cache type.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Vegetables", 200},
           {"Fruit", 150}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B4"), true);
       ISlicerCache cache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       cache.getSlicerItems().get("Vegetables").setSelected(false);
       cache.clearAllFilters();
       
    • delete

      void delete()
      Deletes this slicer cache and all ISlicer objects associated with it.

      After this method is called, the slicer cache is removed from the workbook's slicer cache collection.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Beverages", 100},
           {"Produce", 200},
           {"Snacks", 150}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B4"), true);
       ISlicerCache cache = workbook.getSlicerCaches().add(table, "Category");
       cache.getSlicers().add(worksheet, "categorySlicer", "Category", 30, 100, 120, 160);
       cache.delete();