We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to set page field current value of PivotTable?

How to set page field value


Workbook wb = new Workbook(“C:/Pivot.xlsx”);

How to change current page field “x” value to “a”?

wb.getWorksheets().get(0).getPivotTables().get(0).getPageFields().get(0).setCurrentPageItem(0)

is not work.

Hi,


Thanks for your posting and using Aspose.Cells.

Please use the following code. It works fine. You must refresh and calculate data of the pivot table to get your desired result. Please check the output Excel file generated with the code for a reference.

Java
Workbook wb = new Workbook(dirPath + “Pivot.xlsx”);

PivotTable pt = wb.getWorksheets().get(0).getPivotTables().get(0);
pt.getPageFields().get(0).setCurrentPageItem((short)0);
pt.refreshData();
pt.calculateData();

wb.save(dirPath + “output.xlsx”);