public class Slicer
extends java.lang.Object
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");
| Modifier and Type | Method and Description |
|---|---|
void |
addPivotConnection(PivotTable pivot)
Adds PivotTable connection.
|
java.lang.String |
getAlternativeText()
Returns or sets the descriptive (alternative) text string of the Slicer object.
|
java.lang.String |
getCaption()
Returns or sets the caption of the specified slicer.
|
boolean |
getCaptionVisible()
Returns or sets whether the header that displays the slicer Caption is visible
the default value is true
|
double |
getColumnWidth()
Returns or sets the width, in points, of each column in the slicer.
|
int |
getColumnWidthPixel()
Gets the width of聽each column in聽the slicer, in unit of聽pixels.聽
|
double |
getHeight()
Deprecated.
Use Shape.HeightPt property instead.
|
int |
getHeightPixel()
Deprecated.
Use Shape.Height property instead.
|
int |
getLeftPixel()
Deprecated.
Use Shape.Left property instead.
|
boolean |
getLockedAspectRatio()
Indicates whether locking aspect ratio.
|
boolean |
getLockedPosition()
Indicates whether the specified slicer can be moved or resized by using the user interface.
|
java.lang.String |
getName()
Returns or sets the name of the specified slicer
|
int |
getNumberOfColumns()
Returns or sets the number of columns in the specified slicer.
|
Worksheet |
getParent()
Returns the
Range.getWorksheet() object which contains this slicer. |
int |
getPlacement()
Represents the way the drawing object is attached to the cells below it.
|
double |
getRowHeight()
Returns or sets the height, in points, of each row in the specified slicer.
|
int |
getRowHeightPixel()
Returns or sets the height, in pixels, of each row in the specified slicer.
|
SlicerShape |
getShape()
Returns the Shape object associated with the specified slicer.
|
SlicerCache |
getSlicerCache()
Returns the SlicerCache object associated with the slicer.
|
int |
getStyleType()
Specify the type of Built-in slicer style
the default type is SlicerStyleLight1
|
java.lang.String |
getTitle()
Specifies the title of the current Slicer object.
|
int |
getTopPixel()
Deprecated.
Use Shape.Top property instead.
|
double |
getWidth()
Deprecated.
Use Shape.WidthPt property instead.
|
int |
getWidthPixel()
Deprecated.
Use Shape.Width property instead.
|
boolean |
isLocked()
Indicates whether the slicer shape is locked.
|
boolean |
isPrintable()
Indicates whether the slicer object is printable.
|
void |
refresh()
Refreshing the slicer.Meanwhile, Refreshing and Calculating relative PivotTables.
|
void |
removePivotConnection(PivotTable pivot)
Removes PivotTable connection.
|
void |
setAlternativeText(java.lang.String value)
Returns or sets the descriptive (alternative) text string of the Slicer object.
|
void |
setCaption(java.lang.String value)
Returns or sets the caption of the specified slicer.
|
void |
setCaptionVisible(boolean value)
Returns or sets whether the header that displays the slicer Caption is visible
the default value is true
|
void |
setColumnWidth(double value)
Returns or sets the width, in points, of each column in the slicer.
|
void |
setColumnWidthPixel(int value)
Sets the width of聽each column in聽the slicer, in unit of聽pixels.聽
|
void |
setHeight(double value)
Deprecated.
Use Shape.HeightPt property instead.
|
void |
setHeightPixel(int value)
Deprecated.
Use Shape.Height property instead.
|
void |
setLeftPixel(int value)
Deprecated.
Use Shape.Left property instead.
|
void |
setLocked(boolean value)
Indicates whether the slicer shape is locked.
|
void |
setLockedAspectRatio(boolean value)
Indicates whether locking aspect ratio.
|
void |
setLockedPosition(boolean value)
Indicates whether the specified slicer can be moved or resized by using the user interface.
|
void |
setName(java.lang.String value)
Returns or sets the name of the specified slicer
|
void |
setNumberOfColumns(int value)
Returns or sets the number of columns in the specified slicer.
|
void |
setPlacement(int value)
Represents the way the drawing object is attached to the cells below it.
|
void |
setPrintable(boolean value)
Indicates whether the slicer object is printable.
|
void |
setRowHeight(double value)
Returns or sets the height, in points, of each row in the specified slicer.
|
void |
setRowHeightPixel(int value)
Returns or sets the height, in pixels, of each row in the specified slicer.
|
void |
setStyleType(int value)
Specify the type of Built-in slicer style
the default type is SlicerStyleLight1
|
void |
setTitle(java.lang.String value)
Specifies the title of the current Slicer object.
|
void |
setTopPixel(int value)
Deprecated.
Use Shape.Top property instead.
|
void |
setWidth(double value)
Deprecated.
Use Shape.WidthPt property instead.
|
void |
setWidthPixel(int value)
Deprecated.
Use Shape.Width property instead.
|
public void addPivotConnection(PivotTable pivot)
Example
slicer.addPivotConnection(pivot);
pivot - The PivotTable objectpublic void removePivotConnection(PivotTable pivot)
Example
slicer.removePivotConnection(pivot);
pivot - The PivotTable objectpublic java.lang.String getTitle()
Example
slicer.setTitle("slicer title");
public void setTitle(java.lang.String value)
public java.lang.String getAlternativeText()
Example
slicer.setAlternativeText("AlternativeText test");
public void setAlternativeText(java.lang.String value)
public boolean isPrintable()
Example
slicer.setPrintable(true);
public void setPrintable(boolean value)
public boolean isLocked()
Example
slicer.setLocked(false);
public void setLocked(boolean value)
public int getPlacement()
See PlacementType.
Example
slicer.setPlacement(PlacementType.FREE_FLOATING);
public void setPlacement(int value)
See PlacementType.
public boolean getLockedAspectRatio()
Example
slicer.setLockedAspectRatio(true);
public void setLockedAspectRatio(boolean value)
public boolean getLockedPosition()
Example
slicer.setLockedPosition(false);
public void setLockedPosition(boolean value)
public void refresh()
Example
slicer.refresh();
public SlicerShape getShape()
public SlicerCache getSlicerCache()
Example
SlicerCache slicerCache = slicer.getSlicerCache();
public Worksheet getParent()
Range.getWorksheet() object which contains this slicer. Read-only.
Example
Worksheet currSheet = slicer.getParent();
public int getStyleType()
See SlicerStyleType.
Example
slicer.setStyleType(SlicerStyleType.SLICER_STYLE_LIGHT_2);
public void setStyleType(int value)
See SlicerStyleType.
public java.lang.String getName()
Example
slicer.setName("slicer name");
public void setName(java.lang.String value)
public java.lang.String getCaption()
Example
slicer.setCaption("slicer caption");
public void setCaption(java.lang.String value)
public boolean getCaptionVisible()
Example
slicer.setCaptionVisible(true);
public void setCaptionVisible(boolean value)
public int getNumberOfColumns()
Example
slicer.setNumberOfColumns(1);
public void setNumberOfColumns(int value)
public int getLeftPixel()
Remarks
NOTE: This member is now obsolete. Instead, please use Shape.Left property. This property will be removed 12 months later since May 2025. Aspose apologizes for any inconvenience you may have experienced.Example
slicer.setNumberOfColumns(1);
public void setLeftPixel(int value)
Remarks
NOTE: This member is now obsolete. Instead, please use Shape.Left property. This property will be removed 12 months later since May 2025. Aspose apologizes for any inconvenience you may have experienced.public int getTopPixel()
Remarks
NOTE: This member is now obsolete. Instead, please use Shape.Top property. This property will be removed 12 months later since May 2025. Aspose apologizes for any inconvenience you may have experienced.Example
slicer.setNumberOfColumns(1);
public void setTopPixel(int value)
Remarks
NOTE: This member is now obsolete. Instead, please use Shape.Top property. This property will be removed 12 months later since May 2025. Aspose apologizes for any inconvenience you may have experienced.public double getWidth()
Remarks
NOTE: This member is now obsolete. Instead, please use Shape.WidthPt property. This property will be removed 12 months later since May 2025. Aspose apologizes for any inconvenience you may have experienced.Example
slicer.setNumberOfColumns(1);
public void setWidth(double value)
Remarks
NOTE: This member is now obsolete. Instead, please use Shape.WidthPt property. This property will be removed 12 months later since May 2025. Aspose apologizes for any inconvenience you may have experienced.public int getWidthPixel()
Remarks
NOTE: This member is now obsolete. Instead, please use Shape.Width property. This property will be removed 12 months later since May 2025. Aspose apologizes for any inconvenience you may have experienced.Example
slicer.setNumberOfColumns(1);
public void setWidthPixel(int value)
Remarks
NOTE: This member is now obsolete. Instead, please use Shape.Width property. This property will be removed 12 months later since May 2025. Aspose apologizes for any inconvenience you may have experienced.public double getHeight()
Remarks
NOTE: This member is now obsolete. Instead, please use Shape.HeightPt property. This property will be removed 12 months later since May 2025. Aspose apologizes for any inconvenience you may have experienced.Example
slicer.setNumberOfColumns(1);
public void setHeight(double value)
Remarks
NOTE: This member is now obsolete. Instead, please use Shape.HeightPt property. This property will be removed 12 months later since May 2025. Aspose apologizes for any inconvenience you may have experienced.public int getHeightPixel()
Remarks
NOTE: This member is now obsolete. Instead, please use Shape.Height property. This property will be removed 12 months later since May 2025. Aspose apologizes for any inconvenience you may have experienced.Example
slicer.setNumberOfColumns(1);
public void setHeightPixel(int value)
Remarks
NOTE: This member is now obsolete. Instead, please use Shape.Height property. This property will be removed 12 months later since May 2025. Aspose apologizes for any inconvenience you may have experienced.public int getColumnWidthPixel()
Example
slicer.setColumnWidthPixel(120);
public void setColumnWidthPixel(int value)
public double getColumnWidth()
Example
slicer.setColumnWidth(80);
public void setColumnWidth(double value)
public int getRowHeightPixel()
Example
slicer.setRowHeightPixel(30);
public void setRowHeightPixel(int value)
public double getRowHeight()
Example
slicer.setRowHeight(20);
public void setRowHeight(double value)
See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.