[]
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:
PivotCache.PivotFields with the refreshed cache.If only the PivotTable layout or display settings have changed and the source data has not changed, use Update() instead.
bool Refresh()
Function Refresh() As Boolean
| Type | Description |
|---|---|
| bool |
true
if the refresh succeeds.
|
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();
| Type | Condition |
|---|---|
| InvalidOperationException | if the source sheet of the PivotTable cannot be found. |