I want to refresh pivot table after enter data to data sheet
I read two previous questions [this][1] and [this][2]. there two way to do this
one way is
Right click your pivot table -> pivotTable Options -> Data -> Check Refresh Data when opening File
this is working I want a automated way so I tried in this way
FileInputStream inputStream = new FileInputStream(new File(excelFilePath));
workbook = new XSSFWorkbook(inputStream);
XSSFSheet sheet = workbook.getSheet("Summary");
XSSFPivotTable pivotTable = sheet.getPivotTables().get(0);
pivotTable.getPivotCacheDefinition().getCTPivotCacheDefinition().setRefreshOnLoad(true);
I have two pivot tables in this sheet so sheet.getPrivotTable return this
[Name: /xl/pivotTables/pivotTable1.xml - Content Type: application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml, Name: /xl/pivotTables/pivotTable2.xml - Content Type: application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml]
but sheet.getPivotTables().get(0).getPivotCacheDefinition() return null value.
Is there any way to refresh Pivot table automatically?