SlicerCollection

Inheritance: java.lang.Object, com.aspose.cells.CollectionBase

public class SlicerCollection extends CollectionBase

Specifies the collection of all the Slicer objects on the specified worksheet.

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 tableIndex = sheet.getListObjects().add("A1", "C9", true);
         ListObject table = sheet.getListObjects().get(tableIndex);
 
         //do your business
 
         book.save("out.xlsx");

Methods

MethodDescription
add(ListObject table, ListColumn listColumn, int row, int column)Add a new Slicer using ListObjet as data source
add(ListObject table, ListColumn listColumn, String destCellName)Add a new Slicer using ListObjet as data source
add(ListObject table, int index, String destCellName)Add a new Slicer using ListObjet as data source
add(PivotTable pivot, int row, int column, PivotField baseField)Add a new Slicer using PivotTable as data source
add(PivotTable pivot, int row, int column, int baseFieldIndex)Add a new Slicer using PivotTable as data source
add(PivotTable pivot, int row, int column, String baseFieldName)Add a new Slicer using PivotTable as data source
add(PivotTable pivot, String destCellName, PivotField baseField)Add a new Slicer using PivotTable as data source
add(PivotTable pivot, String destCellName, int baseFieldIndex)Add a new Slicer using PivotTable as data source
add(PivotTable pivot, String destCellName, String baseFieldName)Add a new Slicer using PivotTable as data source
add(Object o)Adds an item to the CollectionBase instance.
clear()Removes all objects from the CollectionBase instance.
contains(Object o)Return whether instance contains this object
equals(Object arg0)
get(int index)Gets the Slicer by index.
get(String name)Gets the Slicer by slicer’s name.
getClass()
getCount()Gets the number of elements contained in the CollectionBase instance.
hashCode()
indexOf(Object o)Determines the index of a specific item in the CollectionBase instance.
iterator()Returns an enumerator that iterates through the CollectionBase instance.
notify()
notifyAll()
remove(Slicer slicer)Remove the specified Slicer
removeAt(int index)Deletes the Slicer at the specified index
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)

add(ListObject table, ListColumn listColumn, int row, int column)

public int add(ListObject table, ListColumn listColumn, int row, int column)

Add a new Slicer using ListObjet as data source

Example

         slicers.add(table, table.getListColumns().get(1), 38, 12);

Parameters:

ParameterTypeDescription
tableListObjectListObject object
listColumnListColumnThe ListColumn in ListObject.ListColumns
rowintRow index of the cell in the upper-left corner of the Slicer range.
columnintColumn index of the cell in the upper-left corner of the Slicer range.

Returns: int - The new add Slicer index

add(ListObject table, ListColumn listColumn, String destCellName)

public int add(ListObject table, ListColumn listColumn, String destCellName)

Add a new Slicer using ListObjet as data source

Example

         slicers.add(table, table.getListColumns().get(1), "I38");

Parameters:

ParameterTypeDescription
tableListObjectListObject object
listColumnListColumnThe ListColumn in ListObject.ListColumns
destCellNamejava.lang.StringThe cell in the upper-left corner of the Slicer range.

Returns: int - The new add Slicer index

add(ListObject table, int index, String destCellName)

public int add(ListObject table, int index, String destCellName)

Add a new Slicer using ListObjet as data source

Example

         slicers.add(table, 1, "E38");

Parameters:

ParameterTypeDescription
tableListObjectListObject object
indexintThe index of ListColumn in ListObject.ListColumns
destCellNamejava.lang.StringThe cell in the upper-left corner of the Slicer range.

Returns: int - The new add Slicer index

add(PivotTable pivot, int row, int column, PivotField baseField)

public int add(PivotTable pivot, int row, int column, PivotField baseField)

Add a new Slicer using PivotTable as data source

Example

         slicers.add(pivot, 3, 12, pivot.getBaseFields().get(0));

Parameters:

ParameterTypeDescription
pivotPivotTablePivotTable object
rowintRow index of the cell in the upper-left corner of the Slicer range.
columnintColumn index of the cell in the upper-left corner of the Slicer range.
baseFieldPivotFieldThe PivotField in PivotTable.BaseFields

Returns: int - The new add Slicer index

add(PivotTable pivot, int row, int column, int baseFieldIndex)

public int add(PivotTable pivot, int row, int column, int baseFieldIndex)

Add a new Slicer using PivotTable as data source

Example

         slicers.add(pivot, 20, 8, 0);

Parameters:

ParameterTypeDescription
pivotPivotTablePivotTable object
rowintRow index of the cell in the upper-left corner of the Slicer range.
columnintColumn index of the cell in the upper-left corner of the Slicer range.
baseFieldIndexintThe index of PivotField in PivotTable.BaseFields

Returns: int - The new add Slicer index

add(PivotTable pivot, int row, int column, String baseFieldName)

public int add(PivotTable pivot, int row, int column, String baseFieldName)

Add a new Slicer using PivotTable as data source

Example

         slicers.add(pivot, 20, 12, "fruit");

Parameters:

ParameterTypeDescription
pivotPivotTablePivotTable object
rowintRow index of the cell in the upper-left corner of the Slicer range.
columnintColumn index of the cell in the upper-left corner of the Slicer range.
baseFieldNamejava.lang.StringThe name of PivotField in PivotTable.BaseFields

Returns: int - The new add Slicer index

add(PivotTable pivot, String destCellName, PivotField baseField)

public int add(PivotTable pivot, String destCellName, PivotField baseField)

Add a new Slicer using PivotTable as data source

Example

         slicers.add(pivot, "I3", pivot.getBaseFields().get(0));

Parameters:

ParameterTypeDescription
pivotPivotTablePivotTable object
destCellNamejava.lang.StringThe cell in the upper-left corner of the Slicer range.
baseFieldPivotFieldThe PivotField in PivotTable.BaseFields

Returns: int - The new add Slicer index

add(PivotTable pivot, String destCellName, int baseFieldIndex)

public int add(PivotTable pivot, String destCellName, int baseFieldIndex)

Add a new Slicer using PivotTable as data source

Example

         slicers.add(pivot, "E20", 0);

Parameters:

ParameterTypeDescription
pivotPivotTablePivotTable object
destCellNamejava.lang.StringThe cell in the upper-left corner of the Slicer range.
baseFieldIndexintThe index of PivotField in PivotTable.BaseFields

Returns: int - The new add Slicer index

add(PivotTable pivot, String destCellName, String baseFieldName)

public int add(PivotTable pivot, String destCellName, String baseFieldName)

Add a new Slicer using PivotTable as data source

Example

         slicers.add(pivot, "E3", "fruit");

Parameters:

ParameterTypeDescription
pivotPivotTablePivotTable object
destCellNamejava.lang.StringThe cell in the upper-left corner of the Slicer range.
baseFieldNamejava.lang.StringThe name of PivotField in PivotTable.BaseFields

Returns: int - The new add Slicer index

add(Object o)

public int add(Object o)

Adds an item to the CollectionBase instance.

Parameters:

ParameterTypeDescription
ojava.lang.ObjectThe Object to add to the CollectionBase instance.

Returns: int - The position into which the new element was inserted.

clear()

public void clear()

Removes all objects from the CollectionBase instance.

contains(Object o)

public boolean contains(Object o)

Return whether instance contains this object

Parameters:

ParameterTypeDescription
ojava.lang.Objecttest object

Returns: boolean - Whether instance contains this object

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

get(int index)

public Slicer get(int index)

Gets the Slicer by index.

Example

         Slicer slicerByIndex = slicers.get(0);

Parameters:

ParameterTypeDescription
indexint

Returns: Slicer

get(String name)

public Slicer get(String name)

Gets the Slicer by slicer’s name.

Example

         Slicer slicerByName = slicers.get("fruit");

Parameters:

ParameterTypeDescription
namejava.lang.String

Returns: Slicer

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getCount()

public int getCount()

Gets the number of elements contained in the CollectionBase instance.

Returns: int - The number of elements contained in the CollectionBase instance.

hashCode()

public native int hashCode()

Returns: int

indexOf(Object o)

public int indexOf(Object o)

Determines the index of a specific item in the CollectionBase instance.

Parameters:

ParameterTypeDescription
ojava.lang.ObjectDetermines the index of a specific item in the CollectionBase instance.

Returns: int - The index of value if found in the list; otherwise, -1.

iterator()

public Iterator iterator()

Returns an enumerator that iterates through the CollectionBase instance.

Returns: java.util.Iterator - An iterator for the CollectionBase instance.

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

remove(Slicer slicer)

public void remove(Slicer slicer)

Remove the specified Slicer

Example

         Slicer delSlicer = slicers.get(0);
         slicers.remove(delSlicer);

Parameters:

ParameterTypeDescription
slicerSlicerThe Slicer object

removeAt(int index)

public void removeAt(int index)

Deletes the Slicer at the specified index

Example

         slicers.removeAt(1);

Parameters:

ParameterTypeDescription
indexintThe position index in Slicer collection

toString()

public String toString()

Returns: java.lang.String

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int