PivotCaches.Add Method
Adds a new PivotTable cache to a PivotCaches collection.
Namespace: Microsoft.Office.Interop.Excel
Assembly: Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)
Syntax
'Declaration
Function Add ( _
SourceType As XlPivotTableSourceType, _
SourceData As Object _
) As PivotCache
'Usage
Dim instance As PivotCaches
Dim SourceType As XlPivotTableSourceType
Dim SourceData As Object
Dim returnValue As PivotCache
returnValue = instance.Add(SourceType, _
SourceData)
PivotCache Add(
XlPivotTableSourceType SourceType,
Object SourceData
)
Parameters
SourceType
Type: Microsoft.Office.Interop.Excel.XlPivotTableSourceTypeRequired XlPivotTableSourceType. The source of the PivotTable cache data. Can be one of the following XlPivotTableSourceType constants:
xlConsolidation
xlDatabase
xlExternal
xlPivotTable
xlScenario
SourceData
Type: System.ObjectOptional Object. The data for the new PivotTable cache. This argument is required if SourceType isn't xlExternal. Can be a Range object, an array of ranges, or a text constant that represents the name of an existing PivotTable report. For an external database, this is a two-element array. The first element is the connection string specifying the provider of the data. The second element is the SQL query string used to get the data. If you specify this argument, you must also specify SourceType.
Return Value
Type: Microsoft.Office.Interop.Excel.PivotCache
Remarks
If the PivotTable cache isn't referenced by a PivotTable object, the PivotTable cache is automatically deleted before the workbook is saved.