_Worksheet.PivotTableWizard Method
Creates a PivotTable object. This method doesn’t display the PivotTable Wizard. This method isn’t available for OLE DB data sources. Use the Add method to add a PivotTable cache, and then create a PivotTable report based on the cache. PivotTable object.
Namespace: Microsoft.Office.Interop.Excel
Assembly: Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)
Syntax
'Declaration
Function PivotTableWizard ( _
SourceType As Object, _
SourceData As Object, _
TableDestination As Object, _
TableName As Object, _
RowGrand As Object, _
ColumnGrand As Object, _
SaveData As Object, _
HasAutoFormat As Object, _
AutoPage As Object, _
Reserved As Object, _
BackgroundQuery As Object, _
OptimizeCache As Object, _
PageFieldOrder As Object, _
PageFieldWrapCount As Object, _
ReadData As Object, _
Connection As Object _
) As PivotTable
'Usage
Dim instance As _Worksheet
Dim SourceType As Object
Dim SourceData As Object
Dim TableDestination As Object
Dim TableName As Object
Dim RowGrand As Object
Dim ColumnGrand As Object
Dim SaveData As Object
Dim HasAutoFormat As Object
Dim AutoPage As Object
Dim Reserved As Object
Dim BackgroundQuery As Object
Dim OptimizeCache As Object
Dim PageFieldOrder As Object
Dim PageFieldWrapCount As Object
Dim ReadData As Object
Dim Connection As Object
Dim returnValue As PivotTable
returnValue = instance.PivotTableWizard(SourceType, _
SourceData, TableDestination, TableName, _
RowGrand, ColumnGrand, SaveData, _
HasAutoFormat, AutoPage, Reserved, _
BackgroundQuery, OptimizeCache, _
PageFieldOrder, PageFieldWrapCount, _
ReadData, Connection)
PivotTable PivotTableWizard(
Object SourceType,
Object SourceData,
Object TableDestination,
Object TableName,
Object RowGrand,
Object ColumnGrand,
Object SaveData,
Object HasAutoFormat,
Object AutoPage,
Object Reserved,
Object BackgroundQuery,
Object OptimizeCache,
Object PageFieldOrder,
Object PageFieldWrapCount,
Object ReadData,
Object Connection
)
Parameters
SourceType
Type: System.ObjectOptional Object. The source of the report data. Can be one of the XlPivotTableSourceType.constants.
SourceData
Type: System.ObjectOptional Object. The data for the new report. Can be a Range object, an array of ranges, or a text constant that represents the name of another report. For an external database, SourceData is an array of strings containing the SQL query string, where each element is up to 255 characters in length. You should use the Connection argument to specify the ODBC connection string. For compatibility with earlier versions of Excel, SourceData can be a two-element array. The first element is the connection string specifying the ODBC source for the data. The second element is the SQL query string used to get the data. If you specify SourceData, you must also specify SourceType. If the active cell is inside the SourceData range, you must specify TableDestination as well.
TableDestination
Type: System.ObjectOptional Object. A Range object specifying where the report should be placed on the worksheet. If this argument is omitted, the report is placed at the active cell.
TableName
Type: System.ObjectOptional Object. A string that specifies the name of the new report.
RowGrand
Type: System.ObjectOptional Object. True to show grand totals for rows in the report.
ColumnGrand
Type: System.ObjectOptional Object. True to show grand totals for columns in the report.
SaveData
Type: System.ObjectOptional Object. True to save data with the report. False to save only the report definition.
HasAutoFormat
Type: System.ObjectOptional Object. True to have Microsoft Excel automatically format the report when it’s refreshed or when fields are moved.
AutoPage
Type: System.ObjectOptional Object. Valid only if SourceType is xlConsolidation. True to have Microsoft Excel create a page field for the consolidation. If AutoPage is False, you must create the page field or fields.
Reserved
Type: System.ObjectOptional Object. Not used by Microsoft Excel.
BackgroundQuery
Type: System.ObjectOptional Object. True to have Excel perform queries for the report asynchronously (in the background). The default value is False.
OptimizeCache
Type: System.ObjectOptional Object. True to optimize the PivotTable cache when it's constructed. The default value is False.
PageFieldOrder
Type: System.ObjectOptional Object. The order in which page fields are added to the PivotTable report’s layout. Can be one of the following XlOrder constants: xlDownThenOver or xlOverThenDown. The default value is xlDownThenOver.
PageFieldWrapCount
Type: System.ObjectOptional Object. The number of page fields in each column or row in the PivotTable report. The default value is 0 (zero).
ReadData
Type: System.ObjectOptional Object. True to create a PivotTable cache that contains all records from the external database; this cache can be very large. If ReadData is False, you can set some of the fields as server-based page fields before the data is actually read.
Connection
Type: System.ObjectOptional Object. A string that contains ODBC settings that allow Excel to connect to an ODBC data source. The connection string has the form "ODBC;<connection string>". This argument overrides any previous setting for the PivotCache object’s Connection property.
Return Value
Type: Microsoft.Office.Interop.Excel.PivotTable