[]
Updates the PivotTable report layout and displayed results.
A common use case is to enable DeferLayoutUpdate, make multiple layout changes, and then call this method once to apply them.
This method does not refresh the PivotCache from the source data. If the source data has changed and the PivotCache must be refreshed first, call Refresh() instead.
void Update()
Sub Update()
worksheet.Range["A1:C5"].Value = new object[,] {
{"Category", "Product", "Amount"},
{"Beverages", "Tea", 100},
{"Beverages", "Coffee", 200},
{"Snacks", "Biscuits", 150}
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:C5"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["E1"], "PivotTable1");
pivotTable.DeferLayoutUpdate = true;
pivotTable.PivotFields["Category"].Orientation = PivotFieldOrientation.RowField;
pivotTable.PivotFields["Amount"].Orientation = PivotFieldOrientation.DataField;
pivotTable.Update();