com.aspose.cells
Class Slicer

java.lang.Object
    extended by com.aspose.cells.Slicer

public class Slicer 
extends java.lang.Object

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");


Property Getters/Setters Summary
java.lang.StringgetAlternativeText()
voidsetAlternativeText(java.lang.String)
           Returns or sets the descriptive (alternative) text string of the Slicer object.
java.lang.StringgetCaption()
voidsetCaption(java.lang.String)
           Returns or sets the caption of the specified slicer.
booleangetCaptionVisible()
voidsetCaptionVisible(boolean)
           Returns or sets whether the header that displays the slicer Caption is visible the default value is true
doublegetColumnWidth()
voidsetColumnWidth(double)
           Returns or sets the width, in points, of each column in the slicer.
intgetColumnWidthPixel()
voidsetColumnWidthPixel(int)
           Gets or sets the width in unit of pixels for each column of the slicer. 
doublegetHeight()
voidsetHeight(double)
           Returns or sets the height of the specified slicer, in points.
intgetHeightPixel()
voidsetHeightPixel(int)
           Returns or sets the height of the specified slicer, in pixels.
booleanisLocked()
voidsetLocked(boolean)
           Indicates whether the slicer shape is locked.
booleanisPrintable()
voidsetPrintable(boolean)
           Indicates whether the slicer object is printable.
intgetLeftPixel()
voidsetLeftPixel(int)
           Returns or sets the horizontal offset of slicer shape from its left column, in pixels.
booleangetLockedAspectRatio()
voidsetLockedAspectRatio(boolean)
           Indicates whether locking aspect ratio.
booleangetLockedPosition()
voidsetLockedPosition(boolean)
           Indicates whether the specified slicer can be moved or resized by using the user interface.
java.lang.StringgetName()
voidsetName(java.lang.String)
           Returns or sets the name of the specified slicer
intgetNumberOfColumns()
voidsetNumberOfColumns(int)
           Returns or sets the number of columns in the specified slicer.
WorksheetgetParent()
           Returns the Worksheet object that represents the sheet that contains the slicer. Read-only.
intgetPlacement()
voidsetPlacement(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.
doublegetRowHeight()
voidsetRowHeight(double)
           Returns or sets the height, in points, of each row in the specified slicer.
intgetRowHeightPixel()
voidsetRowHeightPixel(int)
           Returns or sets the height, in pixels, of each row in the specified slicer.
SlicerCachegetSlicerCache()
           Returns the SlicerCache object associated with the slicer. Read-only.
intgetStyleType()
voidsetStyleType(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.StringgetTitle()
voidsetTitle(java.lang.String)
           Specifies the title of the current Slicer object.
intgetTopPixel()
voidsetTopPixel(int)
           Returns or sets the vertical offset of slicer shape from its top row, in pixels.
doublegetWidth()
voidsetWidth(double)
           Returns or sets the width of the specified slicer, in points.
intgetWidthPixel()
voidsetWidthPixel(int)
           Returns or sets the width of the specified slicer, in pixels.
 
Method Summary
voidaddPivotConnection(PivotTable pivot)
           Adds PivotTable connection.
voidrefresh()
           Refreshing the slicer.Meanwhile, Refreshing and Calculating relative PivotTables.
voidremovePivotConnection(PivotTable pivot)
           Removes PivotTable connection.
 

Property Getters/Setters Detail

getTitle/setTitle

public java.lang.String getTitle() / public void setTitle(java.lang.String value)
Specifies the title of the current Slicer object.

Example:

slicer.setTitle("slicer title");

setTitle

public void setTitle(java.lang.String value)
Specifies the title of the current Slicer object.

Example:

slicer.setTitle("slicer title");

getAlternativeText/setAlternativeText

public java.lang.String getAlternativeText() / public void setAlternativeText(java.lang.String value)
Returns or sets the descriptive (alternative) text string of the Slicer object.

Example:

slicer.setAlternativeText("AlternativeText test");

setAlternativeText

public void setAlternativeText(java.lang.String value)
Returns or sets the descriptive (alternative) text string of the Slicer object.

Example:

slicer.setAlternativeText("AlternativeText test");

isPrintable/setPrintable

public boolean isPrintable() / public void setPrintable(boolean value)
Indicates whether the slicer object is printable.

Example:

slicer.setPrintable(true);

setPrintable

public void setPrintable(boolean value)
Indicates whether the slicer object is printable.

Example:

slicer.setPrintable(true);

isLocked/setLocked

public boolean isLocked() / public void setLocked(boolean value)
Indicates whether the slicer shape is locked.

Example:

slicer.setLocked(false);

setLocked

public void setLocked(boolean value)
Indicates whether the slicer shape is locked.

Example:

slicer.setLocked(false);

getPlacement/setPlacement

public int getPlacement() / 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. The value of the property is PlacementType integer constant.

Example:

slicer.setPlacement(PlacementType.FREE_FLOATING);

setPlacement

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. The value of the property is PlacementType integer constant.

Example:

slicer.setPlacement(PlacementType.FREE_FLOATING);

getLockedAspectRatio/setLockedAspectRatio

public boolean getLockedAspectRatio() / public void setLockedAspectRatio(boolean value)
Indicates whether locking aspect ratio.

Example:

slicer.setLockedAspectRatio(true);

setLockedAspectRatio

public void setLockedAspectRatio(boolean value)
Indicates whether locking aspect ratio.

Example:

slicer.setLockedAspectRatio(true);

getLockedPosition/setLockedPosition

public boolean getLockedPosition() / public void setLockedPosition(boolean value)
Indicates whether the specified slicer can be moved or resized by using the user interface.

Example:

slicer.setLockedPosition(false);

setLockedPosition

public void setLockedPosition(boolean value)
Indicates whether the specified slicer can be moved or resized by using the user interface.

Example:

slicer.setLockedPosition(false);

getSlicerCache

public SlicerCache getSlicerCache()
Returns the SlicerCache object associated with the slicer. Read-only.

Example:

SlicerCache slicerCache = slicer.getSlicerCache();

getParent

public Worksheet getParent()
Returns the Worksheet object that represents the sheet that contains the slicer. Read-only.

Example:

Worksheet currSheet = slicer.getParent();

getStyleType/setStyleType

public int getStyleType() / public void setStyleType(int value)
Specify the type of Built-in slicer style the default type is SlicerStyleLight1 The value of the property is SlicerStyleType integer constant.

Example:

slicer.setStyleType(SlicerStyleType.SLICER_STYLE_LIGHT_2);

setStyleType

public void setStyleType(int value)
Specify the type of Built-in slicer style the default type is SlicerStyleLight1 The value of the property is SlicerStyleType integer constant.

Example:

slicer.setStyleType(SlicerStyleType.SLICER_STYLE_LIGHT_2);

getName/setName

public java.lang.String getName() / public void setName(java.lang.String value)
Returns or sets the name of the specified slicer

Example:

slicer.setName("slicer name");

setName

public void setName(java.lang.String value)
Returns or sets the name of the specified slicer

Example:

slicer.setName("slicer name");

getCaption/setCaption

public java.lang.String getCaption() / public void setCaption(java.lang.String value)
Returns or sets the caption of the specified slicer.

Example:

slicer.setCaption("slicer caption");

setCaption

public void setCaption(java.lang.String value)
Returns or sets the caption of the specified slicer.

Example:

slicer.setCaption("slicer caption");

getCaptionVisible/setCaptionVisible

public boolean getCaptionVisible() / public void setCaptionVisible(boolean value)
Returns or sets whether the header that displays the slicer Caption is visible the default value is true

Example:

slicer.setCaptionVisible(true);

setCaptionVisible

public void setCaptionVisible(boolean value)
Returns or sets whether the header that displays the slicer Caption is visible the default value is true

Example:

slicer.setCaptionVisible(true);

getNumberOfColumns/setNumberOfColumns

public int getNumberOfColumns() / public void setNumberOfColumns(int value)
Returns or sets the number of columns in the specified slicer.

Example:

slicer.setNumberOfColumns(1);

setNumberOfColumns

public void setNumberOfColumns(int value)
Returns or sets the number of columns in the specified slicer.

Example:

slicer.setNumberOfColumns(1);

getLeftPixel/setLeftPixel

public int getLeftPixel() / public void setLeftPixel(int value)
Returns or sets the horizontal offset of slicer shape from its left column, in pixels.

Example:

slicer.setLeftPixel(2);

setLeftPixel

public void setLeftPixel(int value)
Returns or sets the horizontal offset of slicer shape from its left column, in pixels.

Example:

slicer.setLeftPixel(2);

getTopPixel/setTopPixel

public int getTopPixel() / public void setTopPixel(int value)
Returns or sets the vertical offset of slicer shape from its top row, in pixels.

Example:

slicer.setTopPixel(6);

setTopPixel

public void setTopPixel(int value)
Returns or sets the vertical offset of slicer shape from its top row, in pixels.

Example:

slicer.setTopPixel(6);

getWidth/setWidth

public double getWidth() / public void setWidth(double value)
Returns or sets the width of the specified slicer, in points.

Example:

slicer.setWidth(100);

setWidth

public void setWidth(double value)
Returns or sets the width of the specified slicer, in points.

Example:

slicer.setWidth(100);

getWidthPixel/setWidthPixel

public int getWidthPixel() / public void setWidthPixel(int value)
Returns or sets the width of the specified slicer, in pixels.

Example:

slicer.setWidthPixel(120);

setWidthPixel

public void setWidthPixel(int value)
Returns or sets the width of the specified slicer, in pixels.

Example:

slicer.setWidthPixel(120);

getHeight/setHeight

public double getHeight() / public void setHeight(double value)
Returns or sets the height of the specified slicer, in points.

Example:

slicer.setHeight(120);

setHeight

public void setHeight(double value)
Returns or sets the height of the specified slicer, in points.

Example:

slicer.setHeight(120);

getHeightPixel/setHeightPixel

public int getHeightPixel() / public void setHeightPixel(int value)
Returns or sets the height of the specified slicer, in pixels.

Example:

slicer.setHeightPixel(150);

setHeightPixel

public void setHeightPixel(int value)
Returns or sets the height of the specified slicer, in pixels.

Example:

slicer.setHeightPixel(150);

getColumnWidthPixel/setColumnWidthPixel

public int getColumnWidthPixel() / public void setColumnWidthPixel(int value)
Gets or sets the width in unit of pixels for each column of the slicer. 

Example:

slicer.setColumnWidthPixel(120);

setColumnWidthPixel

public void setColumnWidthPixel(int value)
Gets or sets the width in unit of pixels for each column of the slicer. 

Example:

slicer.setColumnWidthPixel(120);

getColumnWidth/setColumnWidth

public double getColumnWidth() / public void setColumnWidth(double value)
Returns or sets the width, in points, of each column in the slicer.

Example:

slicer.setColumnWidth(80);

setColumnWidth

public void setColumnWidth(double value)
Returns or sets the width, in points, of each column in the slicer.

Example:

slicer.setColumnWidth(80);

getRowHeightPixel/setRowHeightPixel

public int getRowHeightPixel() / public void setRowHeightPixel(int value)
Returns or sets the height, in pixels, of each row in the specified slicer.

Example:

slicer.setRowHeightPixel(30);

setRowHeightPixel

public void setRowHeightPixel(int value)
Returns or sets the height, in pixels, of each row in the specified slicer.

Example:

slicer.setRowHeightPixel(30);

getRowHeight/setRowHeight

public double getRowHeight() / public void setRowHeight(double value)
Returns or sets the height, in points, of each row in the specified slicer.

Example:

slicer.setRowHeight(20);

setRowHeight

public void setRowHeight(double value)
Returns or sets the height, in points, of each row in the specified slicer.

Example:

slicer.setRowHeight(20);

Method Detail

addPivotConnection

public void addPivotConnection(PivotTable pivot)
Adds PivotTable connection.
Parameters:
pivot - The PivotTable object

Example:

slicer.addPivotConnection(pivot);

removePivotConnection

public void removePivotConnection(PivotTable pivot)
Removes PivotTable connection.
Parameters:
pivot - The PivotTable object

Example:

slicer.removePivotConnection(pivot);

refresh

public void refresh()
            throws java.lang.Exception
Refreshing the slicer.Meanwhile, Refreshing and Calculating relative PivotTables.

Example:

slicer.refresh();

See Also:
          Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
          Aspose.Cells Support Forum - our preferred method of support.