public class SlicerCollection extends CollectionBase
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");
| Modifier and Type | Method and Description |
|---|---|
int |
add(ListObject table,
int index,
java.lang.String destCellName)
Add a new Slicer using ListObjet as data source
|
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(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,
PivotField baseField)
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,
int baseFieldIndex)
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,
java.lang.String baseFieldName)
Add a new Slicer using PivotTable as data source
|
void |
clear()
Clear all Slicers.
|
Slicer |
get(int index)
Gets the Slicer by index.
|
Slicer |
get(java.lang.String name)
Gets the Slicer by slicer's name.
|
void |
remove(Slicer slicer)
Remove the specified Slicer
|
void |
removeAt(int index)
Deletes the Slicer at the specified index
|
public Slicer get(int index)
Example
Slicer slicerByIndex = slicers.get(0);
get in class CollectionBaseindex - Specified position index.public Slicer get(java.lang.String name)
Example
Slicer slicerByName = slicers.get("fruit");
public void remove(Slicer slicer)
Example
Slicer delSlicer = slicers.get(0);
slicers.remove(delSlicer);
slicer - The Slicer objectpublic void removeAt(int index)
Example
slicers.removeAt(1);
removeAt in class CollectionBaseindex - The position index in Slicer collectionpublic void clear()
clear in class CollectionBasepublic int add(PivotTable pivot, java.lang.String destCellName, java.lang.String baseFieldName)
Example
slicers.add(pivot, "E3", "fruit");
pivot - PivotTable objectdestCellName - The cell in the upper-left corner of the Slicer range.baseFieldName - The name of PivotField in PivotTable.BaseFieldspublic int add(PivotTable pivot, int row, int column, java.lang.String baseFieldName)
Example
slicers.add(pivot, 20, 12, "fruit");
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.BaseFieldspublic int add(PivotTable pivot, int row, int column, int baseFieldIndex)
Example
slicers.add(pivot, 20, 8, 0);
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.BaseFieldspublic int add(PivotTable pivot, java.lang.String destCellName, int baseFieldIndex)
Example
slicers.add(pivot, "E20", 0);
pivot - PivotTable objectdestCellName - The cell in the upper-left corner of the Slicer range.baseFieldIndex - The index of PivotField in PivotTable.BaseFieldspublic int add(PivotTable pivot, int row, int column, PivotField baseField)
Example
slicers.add(pivot, 3, 12, pivot.getBaseFields().get(0));
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.BaseFieldspublic int add(PivotTable pivot, java.lang.String destCellName, PivotField baseField)
Example
slicers.add(pivot, "I3", pivot.getBaseFields().get(0));
pivot - PivotTable objectdestCellName - The cell in the upper-left corner of the Slicer range.baseField - The PivotField in PivotTable.BaseFieldspublic int add(ListObject table, int index, java.lang.String destCellName)
Example
slicers.add(table, 1, "E38");
table - ListObject objectindex - The index of ListColumn in ListObject.ListColumnsdestCellName - The cell in the upper-left corner of the Slicer range.public int add(ListObject table, ListColumn listColumn, java.lang.String destCellName)
Example
slicers.add(table, table.getListColumns().get(1), "I38");
table - ListObject objectlistColumn - The ListColumn in ListObject.ListColumnsdestCellName - The cell in the upper-left corner of the Slicer range.public int add(ListObject table, ListColumn listColumn, int row, int column)
Example
slicers.add(table, table.getListColumns().get(1), 38, 12);
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.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 2003-2025. All Rights Reserved.