Slicer
Inheritance: java.lang.Object
public class Slicer
summary description of Slicer View
Example
Workbook book = new Workbook();
Worksheet sheet = book.getWorksheets().get(0);
Cells cells = sheet.getCells();
cells.get(0, 0).setValue("fruit");
cells.get(1, 0).setValue("grape");
cells.get(2, 0).setValue("blueberry");
cells.get(3, 0).setValue("kiwi");
cells.get(4, 0).setValue("cherry");
cells.get(5, 0).setValue("grape");
cells.get(6, 0).setValue("blueberry");
cells.get(7, 0).setValue("kiwi");
cells.get(8, 0).setValue("cherry");
cells.get(0, 1).setValue("year");
cells.get(1, 1).setValue(2020);
cells.get(2, 1).setValue(2020);
cells.get(3, 1).setValue(2020);
cells.get(4, 1).setValue(2020);
cells.get(5, 1).setValue(2021);
cells.get(6, 1).setValue(2021);
cells.get(7, 1).setValue(2021);
cells.get(8, 1).setValue(2021);
cells.get(0, 2).setValue("amount");
cells.get(1, 2).setValue(50);
cells.get(2, 2).setValue(60);
cells.get(3, 2).setValue(70);
cells.get(4, 2).setValue(80);
cells.get(5, 2).setValue(90);
cells.get(6, 2).setValue(100);
cells.get(7, 2).setValue(110);
cells.get(8, 2).setValue(120);
PivotTableCollection pivots = sheet.getPivotTables();
int pivotIndex = pivots.add("=Sheet1!A1:C9", "A12", "TestPivotTable");
PivotTable pivot = pivots.get(pivotIndex);
pivot.addFieldToArea(PivotFieldType.ROW, "fruit");
pivot.addFieldToArea(PivotFieldType.COLUMN, "year");
pivot.addFieldToArea(PivotFieldType.DATA, "amount");
pivot.setPivotTableStyleType(PivotTableStyleType.PIVOT_TABLE_STYLE_MEDIUM_10);
pivot.refreshData();
pivot.calculateData();
SlicerCollection slicers = sheet.getSlicers();
int slicerIndex = slicers.add(pivot, "E12", "fruit");
Slicer slicer = slicers.get(slicerIndex);
slicer.setStyleType(SlicerStyleType.SLICER_STYLE_LIGHT_2);
SlicerCacheItemCollection items = slicer.getSlicerCache().getSlicerCacheItems();
SlicerCacheItem item = items.get(0);
item.setSelected(false);
//do your business
book.save("out.xlsx");
Methods
Method | Description |
---|---|
addPivotConnection(PivotTable pivot) | Adds PivotTable connection. |
equals(Object arg0) | |
getAlternativeText() | Returns or sets the descriptive (alternative) text string of the Slicer object. |
getCaption() | Returns or sets the caption of the specified slicer. |
getCaptionVisible() | Returns or sets whether the header that displays the slicer Caption is visible the default value is true |
getClass() | |
getColumnWidth() | Returns or sets the width, in points, of each column in the slicer. |
getColumnWidthPixel() | Gets the width in unit of\u807dpixels for\u807deach column of\u807dthe slicer.\u807d |
getHeight() | Returns or sets the height of the specified slicer, in points. |
getHeightPixel() | Returns or sets the height of the specified slicer, in pixels. |
getLeftPixel() | Returns or sets the horizontal offset of slicer shape from its left column, in pixels. |
getLockedAspectRatio() | Indicates whether locking aspect ratio. |
getLockedPosition() | Indicates whether the specified slicer can be moved or resized by using the user interface. |
getName() | Returns or sets the name of the specified slicer |
getNumberOfColumns() | Returns or sets the number of columns in the specified slicer. |
getParent() | Returns the Range.getWorksheet() object which contains this slicer. |
getPlacement() | Represents the way the drawing object is attached to the cells below it. |
getRowHeight() | Returns or sets the height, in points, of each row in the specified slicer. |
getRowHeightPixel() | Returns or sets the height, in pixels, of each row in the specified slicer. |
getSlicerCache() | Returns the SlicerCache object associated with the slicer. |
getStyleType() | Specify the type of Built-in slicer style the default type is SlicerStyleLight1 |
getTitle() | Specifies the title of the current Slicer object. |
getTopPixel() | Returns or sets the vertical offset of slicer shape from its top row, in pixels. |
getWidth() | Returns or sets the width of the specified slicer, in points. |
getWidthPixel() | Returns or sets the width of the specified slicer, in pixels. |
hashCode() | |
isLocked() | Indicates whether the slicer shape is locked. |
isPrintable() | Indicates whether the slicer object is printable. |
notify() | |
notifyAll() | |
refresh() | Refreshing the slicer.Meanwhile, Refreshing and Calculating relative PivotTables. |
removePivotConnection(PivotTable pivot) | Removes PivotTable connection. |
setAlternativeText(String value) | Returns or sets the descriptive (alternative) text string of the Slicer object. |
setCaption(String value) | Returns or sets the caption of the specified slicer. |
setCaptionVisible(boolean value) | Returns or sets whether the header that displays the slicer Caption is visible the default value is true |
setColumnWidth(double value) | Returns or sets the width, in points, of each column in the slicer. |
setColumnWidthPixel(int value) | Sets the width in unit of\u807dpixels for\u807deach column of\u807dthe slicer.\u807d |
setHeight(double value) | Returns or sets the height of the specified slicer, in points. |
setHeightPixel(int value) | Returns or sets the height of the specified slicer, in pixels. |
setLeftPixel(int value) | Returns or sets the horizontal offset of slicer shape from its left column, in pixels. |
setLocked(boolean value) | Indicates whether the slicer shape is locked. |
setLockedAspectRatio(boolean value) | Indicates whether locking aspect ratio. |
setLockedPosition(boolean value) | Indicates whether the specified slicer can be moved or resized by using the user interface. |
setName(String value) | Returns or sets the name of the specified slicer |
setNumberOfColumns(int value) | Returns or sets the number of columns in the specified slicer. |
setPlacement(int value) | Represents the way the drawing object is attached to the cells below it. |
setPrintable(boolean value) | Indicates whether the slicer object is printable. |
setRowHeight(double value) | Returns or sets the height, in points, of each row in the specified slicer. |
setRowHeightPixel(int value) | Returns or sets the height, in pixels, of each row in the specified slicer. |
setStyleType(int value) | Specify the type of Built-in slicer style the default type is SlicerStyleLight1 |
setTitle(String value) | Specifies the title of the current Slicer object. |
setTopPixel(int value) | Returns or sets the vertical offset of slicer shape from its top row, in pixels. |
setWidth(double value) | Returns or sets the width of the specified slicer, in points. |
setWidthPixel(int value) | Returns or sets the width of the specified slicer, in pixels. |
toString() | |
wait() | |
wait(long arg0) | |
wait(long arg0, int arg1) |
addPivotConnection(PivotTable pivot)
public void addPivotConnection(PivotTable pivot)
Adds PivotTable connection.
Example
slicer.addPivotConnection(pivot);
Parameters:
Parameter | Type | Description |
---|---|---|
pivot | PivotTable | The PivotTable object |
equals(Object arg0)
public boolean equals(Object arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | java.lang.Object |
Returns: boolean
getAlternativeText()
public String getAlternativeText()
Returns or sets the descriptive (alternative) text string of the Slicer object.
Example
slicer.setAlternativeText("AlternativeText test");
Returns: java.lang.String
getCaption()
public String getCaption()
Returns or sets the caption of the specified slicer.
Example
slicer.setCaption("slicer caption");
Returns: java.lang.String
getCaptionVisible()
public boolean getCaptionVisible()
Returns or sets whether the header that displays the slicer Caption is visible the default value is true
Example
slicer.setCaptionVisible(true);
Returns: boolean
getClass()
public final native Class<?> getClass()
Returns: java.lang.Class
getColumnWidth()
public double getColumnWidth()
Returns or sets the width, in points, of each column in the slicer.
Example
slicer.setColumnWidth(80);
Returns: double
getColumnWidthPixel()
public int getColumnWidthPixel()
Gets the width in unit of\u807dpixels for\u807deach column of\u807dthe slicer.\u807d
Example
slicer.setColumnWidthPixel(120);
Returns: int
getHeight()
public double getHeight()
Returns or sets the height of the specified slicer, in points.
Example
slicer.setHeight(120);
Returns: double
getHeightPixel()
public int getHeightPixel()
Returns or sets the height of the specified slicer, in pixels.
Example
slicer.setHeightPixel(150);
Returns: int
getLeftPixel()
public int getLeftPixel()
Returns or sets the horizontal offset of slicer shape from its left column, in pixels.
Example
slicer.setLeftPixel(2);
Returns: int
getLockedAspectRatio()
public boolean getLockedAspectRatio()
Indicates whether locking aspect ratio.
Example
slicer.setLockedAspectRatio(true);
Returns: boolean
getLockedPosition()
public boolean getLockedPosition()
Indicates whether the specified slicer can be moved or resized by using the user interface.
Example
slicer.setLockedPosition(false);
Returns: boolean
getName()
public String getName()
Returns or sets the name of the specified slicer
Example
slicer.setName("slicer name");
Returns: java.lang.String
getNumberOfColumns()
public int getNumberOfColumns()
Returns or sets the number of columns in the specified slicer.
Example
slicer.setNumberOfColumns(1);
Returns: int
getParent()
public Worksheet getParent()
Returns the Range.getWorksheet() object which contains this slicer. Read-only.
Example
Worksheet currSheet = slicer.getParent();
Returns: Worksheet
getPlacement()
public int getPlacement()
Represents the way the drawing object is attached to the cells below it. The property controls the placement of an object on a worksheet.
See PlacementType.
Example
slicer.setPlacement(PlacementType.FREE_FLOATING);
Returns: int
getRowHeight()
public double getRowHeight()
Returns or sets the height, in points, of each row in the specified slicer.
Example
slicer.setRowHeight(20);
Returns: double
getRowHeightPixel()
public int getRowHeightPixel()
Returns or sets the height, in pixels, of each row in the specified slicer.
Example
slicer.setRowHeightPixel(30);
Returns: int
getSlicerCache()
public SlicerCache getSlicerCache()
Returns the SlicerCache object associated with the slicer. Read-only.
Example
SlicerCache slicerCache = slicer.getSlicerCache();
Returns: SlicerCache
getStyleType()
public int getStyleType()
Specify the type of Built-in slicer style the default type is SlicerStyleLight1
See SlicerStyleType.
Example
slicer.setStyleType(SlicerStyleType.SLICER_STYLE_LIGHT_2);
Returns: int
getTitle()
public String getTitle()
Specifies the title of the current Slicer object.
Example
slicer.setTitle("slicer title");
Returns: java.lang.String
getTopPixel()
public int getTopPixel()
Returns or sets the vertical offset of slicer shape from its top row, in pixels.
Example
slicer.setTopPixel(6);
Returns: int
getWidth()
public double getWidth()
Returns or sets the width of the specified slicer, in points.
Example
slicer.setWidth(100);
Returns: double
getWidthPixel()
public int getWidthPixel()
Returns or sets the width of the specified slicer, in pixels.
Example
slicer.setWidthPixel(120);
Returns: int
hashCode()
public native int hashCode()
Returns: int
isLocked()
public boolean isLocked()
Indicates whether the slicer shape is locked.
Example
slicer.setLocked(false);
Returns: boolean
isPrintable()
public boolean isPrintable()
Indicates whether the slicer object is printable.
Example
slicer.setPrintable(true);
Returns: boolean
notify()
public final native void notify()
notifyAll()
public final native void notifyAll()
refresh()
public void refresh()
Refreshing the slicer.Meanwhile, Refreshing and Calculating relative PivotTables.
Example
slicer.refresh();
removePivotConnection(PivotTable pivot)
public void removePivotConnection(PivotTable pivot)
Removes PivotTable connection.
Example
slicer.removePivotConnection(pivot);
Parameters:
Parameter | Type | Description |
---|---|---|
pivot | PivotTable | The PivotTable object |
setAlternativeText(String value)
public void setAlternativeText(String value)
Returns or sets the descriptive (alternative) text string of the Slicer object.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String |
setCaption(String value)
public void setCaption(String value)
Returns or sets the caption of the specified slicer.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String |
setCaptionVisible(boolean value)
public void setCaptionVisible(boolean value)
Returns or sets whether the header that displays the slicer Caption is visible the default value is true
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setColumnWidth(double value)
public void setColumnWidth(double value)
Returns or sets the width, in points, of each column in the slicer.
Parameters:
Parameter | Type | Description |
---|---|---|
value | double |
setColumnWidthPixel(int value)
public void setColumnWidthPixel(int value)
Sets the width in unit of\u807dpixels for\u807deach column of\u807dthe slicer.\u807d
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setHeight(double value)
public void setHeight(double value)
Returns or sets the height of the specified slicer, in points.
Parameters:
Parameter | Type | Description |
---|---|---|
value | double |
setHeightPixel(int value)
public void setHeightPixel(int value)
Returns or sets the height of the specified slicer, in pixels.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setLeftPixel(int value)
public void setLeftPixel(int value)
Returns or sets the horizontal offset of slicer shape from its left column, in pixels.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setLocked(boolean value)
public void setLocked(boolean value)
Indicates whether the slicer shape is locked.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setLockedAspectRatio(boolean value)
public void setLockedAspectRatio(boolean value)
Indicates whether locking aspect ratio.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setLockedPosition(boolean value)
public void setLockedPosition(boolean value)
Indicates whether the specified slicer can be moved or resized by using the user interface.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setName(String value)
public void setName(String value)
Returns or sets the name of the specified slicer
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String |
setNumberOfColumns(int value)
public void setNumberOfColumns(int value)
Returns or sets the number of columns in the specified slicer.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setPlacement(int value)
public void setPlacement(int value)
Represents the way the drawing object is attached to the cells below it. The property controls the placement of an object on a worksheet.
See PlacementType.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setPrintable(boolean value)
public void setPrintable(boolean value)
Indicates whether the slicer object is printable.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setRowHeight(double value)
public void setRowHeight(double value)
Returns or sets the height, in points, of each row in the specified slicer.
Parameters:
Parameter | Type | Description |
---|---|---|
value | double |
setRowHeightPixel(int value)
public void setRowHeightPixel(int value)
Returns or sets the height, in pixels, of each row in the specified slicer.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setStyleType(int value)
public void setStyleType(int value)
Specify the type of Built-in slicer style the default type is SlicerStyleLight1
See SlicerStyleType.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setTitle(String value)
public void setTitle(String value)
Specifies the title of the current Slicer object.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String |
setTopPixel(int value)
public void setTopPixel(int value)
Returns or sets the vertical offset of slicer shape from its top row, in pixels.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setWidth(double value)
public void setWidth(double value)
Returns or sets the width of the specified slicer, in points.
Parameters:
Parameter | Type | Description |
---|---|---|
value | double |
setWidthPixel(int value)
public void setWidthPixel(int value)
Returns or sets the width of the specified slicer, in pixels.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
toString()
public String toString()
Returns: java.lang.String
wait()
public final void wait()
wait(long arg0)
public final native void wait(long arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long |
wait(long arg0, int arg1)
public final void wait(long arg0, int arg1)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long | |
arg1 | int |