java.lang.Object
CollectionBase
com.aspose.cells.SlicerCollection
- All Implemented Interfaces:
- java.lang.Iterable
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");
|
Property Getters/Setters Summary |
int | getCount() | → inherited from com.aspose.cells.CollectionBase
|
| |
Slicer | get(int) | |
|
Gets the Slicer by index.
|
Slicer | get(java.lang.String) | |
|
Gets the Slicer by slicer's name.
|
|
Method Summary |
int | add(ListObject table, ListColumn listColumn, int row, int column) | |
|
Add a new Slicer using ListObjet as data source
|
int | add(ListObject table, ListColumn listColumn, java.lang.String destCellName) | |
|
Add a new Slicer using ListObjet as data source
|
int | add(ListObject table, int index, java.lang.String destCellName) | |
|
Add a new Slicer using ListObjet as data source
|
int | add(PivotTable pivot, int row, int column, PivotField baseField) | |
|
Add a new Slicer using PivotTable as data source
|
int | add(PivotTable pivot, int row, int column, int baseFieldIndex) | |
|
Add a new Slicer using PivotTable as data source
|
int | add(PivotTable pivot, int row, int column, java.lang.String baseFieldName) | |
|
Add a new Slicer using PivotTable as data source
|
int | add(PivotTable pivot, java.lang.String destCellName, PivotField baseField) | |
|
Add a new Slicer using PivotTable as data source
|
int | add(PivotTable pivot, java.lang.String destCellName, int baseFieldIndex) | |
|
Add a new Slicer using PivotTable as data source
|
int | add(PivotTable pivot, java.lang.String destCellName, java.lang.String baseFieldName) | |
|
Add a new Slicer using PivotTable as data source
|
int | add(java.lang.Object value) | → inherited from com.aspose.cells.CollectionBase
|
| Reserved for internal use. |
void | clear() | → inherited from com.aspose.cells.CollectionBase
|
| |
boolean | contains(java.lang.Object value) | → inherited from com.aspose.cells.CollectionBase
|
| Reserved for internal use. |
int | indexOf(java.lang.Object value) | → inherited from com.aspose.cells.CollectionBase
|
| Reserved for internal use. |
java.util.Iterator | iterator() | → inherited from com.aspose.cells.CollectionBase
|
| |
void | remove(Slicer slicer) | |
|
Remove the specified Slicer
|
void | removeAt(int index) | |
|
Deletes the Slicer at the specified index
|
|
Property Getters/Setters Detail |
getCount | → inherited from com.aspose.cells.CollectionBase
|
public int getCount()
|
-
get | |
public Slicer get(int index)
|
-
Gets the Slicer by index.
Example:
Slicer slicerByIndex = slicers.get(0);
get | |
public Slicer get(java.lang.String name)
|
-
Gets the Slicer by slicer's name.
Example:
Slicer slicerByName = slicers.get("fruit");
remove | |
public void remove(Slicer slicer) |
-
Remove the specified Slicer
- Parameters:
slicer - The Slicer object
Example:
Slicer delSlicer = slicers.get(0);
slicers.remove(delSlicer);
removeAt | |
public void removeAt(int index) |
-
Deletes the Slicer at the specified index
- Parameters:
index - The position index in Slicer collection
Example:
slicers.removeAt(1);
add | |
public int add(PivotTable pivot, java.lang.String destCellName, java.lang.String baseFieldName) |
-
Add a new Slicer using PivotTable as data source
- Parameters:
pivot - PivotTable objectdestCellName - The cell in the upper-left corner of the Slicer range.baseFieldName - The name of PivotField in PivotTable.BaseFields
- Returns:
- The new add Slicer index
Example:
slicers.add(pivot, "E3", "fruit");
add | |
public int add(PivotTable pivot, int row, int column, java.lang.String baseFieldName) |
-
Add a new Slicer using PivotTable as data source
- Parameters:
pivot - PivotTable objectrow - Row index of the cell in the upper-left corner of the Slicer range.column - Column index of the cell in the upper-left corner of the Slicer range.baseFieldName - The name of PivotField in PivotTable.BaseFields
- Returns:
- The new add Slicer index
Example:
slicers.add(pivot, 20, 12, "fruit");
add | |
public int add(PivotTable pivot, int row, int column, int baseFieldIndex) |
-
Add a new Slicer using PivotTable as data source
- Parameters:
pivot - PivotTable objectrow - Row index of the cell in the upper-left corner of the Slicer range.column - Column index of the cell in the upper-left corner of the Slicer range.baseFieldIndex - The index of PivotField in PivotTable.BaseFields
- Returns:
- The new add Slicer index
Example:
slicers.add(pivot, 20, 8, 0);
add | |
public int add(PivotTable pivot, java.lang.String destCellName, int baseFieldIndex) |
-
Add a new Slicer using PivotTable as data source
- Parameters:
pivot - PivotTable objectdestCellName - The cell in the upper-left corner of the Slicer range.baseFieldIndex - The index of PivotField in PivotTable.BaseFields
- Returns:
- The new add Slicer index
Example:
slicers.add(pivot, "E20", 0);
-
Add a new Slicer using PivotTable as data source
- Parameters:
pivot - PivotTable objectrow - Row index of the cell in the upper-left corner of the Slicer range.column - Column index of the cell in the upper-left corner of the Slicer range.baseField - The PivotField in PivotTable.BaseFields
- Returns:
- The new add Slicer index
Example:
slicers.add(pivot, 3, 12, pivot.getBaseFields().get(0));
-
Add a new Slicer using PivotTable as data source
- Parameters:
pivot - PivotTable objectdestCellName - The cell in the upper-left corner of the Slicer range.baseField - The PivotField in PivotTable.BaseFields
- Returns:
- The new add Slicer index
Example:
slicers.add(pivot, "I3", pivot.getBaseFields().get(0));
add | |
public int add(ListObject table, int index, java.lang.String destCellName) |
-
Add a new Slicer using ListObjet as data source
- Parameters:
table - ListObject objectindex - The index of ListColumn in ListObject.ListColumnsdestCellName - The cell in the upper-left corner of the Slicer range.
- Returns:
- The new add Slicer index
Example:
slicers.add(table, 1, "E38");
-
Add a new Slicer using ListObjet as data source
- Parameters:
table - ListObject objectlistColumn - The ListColumn in ListObject.ListColumnsdestCellName - The cell in the upper-left corner of the Slicer range.
- Returns:
- The new add Slicer index
Example:
slicers.add(table, table.getListColumns().get(1), "I38");
-
Add a new Slicer using ListObjet as data source
- Parameters:
table - ListObject objectlistColumn - The ListColumn in ListObject.ListColumnsrow - Row index of the cell in the upper-left corner of the Slicer range.column - Column index of the cell in the upper-left corner of the Slicer range.
- Returns:
- The new add Slicer index
Example:
slicers.add(table, table.getListColumns().get(1), 38, 12);
clear | → inherited from com.aspose.cells.CollectionBase
|
public void clear() |
-
iterator | → inherited from com.aspose.cells.CollectionBase
|
public java.util.Iterator iterator() |
-
contains | → inherited from com.aspose.cells.CollectionBase
|
public boolean contains(java.lang.Object value) |
- Reserved for internal use.
add | → inherited from com.aspose.cells.CollectionBase
|
public int add(java.lang.Object value) |
- Reserved for internal use.
indexOf | → inherited from com.aspose.cells.CollectionBase
|
public int indexOf(java.lang.Object value) |
- Reserved for internal use.
See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.