Apply filter to pivot table

Hi ,

I would like filter the report filter column by the value “Student” in Java.

PivotTable table = wb1.getWorksheets().get(5).getPivotTables().get(0);
PivotField field = table.getPageFields().get(0);
//how to apply filter here ? I did not get any documentation in java
table.calculateData();
table.refreshData();
Is it supported in Java for pivot table?

Hi,


Please see the thread for your complete reference on how to apply filters to PivotTable:
<a href="

(Note: The example code (in the above thread) is provided in .NET, but you may easily convert to JAVA using the relevant Aspose.Cells for Java APIs)

Let us know if you have any issue.

Thank you.

Hi ,

Thanks for your reply. According to the code in .NET I am writing the code like below:

PivotTable table = wb1.getWorksheets().get(5).getPivotTables().get(0);
PivotField field = table.getPageFields().get(0);
int pageItemCount = field.getPivotItems().getCount();
for(int i=0;i<pageItemCount;i++) {
if(“Students”.equals(field.getPivotItems().get(i).getValue())) {
field.setCurrentPageItem((short)i);
break;
}
}
table.refreshData();
table.calculateData();
wb1.save(“Book1.xlsx”);

But it is not applying the filter. What is wrong in my code?Please suggest me

How can I clear all the filters before applying any?

Hi,


Could you provide us your template file here, we will check it soon.

Thank you.