public class PivotFilter
extends java.lang.Object
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);
//Add PivotFilter
int index = pivot.getPivotFilters().add(0, PivotFilterType.COUNT);
PivotFilter filter = pivot.getPivotFilters().get(index);
filter.getAutoFilter().filterTop10(0, false, false, 2);
pivot.refreshData();
pivot.calculateData();
//do your business
book.save("out.xlsx");
| Modifier and Type | Method and Description |
|---|---|
AutoFilter |
getAutoFilter()
Gets the autofilter of the pivot filter.
|
int |
getEvaluationOrder()
Gets the Evaluation Order of the pivot filter.
|
int |
getFieldIndex()
Gets the field index of the pivot filter.
|
int |
getFilterType()
Gets the autofilter type of the pivot filter.
|
int |
getMeasureFldIndex()
Gets the measure field index of the pivot filter.
|
int |
getMemberPropertyFieldIndex()
Gets the member property field index of the pivot filter.
|
java.lang.String |
getName()
Gets the name of the pivot filter.
|
java.lang.String |
getValue1()
Gets the string value1 of the label pivot filter.
|
java.lang.String |
getValue2()
Gets the string value2 of the label pivot filter.
|
void |
setEvaluationOrder(int value)
Gets the Evaluation Order of the pivot filter.
|
void |
setMeasureFldIndex(int value)
Gets the measure field index of the pivot filter.
|
void |
setMemberPropertyFieldIndex(int value)
Gets the member property field index of the pivot filter.
|
void |
setName(java.lang.String value)
Gets the name of the pivot filter.
|
void |
setValue1(java.lang.String value)
Gets the string value1 of the label pivot filter.
|
void |
setValue2(java.lang.String value)
Gets the string value2 of the label pivot filter.
|
public AutoFilter getAutoFilter()
public int getFilterType()
See PivotFilterType.
public int getFieldIndex()
public java.lang.String getValue1()
public void setValue1(java.lang.String value)
public java.lang.String getValue2()
public void setValue2(java.lang.String value)
public int getMeasureFldIndex()
public void setMeasureFldIndex(int value)
public int getMemberPropertyFieldIndex()
public void setMemberPropertyFieldIndex(int value)
public java.lang.String getName()
public void setName(java.lang.String value)
public int getEvaluationOrder()
public void setEvaluationOrder(int value)
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 2001-2023. All Rights Reserved.