Refresh pivot table in Excel file

选择整列做数据表问题.xlsx.zip (10.4 KB)

	Workbook wb = new Workbook("/选择整列做数据表问题.xlsx");
	PivotTable table = wb.getWorksheets().get("Sheet6").getPivotTables().get(0);
	table.calculateRange();
	table.calculateData();
	table.refreshData();
	wb.save("/选择整列做数据表问题2.html");

PivotTable doesn’t refresh fine, but in MS Excel it works fine.

@xhaixia,
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSJAVA-43068 - PivotTable refresh error

@xhaixia,

We evaluated your issue further.
Well, you should refresh data first, and then calculate the data. By the way, if you will call the PivotTable.calculateData() method, you don’t need to call the PivotTable.calculateRange() method for performance. This is due to the fact that we have implemented the logic of calculating range in the PivotTable.CalculateData() method already.

So, for your issue, please change the following code:
i.e.,

table.calculateRange();
table.calculateData();
table.refreshData();

to:

table.refreshData();
table.calculateData();

Let us know if you still find the issue.