java.lang.Object
com.aspose.cells.Slicer
public class Slicer
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");
| Property Getters/Setters Summary | ||
|---|---|---|
java.lang.String | getAlternativeText() | |
void | setAlternativeText(java.lang.String) | |
| Returns or sets the descriptive (alternative) text string of the Slicer object. | ||
java.lang.String | getCaption() | |
void | setCaption(java.lang.String) | |
| Returns or sets the caption of the specified slicer. | ||
boolean | getCaptionVisible() | |
void | setCaptionVisible(boolean) | |
| Returns or sets whether the header that displays the slicer Caption is visible the default value is true | ||
double | getColumnWidth() | |
void | setColumnWidth(double) | |
| Returns or sets the width, in points, of each column in the slicer. | ||
int | getColumnWidthPixel() | |
void | setColumnWidthPixel(int) | |
| Gets or sets the width in unit of pixels for each column of the slicer. | ||
double | getHeight() | |
void | setHeight(double) | |
| Returns or sets the height of the specified slicer, in points. | ||
int | getHeightPixel() | |
void | setHeightPixel(int) | |
| Returns or sets the height of the specified slicer, in pixels. | ||
boolean | isLocked() | |
void | setLocked(boolean) | |
| Indicates whether the slicer shape is locked. | ||
boolean | isPrintable() | |
void | setPrintable(boolean) | |
| Indicates whether the slicer object is printable. | ||
int | getLeftPixel() | |
void | setLeftPixel(int) | |
| Returns or sets the horizontal offset of slicer shape from its left column, in pixels. | ||
boolean | getLockedAspectRatio() | |
void | setLockedAspectRatio(boolean) | |
| Indicates whether locking aspect ratio. | ||
boolean | getLockedPosition() | |
void | setLockedPosition(boolean) | |
| Indicates whether the specified slicer can be moved or resized by using the user interface. | ||
java.lang.String | getName() | |
void | setName(java.lang.String) | |
| Returns or sets the name of the specified slicer | ||
int | getNumberOfColumns() | |
void | setNumberOfColumns(int) | |
| Returns or sets the number of columns in the specified slicer. | ||
Worksheet | getParent() | |
| Returns the Worksheet object that represents the sheet that contains the slicer. Read-only. | ||
int | getPlacement() | |
void | setPlacement(int) | |
| Represents the way the drawing object is attached to the cells below it. The property controls the placement of an object on a worksheet. The value of the property is PlacementType integer constant. | ||
double | getRowHeight() | |
void | setRowHeight(double) | |
| Returns or sets the height, in points, of each row in the specified slicer. | ||
int | getRowHeightPixel() | |
void | setRowHeightPixel(int) | |
| Returns or sets the height, in pixels, of each row in the specified slicer. | ||
SlicerCache | getSlicerCache() | |
| Returns the SlicerCache object associated with the slicer. Read-only. | ||
int | getStyleType() | |
void | setStyleType(int) | |
| Specify the type of Built-in slicer style the default type is SlicerStyleLight1 The value of the property is SlicerStyleType integer constant. | ||
java.lang.String | getTitle() | |
void | setTitle(java.lang.String) | |
| Specifies the title of the current Slicer object. | ||
int | getTopPixel() | |
void | setTopPixel(int) | |
| Returns or sets the vertical offset of slicer shape from its top row, in pixels. | ||
double | getWidth() | |
void | setWidth(double) | |
| Returns or sets the width of the specified slicer, in points. | ||
int | getWidthPixel() | |
void | setWidthPixel(int) | |
| Returns or sets the width of the specified slicer, in pixels. | ||
| Method Summary | ||
|---|---|---|
void | addPivotConnection(PivotTable pivot) | |
| Adds PivotTable connection. | ||
void | refresh() | |
| Refreshing the slicer.Meanwhile, Refreshing and Calculating relative PivotTables. | ||
void | removePivotConnection(PivotTable pivot) | |
| Removes PivotTable connection. | ||
| Property Getters/Setters Detail |
|---|
getTitle/setTitle | |
public java.lang.String getTitle() / public void setTitle(java.lang.String value) | |
Example:
slicer.setTitle("slicer title");getAlternativeText/setAlternativeText | |
public java.lang.String getAlternativeText() / public void setAlternativeText(java.lang.String value) | |
Example:
slicer.setAlternativeText("AlternativeText test");isPrintable/setPrintable | |
public boolean isPrintable() / public void setPrintable(boolean value) | |
Example:
slicer.setPrintable(true);
isLocked/setLocked | |
public boolean isLocked() / public void setLocked(boolean value) | |
Example:
slicer.setLocked(false);
getPlacement/setPlacement | |
public int getPlacement() / public void setPlacement(int value) | |
Example:
slicer.setPlacement(PlacementType.FREE_FLOATING);
getLockedAspectRatio/setLockedAspectRatio | |
public boolean getLockedAspectRatio() / public void setLockedAspectRatio(boolean value) | |
Example:
slicer.setLockedAspectRatio(true);
getLockedPosition/setLockedPosition | |
public boolean getLockedPosition() / public void setLockedPosition(boolean value) | |
Example:
slicer.setLockedPosition(false);
getSlicerCache | |
public SlicerCache getSlicerCache() | |
Example:
SlicerCache slicerCache = slicer.getSlicerCache();
getParent | |
public Worksheet getParent() | |
Example:
Worksheet currSheet = slicer.getParent();
getStyleType/setStyleType | |
public int getStyleType() / public void setStyleType(int value) | |
Example:
slicer.setStyleType(SlicerStyleType.SLICER_STYLE_LIGHT_2);
getName/setName | |
public java.lang.String getName() / public void setName(java.lang.String value) | |
Example:
slicer.setName("slicer name");getCaption/setCaption | |
public java.lang.String getCaption() / public void setCaption(java.lang.String value) | |
Example:
slicer.setCaption("slicer caption");getCaptionVisible/setCaptionVisible | |
public boolean getCaptionVisible() / public void setCaptionVisible(boolean value) | |
Example:
slicer.setCaptionVisible(true);
getNumberOfColumns/setNumberOfColumns | |
public int getNumberOfColumns() / public void setNumberOfColumns(int value) | |
Example:
slicer.setNumberOfColumns(1);
getLeftPixel/setLeftPixel | |
public int getLeftPixel() / public void setLeftPixel(int value) | |
Example:
slicer.setLeftPixel(2);
getTopPixel/setTopPixel | |
public int getTopPixel() / public void setTopPixel(int value) | |
Example:
slicer.setTopPixel(6);
getWidth/setWidth | |
public double getWidth() / public void setWidth(double value) | |
Example:
slicer.setWidth(100);
getWidthPixel/setWidthPixel | |
public int getWidthPixel() / public void setWidthPixel(int value) | |
Example:
slicer.setWidthPixel(120);
getHeight/setHeight | |
public double getHeight() / public void setHeight(double value) | |
Example:
slicer.setHeight(120);
getHeightPixel/setHeightPixel | |
public int getHeightPixel() / public void setHeightPixel(int value) | |
Example:
slicer.setHeightPixel(150);
getColumnWidthPixel/setColumnWidthPixel | |
public int getColumnWidthPixel() / public void setColumnWidthPixel(int value) | |
Example:
slicer.setColumnWidthPixel(120);
getColumnWidth/setColumnWidth | |
public double getColumnWidth() / public void setColumnWidth(double value) | |
Example:
slicer.setColumnWidth(80);
getRowHeightPixel/setRowHeightPixel | |
public int getRowHeightPixel() / public void setRowHeightPixel(int value) | |
Example:
slicer.setRowHeightPixel(30);
getRowHeight/setRowHeight | |
public double getRowHeight() / public void setRowHeight(double value) | |
Example:
slicer.setRowHeight(20);
| Method Detail |
|---|
addPivotConnection | |
public void addPivotConnection(PivotTable pivot) | |
pivot - The PivotTable objectExample:
slicer.addPivotConnection(pivot);
removePivotConnection | |
public void removePivotConnection(PivotTable pivot) | |
pivot - The PivotTable objectExample:
slicer.removePivotConnection(pivot);
refresh | |
public void refresh()
throws java.lang.Exception | |
Example:
slicer.refresh();