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 top 10 filter
pivot.getBaseFields().get(0).filterTop10(0, PivotFilterType.COUNT,false,2);
pivot.refreshData();
pivot.calculateData();
//do your business
book.save("out.xlsx");
| Modifier and Type | Method and Description |
|---|---|
AutoFilter |
getAutoFilter()
Deprecated.
Use FilterLabel, FilterValue,FilterDate or FilterTop10 method.
|
DateTime[] |
getDateTimeValues()
Gets values of the number filter.
|
int |
getEvaluationOrder()
Gets the Evaluation Order of the pivot filter.
|
int |
getFieldIndex()
Gets the index of source field which this pivot filter is applied to.
|
int |
getFilterCategory()
Gets the category of this filter.
|
int |
getFilterType()
Gets the autofilter type of the pivot filter.
|
java.lang.String[] |
getLabels()
Gets labels of the caption filter.
|
int |
getMeasureCubeFieldIndex()
Specifies the index of the measure cube field.
|
int |
getMeasureFldIndex()
Deprecated.
Use PivotFilter.ValueFieldIndex property.
|
int |
getMemberPropertyFieldIndex()
Gets the member property field index of the pivot filter.
|
java.lang.String |
getName()
Gets the name of the pivot filter.
|
double[] |
getNumberValues()
Gets values of the number filter.
|
Top10Filter |
getTop10Value()
Gets top 10 setting of the filter.
|
boolean |
getUseWholeDay()
Indicates whether uses whole days in its filtering criteria.
|
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.
|
int |
getValueFieldIndex()
Gets the index of value field in the value region.
|
void |
setEvaluationOrder(int value)
Gets the Evaluation Order of the pivot filter.
|
void |
setMeasureFldIndex(int value)
Deprecated.
Use PivotFilter.ValueFieldIndex property.
|
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 |
setUseWholeDay(boolean value)
Indicates whether uses whole days in its filtering criteria.
|
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.
|
void |
setValueFieldIndex(int value)
Gets the index of value field in the value region.
|
public boolean getUseWholeDay()
public void setUseWholeDay(boolean value)
public AutoFilter getAutoFilter()
Remarks
NOTE: This method is now obsolete. Instead, please use FilterLabel, FilterValue,FilterDate or FilterTop10 method. This method will be removed 12 months later since November 2024. Aspose apologizes for any inconvenience you may have experienced.public int getFilterType()
See PivotFilterType.
public int getFieldIndex()
public Top10Filter getTop10Value()
public java.lang.String[] getLabels()
public double[] getNumberValues()
public DateTime[] getDateTimeValues()
public int getFilterCategory()
See FilterCategory.
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()
Remarks
NOTE: This method is now obsolete. Instead, please use PivotFilter.ValueFieldIndex property. This method will be removed 12 months later since November 2024. Aspose apologizes for any inconvenience you may have experienced.public void setMeasureFldIndex(int value)
Remarks
NOTE: This method is now obsolete. Instead, please use PivotFilter.ValueFieldIndex property. This method will be removed 12 months later since November 2024. Aspose apologizes for any inconvenience you may have experienced.public int getValueFieldIndex()
public void setValueFieldIndex(int value)
public int getMeasureCubeFieldIndex()
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 2003-2025. All Rights Reserved.