Skip to main content

How to: Refresh a Pivot Table

To refresh a pivot table and retrieve the latest data from a data source, use the PivotCache.Refresh method of the PivotTable cache accessible through the PivotTable.Cache property. All pivot tables that are based on the same PivotCache will also be refreshed.

Note

If your PivotTable report contains cell formatting, it may disappear after the refresh operation.

If you wish to prevent column widths from being automatically adjusted when the PivotTable data is refreshed, set the PivotBehaviorOptions.AutoFitColumns property to false.

// Access the pivot table by its name in the collection.
PivotTable pivotTable = worksheet.PivotTables["PivotTable1"];
// Refresh the pivot table.
pivotTable.Cache.Refresh();

To refresh all pivot tables in a workbook at once, use the PivotCacheCollection.RefreshAll method.