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 in unit of聽pixels for聽each column of聽the slicer.聽
|
double |
getHeight()
Returns or sets the height of the specified slicer, in points.
|
int |
getHeightPixel()
Returns or sets the height of the specified slicer, in pixels.
|
int |
getLeftPixel()
Returns or sets the horizontal offset of slicer shape from its left column, in pixels.
|
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.
|
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()
Returns or sets the vertical offset of slicer shape from its top row, in pixels.
|
double |
getWidth()
Returns or sets the width of the specified slicer, in points.
|
int |
getWidthPixel()
Returns or sets the width of the specified slicer, in pixels.
|
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 in unit of聽pixels for聽each column of聽the slicer.聽
|
void |
setHeight(double value)
Returns or sets the height of the specified slicer, in points.
|
void |
setHeightPixel(int value)
Returns or sets the height of the specified slicer, in pixels.
|
void |
setLeftPixel(int value)
Returns or sets the horizontal offset of slicer shape from its left column, in pixels.
|
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)
Returns or sets the vertical offset of slicer shape from its top row, in pixels.
|
void |
setWidth(double value)
Returns or sets the width of the specified slicer, in points.
|
void |
setWidthPixel(int value)
Returns or sets the width of the specified slicer, in pixels.
|
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 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()
Example
slicer.setLeftPixel(2);
public void setLeftPixel(int value)
public int getTopPixel()
Example
slicer.setTopPixel(6);
public void setTopPixel(int value)
public double getWidth()
Example
slicer.setWidth(100);
public void setWidth(double value)
public int getWidthPixel()
Example
slicer.setWidthPixel(120);
public void setWidthPixel(int value)
public double getHeight()
Example
slicer.setHeight(120);
public void setHeight(double value)
public int getHeightPixel()
Example
slicer.setHeightPixel(150);
public void setHeightPixel(int value)
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 2001-2023. All Rights Reserved.