[]
Adds a new PivotTable report.
Creates a PivotTable report from the specified IPivotCache and places it at the specified destination range on the worksheet that contains this IPivotTables collection.
IPivotTable Add(IPivotCache PivotCache, IRange TableDestination, string TableName = null)
Function Add(PivotCache As IPivotCache, TableDestination As IRange, Optional TableName As String = Nothing) As IPivotTable
| Type | Name | Description |
|---|---|---|
| IPivotCache | PivotCache | The PivotTable cache on which the new PivotTable report is based. This parameter must not be |
| IRange | TableDestination | The upper-left cell of the destination range where the PivotTable report is placed. The destination range must be on the worksheet that contains this |
| string | TableName | The name of the new PivotTable report. This value can be |
| Type | Description |
|---|---|
| IPivotTable | The created IPivotTable report. |
worksheet.Range["A1:C4"].Value = new object[,] {
{"Region", "Product", "Amount"},
{"East", "Apple", 120},
{"West", "Apple", 80},
{"East", "Orange", 90}
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:C4"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["E1"], "SalesPivot");