[]
Clears the PivotTable.
Clearing a PivotTable removes all fields and deletes any filtering and sorting applied to the report. This method resets the PivotTable to the state it had immediately after creation, before any fields were added.
void ClearTable()
Sub ClearTable()
object[,] sourceData = {
{"Product", "Region", "Amount"},
{"Apple", "East", 120},
{"Pear", "West", 80}
};
worksheet.Range["A1:C3"].Value = sourceData;
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:C3"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["E1"], "PivotTable1");
pivotTable.PivotFields["Region"].Orientation = PivotFieldOrientation.RowField;
pivotTable.AddDataField(pivotTable.PivotFields["Amount"], "Sum of Amount", ConsolidationFunction.Sum);
pivotTable.ClearTable();