[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.IPivotTable.Refresh

Refresh Method

Refresh()

Refreshes the PivotTable report from its source data.

Use this method after the source data has changed and you need the PivotTable to reflect the latest data.

This method performs the following actions:

  1. Refreshes the underlying PivotCache.
  2. Synchronizes PivotFields with the refreshed cache.
  3. Recalculates and updates the PivotTable report on the worksheet.

If only the PivotTable layout or display settings have changed and the source data has not changed, use Update() instead.

Declaration
bool Refresh()
Function Refresh() As Boolean
Returns
Type Description
bool true if the refresh succeeds.
Examples
worksheet.Range["A1:B4"].Value = new object[,] {
    {"Product", "Amount"},
    {"Apple", 100},
    {"Apple", 200},
    {"Orange", 150}
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:B4"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["D1"], "PivotTable1");
pivotTable.PivotFields["Product"].Orientation = PivotFieldOrientation.RowField;
pivotTable.PivotFields["Amount"].Orientation = PivotFieldOrientation.DataField;
worksheet.Range["B2"].Value = 120;
bool refreshed = pivotTable.Refresh();
Exceptions
Type Condition
InvalidOperationException

if the source sheet of the PivotTable cannot be found.