[]
        
(Showing Draft Content)

ISlicer

Interface ISlicer


public interface ISlicer
Represents a slicer in a workbook.

A slicer is a visual filter control for a table or PivotTable. You can use an ISlicer to display filter choices, apply slicer styles, and configure the slicer's layout and display settings on a worksheet.


 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");
 ISlicer slicer = cache.getSlicers().add(worksheet, "categorySlicer", "Category", 30, 100, 120, 160);
 
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deletes the slicer and removes it from the associated ISlicers collection.
    void
    Updates the slicer settings from the specified JSON string.
    Gets the caption of the specified slicer.
    boolean
    Gets whether the slicer's caption header is visible.
    double
    Gets the height of the slicer, in points.
    double
    Gets the horizontal position of the specified slicer, in points, relative to the upper-left corner of cell A1 on a worksheet.
    Gets the name of the slicer.
    int
    Gets the number of columns used to display items in the slicer.
    double
    Gets the height, in points, of each row in the specified slicer.
    Gets the IShape object associated with the slicer.
    Gets the ISlicerCache object associated with the slicer.
    Gets the style currently applied to the specified slicer.
    double
    Gets the vertical position of the specified slicer, in points, relative to the upper-left corner of cell A1 on a worksheet.
    double
    Gets the width of the specified slicer, in points.
    void
    Sets the caption of the specified slicer.
    void
    setDisplayHeader(boolean value)
    Sets whether the slicer's caption header is visible.
    void
    setHeight(double value)
    Sets the height of the slicer, in points.
    void
    setLeft(double value)
    Sets the horizontal position of the specified slicer, in points, relative to the upper-left corner of cell A1 on a worksheet.
    void
    setName(String value)
    Sets the name of the slicer.
    void
    setNumberOfColumns(int value)
    Sets the number of columns used to display items in the slicer.
    void
    setRowHeight(double value)
    Sets the height, in points, of each row in the specified slicer.
    void
    Sets the style applied to the slicer.
    void
    setTop(double value)
    Sets the vertical position of the specified slicer, in points, relative to the upper-left corner of cell A1 on a worksheet.
    void
    setWidth(double value)
    Sets the width of the specified slicer, in points.
    Generates a JSON string from this slicer.
  • Method Details

    • getCaption

      String getCaption()
      Gets the caption of the specified slicer.

      The caption is the text displayed in the slicer header. Call setCaption(String) to change it after the slicer is created.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Category", "Value"},
           {"Beverages", 100},
           {"Snacks", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ISlicerCache slicerCache = workbook.getSlicerCaches().add(table, "Category");
       ISlicer slicer = slicerCache.getSlicers().add(worksheet, "categorySlicer", "Category", 20, 20, 120, 180);
       String caption = slicer.getCaption();
       
      Returns:
      The caption text of the slicer.
    • setCaption

      void setCaption(String value)
      Sets the caption of the specified slicer.
      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Category", "Value"},
           {"Beverages", 100},
           {"Snacks", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ISlicerCache slicerCache = workbook.getSlicerCaches().add(table, "Category");
       ISlicer slicer = slicerCache.getSlicers().add(worksheet, "categorySlicer", "Product Category", 20, 20, 120, 180);
       slicer.setCaption("Product Category");
       
      Parameters:
      value - The caption text of the slicer.
    • getDisplayHeader

      boolean getDisplayHeader()
      Gets whether the slicer's caption header is visible.

      Use this method to determine whether the slicer shows its header.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Vegetable", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ISlicer slicer = workbook.getSlicerCaches().add(table, "Category")
           .getSlicers().add(worksheet, "slicer1", "Category", 10, 10, 120, 160);
       slicer.setDisplayHeader(false);
       boolean displayHeader = slicer.getDisplayHeader();
       
      Returns:
      true if the slicer header is visible; otherwise, false.
    • setDisplayHeader

      void setDisplayHeader(boolean value)
      Sets whether the slicer's caption header is visible.

      Use this method to set whether the slicer shows its header.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Vegetable", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ISlicer slicer = workbook.getSlicerCaches().add(table, "Category")
           .getSlicers().add(worksheet, "slicer1", "Category", 10, 10, 120, 160);
       slicer.setDisplayHeader(false);
       
      Parameters:
      value - true if the slicer header is visible; otherwise, false.
    • getHeight

      double getHeight()
      Gets the height of the slicer, in points.

      Use this method to retrieve the current vertical size of a slicer on the worksheet.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Vegetables", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ISlicerCache cache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       ISlicer slicer = cache.getSlicers().add(worksheet, "categorySlicer", "Category", 30, 100, 120, 180);
       double height = slicer.getHeight();
       
      Returns:
      The height of the slicer, in points.
    • setHeight

      void setHeight(double value)
      Sets the height of the slicer, in points.

      Use this method to set the vertical size of a slicer on the worksheet.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Vegetables", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ISlicerCache cache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       ISlicer slicer = cache.getSlicers().add(worksheet, "categorySlicer", "Category", 30, 100, 120, 180);
       slicer.setHeight(100.0);
       
      Parameters:
      value - The height of the slicer, in points.
    • getLeft

      double getLeft()
      Gets the horizontal position of the specified slicer, in points, relative to the upper-left corner of cell A1 on a worksheet.

      Use this method to retrieve the current left offset of the slicer on the worksheet.

      
       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);
       ISlicer slicer = workbook.getSlicerCaches().add(table, "Category")
           .getSlicers().add(worksheet, "categorySlicer", "Category", 30, 100, 120, 160);
       double left = slicer.getLeft();
       
      Returns:
      The horizontal position of the slicer, in points, relative to the upper-left corner of cell A1.
    • setLeft

      void setLeft(double value)
      Sets the horizontal position of the specified slicer, in points, relative to the upper-left corner of cell A1 on a worksheet.

      Use this method to set the left offset of the slicer on the worksheet.

      
       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);
       ISlicer slicer = workbook.getSlicerCaches().add(table, "Category")
           .getSlicers().add(worksheet, "categorySlicer", "Category", 30, 100, 120, 160);
       slicer.setLeft(100.0);
       
      Parameters:
      value - The horizontal position of the slicer, in points, relative to the upper-left corner of cell A1.
    • getName

      String getName()
      Gets the name of the slicer.

      This name identifies the slicer object and corresponds to the name assigned when the slicer is created or renamed by using setName(String).

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Vegetables", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ISlicerCache cache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       ISlicer slicer = cache.getSlicers().add(worksheet, "categorySlicer", "Category", 20, 20, 100, 120);
       String name = slicer.getName();
       
      Returns:
      The name of the slicer.
    • setName

      void setName(String value)
      Sets the name of the slicer.
      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Vegetables", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ISlicerCache cache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       ISlicer slicer = cache.getSlicers().add(worksheet, "categorySlicer", "Category", 20, 20, 100, 120);
       slicer.setName("categorySlicerRenamed");
       
      Parameters:
      value - The name of the slicer.
    • getNumberOfColumns

      int getNumberOfColumns()
      Gets the number of columns used to display items in the slicer.

      Use this property to determine the current slicer layout when slicer items are arranged in multiple columns.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Product", "Amount"},
           {"Apple", 100},
           {"Orange", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ISlicerCache cache = workbook.getSlicerCaches().add(table, "Product", "productCache");
       ISlicer slicer = cache.getSlicers().add(worksheet, "productSlicer", "Product", 30, 30, 120, 160);
       slicer.setNumberOfColumns(2);
       int columnCount = slicer.getNumberOfColumns();
       
      Returns:
      The number of columns in the slicer.
    • setNumberOfColumns

      void setNumberOfColumns(int value)
      Sets the number of columns used to display items in the slicer.

      Use this property to set the slicer layout when slicer items are arranged in multiple columns.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Product", "Amount"},
           {"Apple", 100},
           {"Orange", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ISlicerCache cache = workbook.getSlicerCaches().add(table, "Product", "productCache");
       ISlicer slicer = cache.getSlicers().add(worksheet, "productSlicer", "Product", 30, 30, 120, 160);
       slicer.setNumberOfColumns(2);
       
      Parameters:
      value - The number of columns in the slicer.
    • getRowHeight

      double getRowHeight()
      Gets the height, in points, of each row in the specified slicer.

      This value controls the height of the item rows displayed in the slicer.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Vegetable", 200},
           {"Snack", 150}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B4"), true);
       ISlicer slicer = workbook.getSlicerCaches().add(table, "Category")
           .getSlicers().add(worksheet, "categorySlicer", "Category", 20, 20, 120, 160);
       double rowHeight = slicer.getRowHeight();
       
      Returns:
      The height, in points, of each row in the slicer.
    • setRowHeight

      void setRowHeight(double value)
      Sets the height, in points, of each row in the specified slicer.

      This value controls the height of the item rows displayed in the slicer.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Category", "Amount"},
           {"Fruit", 100},
           {"Vegetable", 200},
           {"Snack", 150}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B4"), true);
       ISlicer slicer = workbook.getSlicerCaches().add(table, "Category")
           .getSlicers().add(worksheet, "categorySlicer", "Category", 20, 20, 120, 160);
       slicer.setRowHeight(100.0);
       
      Parameters:
      value - The height, in points, of each row in the slicer.
    • getSlicerCache

      ISlicerCache getSlicerCache()
      Gets the ISlicerCache object associated with the slicer.

      The returned slicer cache contains the shared filtering data and settings that the slicer uses.

      
       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);
       ISlicer slicer = workbook.getSlicerCaches().add(table, "Category")
           .getSlicers().add(worksheet, "categorySlicer", "Category", 30, 100, 120, 160);
       ISlicerCache slicerCache = slicer.getSlicerCache();
       
      Returns:
      The ISlicerCache object associated with the slicer.
    • getShape

      IShape getShape()
      Gets the IShape object associated with the slicer.

      Use the returned shape to access drawing-level properties of the slicer, such as its position, size, and other shape settings on the worksheet.

      
       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);
       ISlicer slicer = workbook.getSlicerCaches().add(table, "Category")
           .getSlicers().add(worksheet, "categorySlicer", "Category", 30, 100, 120, 160);
       IShape shape = slicer.getShape();
       
      Returns:
      The IShape object associated with the slicer.
    • getTop

      double getTop()
      Gets the vertical position of the specified slicer, in points, relative to the upper-left corner of cell A1 on a worksheet.

      Use this property to determine the slicer's current top offset on its worksheet.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Category", "Value"},
           {"Beverages", 100},
           {"Snacks", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ISlicer slicer = workbook.getSlicerCaches().add(table, "Category")
           .getSlicers().add(worksheet, "categorySlicer", "Category", 30, 100, 120, 160);
       double top = slicer.getTop();
       
      Returns:
      The vertical position of the slicer, in points, relative to the upper-left corner of cell A1 on the worksheet.
    • setTop

      void setTop(double value)
      Sets the vertical position of the specified slicer, in points, relative to the upper-left corner of cell A1 on a worksheet.

      Use this property to set the slicer's current top offset on its worksheet.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Category", "Value"},
           {"Beverages", 100},
           {"Snacks", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ISlicer slicer = workbook.getSlicerCaches().add(table, "Category")
           .getSlicers().add(worksheet, "categorySlicer", "Category", 30, 100, 120, 160);
       slicer.setTop(100.0);
       
      Parameters:
      value - The vertical position of the slicer, in points, relative to the upper-left corner of cell A1 on the worksheet.
    • getWidth

      double getWidth()
      Gets the width of the specified slicer, in points.

      Use this method to retrieve the current horizontal size of the slicer on the worksheet.

      
       worksheet.getRange("A1:A3").setValue(new Object[][] {
           {"Category"},
           {"Fruit"},
           {"Vegetables"}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:A3"), true);
       ISlicerCache cache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       ISlicer slicer = cache.getSlicers().add(worksheet, "categorySlicer", "Category", 30, 30, 120, 160);
       double width = slicer.getWidth();
       
      Returns:
      The width of the slicer, in points.
    • setWidth

      void setWidth(double value)
      Sets the width of the specified slicer, in points.

      Use this method to set the horizontal size of the slicer on the worksheet.

      
       worksheet.getRange("A1:A3").setValue(new Object[][] {
           {"Category"},
           {"Fruit"},
           {"Vegetables"}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:A3"), true);
       ISlicerCache cache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
       ISlicer slicer = cache.getSlicers().add(worksheet, "categorySlicer", "Category", 30, 30, 120, 160);
       slicer.setWidth(100.0);
       
      Parameters:
      value - The width of the slicer, in points.
    • delete

      void delete()
      Deletes the slicer and removes it from the associated ISlicers 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");
       ISlicer slicer = cache.getSlicers().add(worksheet, "categorySlicer", "Category", 30, 100, 120, 160);
       slicer.delete();
       
    • getStyle

      ITableStyle getStyle()
      Gets the style currently applied to the specified slicer.

      Use this method to retrieve the ITableStyle that controls the slicer's current appearance.

      
       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);
       ISlicer slicer = workbook.getSlicerCaches().add(table, "Category", "categoryCache")
           .getSlicers().add(worksheet, "categorySlicer", "Category", 30, 100, 120, 160);
       ITableStyle style = slicer.getStyle();
       
      Returns:
      The ITableStyle currently applied to the slicer.
    • setStyle

      void setStyle(ITableStyle value)
      Sets the style applied to the slicer.

      Use this method to apply a slicer style from the workbook's ITableStyleCollection. Passing null clears the current slicer style.

      
       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");
       ISlicer slicer = slicerCache.getSlicers().add(worksheet, "categorySlicer", "Category", 20, 20, 120, 160);
       ITableStyle style = workbook.getTableStyles().get("SlicerStyleLight2");
       slicer.setStyle(style);
       
      Parameters:
      value - The slicer style to apply. Must be a valid slicer style from the workbook; null clears the current style.
      Throws:
      IllegalArgumentException - if value is not a valid slicer style.
    • fromJson

      void fromJson(String json)
      Updates the slicer settings from the specified JSON string.

      Use this method to apply slicer settings that were generated by toJson() to an existing slicer.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Name", "Value"},
           {"A", 100},
           {"B", 200},
           {"C", 300}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B4"), true);
       ISlicerCache cache = workbook.getSlicerCaches().add(table, "Name");
       ISlicer slicer = cache.getSlicers().add(worksheet, "Slicer1", "Name", 20, 20, 120, 180);
       String json = "{\"name\":\"Slicer1\",\"x\":26.666666666666668,\"y\":26.666666666666668,\"width\":160,\"height\":240.00000000000003,\"startRow\":1,\"startColumn\":0,\"endRow\":13,\"endColumn\":2,\"startRowOffset\":6.666666666666667,\"startColumnOffset\":26.666666666666668,\"endRowOffset\":6.666666666666667,\"endColumnOffset\":58.666666666666664,\"dynamicMove\":false,\"dynamicSize\":false,\"nameInFormula\":\"Slicer_Name\",\"slicerCacheName\":\"Slicer_Name\",\"allowResize\":true,\"allowMove\":true,\"isVisible\":true,\"isSelected\":false,\"multiSelect\":false,\"isLocked\":true,\"disableResizingAndMoving\":false,\"type\":\"table\",\"captionName\":\"Name\",\"columnCount\":1,\"itemHeight\":19.666666666666668,\"showHeader\":true,\"style\":\"SlicerStyleLight1\"}";
       slicer.fromJson(json);
       
      Parameters:
      json - The JSON string that contains slicer settings.
    • toJson

      String toJson()
      Generates a JSON string from this slicer.

      Use this method to serialize the current slicer settings so that they can be applied later by using fromJson(String).

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Name", "Value"},
           {"A", 100},
           {"B", 200},
           {"C", 300}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B4"), true);
       ISlicerCache cache = workbook.getSlicerCaches().add(table, "Name");
       ISlicer slicer = cache.getSlicers().add(worksheet, "Slicer1", "Name", 20, 20, 120, 180);
       String json = slicer.toJson();
       
      Returns:
      A JSON string that contains the current slicer settings.