Refresh Pivot Table with Apache POI Refresh Pivot Table with Apache POI apache apache

Refresh Pivot Table with Apache POI


You can simple activate an option that will refresh the pivot table every time the file is opened.

This Microsoft documentation says :

In the PivotTable Options dialog box, on the Data tab, select the Refresh data when opening the file check box.


It is possible.In the PivotCacheDefinition, there is an attribute refreshOnLoad that can be set to true. The cache is then refreshed when the workbook is opened. More information here.

In POI this can be done by calling the method setRefreshOnLoad(boolean bool), that takes a boolean as parameter, on a CTPivotCacheDefinition.

EDIT:The Apache POI now provides the possibility to create pivot tables and the pivot table is refreshed on load as default. Class XSSFPivotTable


This post says you can turn on an option on the pivot table that will cause it to refresh itself automatically every time the workbook is opened:

How can I refresh all the pivot tables in my excel workbook with a macro?

Hopefully this will still be true after you have used Apache POI to refresh or extend the data rows on which the pivot tables are based.