[]
        
(Showing Draft Content)

ISlicers

Interface ISlicers

All Superinterfaces:
Iterable<ISlicer>

public interface ISlicers extends Iterable<ISlicer>
Represents a collection of ISlicer objects.

An ISlicers object provides access to the slicers associated with a ISlicerCache. Use it to create slicers, iterate through existing slicers, or retrieve a slicer by index or name.


 Object[][] sourceData = new Object[][] {
     {"Product", "Category"},
     {"Apple", "Fruit"},
     {"Carrot", "Vegetable"}
 };
 worksheet.getRange("A1:B3").setValue(sourceData);
 ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
 ISlicerCache slicerCache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
 ISlicers slicers = slicerCache.getSlicers();
 ISlicer slicer = slicers.add(worksheet, "categorySlicer", "Category", 20, 20, 120, 160);
 
  • Method Details

    • get

      ISlicer get(int index)
      Gets the ISlicer with the specified index.

      If the slicer's position is known, use this method to retrieve it from the collection.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Vegetable", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ISlicerCache cache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       cache.getSlicers().add(worksheet, "categorySlicer", "Category", 20, 20, 120, 160);
       ISlicer slicer = cache.getSlicers().get(0);
       
      Parameters:
      index - The index of the slicer to get.
      Returns:
      The ISlicer with the specified index.
    • get

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

      If the slicer's name is known, use this method to retrieve it from the collection.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Vegetable", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ISlicerCache cache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       cache.getSlicers().add(worksheet, "categorySlicer", "Category", 20, 20, 120, 160);
       ISlicer slicer = cache.getSlicers().get("categorySlicer");
       
      Parameters:
      name - The name of the slicer to get.
      Returns:
      The ISlicer with the specified name.
    • getCount

      int getCount()
      Gets the number of ISlicer objects in the collection.

      Use this method to determine how many slicers are associated with an ISlicerCache.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Vegetable", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ISlicerCache cache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       cache.getSlicers().add(worksheet, "categorySlicer", "Category", 20, 20, 120, 160);
       int count = cache.getSlicers().getCount();
       
      Returns:
      The number of ISlicer objects in the collection.
    • add

      ISlicer add(IWorksheet slicerDestination, String name, String caption, double top, double left, double width, double height)
      Creates a slicer on the specified worksheet and returns the new ISlicer.

      The slicer is added to this collection and positioned using coordinates measured in points, relative to the upper-left corner of cell A1 on the destination worksheet.

      
       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 cache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       ISlicer slicer = cache.getSlicers().add(worksheet, "categorySlicer", "Category", 30, 200, 120, 160);
       
      Parameters:
      slicerDestination - The IWorksheet on which the slicer is placed. The destination worksheet must belong to the workbook that contains this ISlicers collection.
      name - The slicer name. This name must be unique across all slicers in the workbook.
      caption - The caption displayed for the slicer.
      top - The initial vertical position of the slicer, in points, relative to the upper-left corner of cell A1.
      left - The initial horizontal position of the slicer, in points, relative to the upper-left corner of cell A1.
      width - The initial width of the slicer, in points.
      height - The initial height of the slicer, in points.
      Returns:
      The created ISlicer.