Show code in...     

  

 

Object Model ExcelApplication Worksheets Worksheet Cells Cell Range
Charts Chart SeriesCollection Series 3DProperties Axis ChartFrame Line Area
PivotField PivotFields PivotTable PivotTables
Style Characters Font Pictures Picture DocumentProperties PageSetup


The PivotTables Collection (IPivotTables)

New


* The PivotTables collection is not available in ExcelWriterSE, ExcelWriterLE, or ExcelWriterFree.

The IPivotTables collection represents the set of PivotTables in a worksheet. Use the property WorkSheet.PivotTables to access the IPivotTables collection, for example:

[VBScript]
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")

'--- Open the workbook containing source data for the PivotTable.
XlwApp.Open "c:\reports\pivotdata.xls"

'--- Get a reference to the source data sheet.
Set wsData = XlwApp.Worksheets("DataSheet")	

'--- Create a second worksheet and name it PivotSheet.
Set wsPivot = XlwApp.Worksheets(2)
wsPivot.Name = "PivotSheet"

'--- The data in the workbook is in a named range called 
'--- DataNamedRange.  Get an SARange object representing 
'--- that range.
Set rngData = XlwApp.NamedRange("DataNamedRange")

'--- Pass CreatePivotTable the range of source data to 
'--- create the PivotTable.
Set pvtTable = wsPivot.PivotTables.CreatePivotTable(rngData, 2, 2)
...
IPivotTables Properties IPivotTables Methods
IPivotTables Properties
Count
Signature
[VBScript]
Property Count As Long (read-only)
Description
Count returns the number of PivotTables in the IPivotTables collection.

Top

Item
Signature
[VBScript]
Property Item(Table As Variant) As IPivotTable (read-only)
Description

Item represents a single PivotTable in a IPivotTables collection. In VBScript, Item is the default property of the IPivotTables object, so IPivotTables(1) is equivalent to IPivotTables.Item(1). You can reference an Item either by number or by name.

In C#, Item is the indexer for the IPivotTables class.

Top



IPivotTables Methods
CreatePivotTable
Signature
[VBScript]
Function CreatePivotTable(aDataRange As SARange, 
			aRow As Long, 
			aColumn As Long) 
			As IPivotTable
Description

CreatePivotTable takes a range of cells containing source data and creates a new PivotTable. The method takes three parameters:

aDataRange An SARange object containing the source data for the PivotTable. The range must be a contiguous region of data with no skipped columns.
aRow aRow and aColumn specify where to put the PivotTable (the table's upper left corner) in the specified worksheet.
aColumn
Example
[VBScript]
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")

'--- Open the workbook containing source data for the PivotTable.
XlwApp.Open "c:\reports\pivotdata.xls"

'--- Get a reference to the source data sheet.
Set wsData = XlwApp.Worksheets("DataSheet")	

'--- Create a second worksheet and name it PivotSheet.
Set wsPivot = XlwApp.Worksheets(2)
wsPivot.Name = "PivotSheet"

'--- The data in the workbook is in a named range called 
'--- DataNamedRange.  Get an SARange object representing 
'--- that range.
Set rngData = XlwApp.NamedRange("DataNamedRange")

'--- Pass CreatePivotTable the range of source data to 
'--- create the PivotTable.
Set pvtTable = wsPivot.PivotTables.CreatePivotTable(rngData, 2, 2)
...

Top



Object Model ExcelApplication Worksheets Worksheet Cells Cell Range
Charts Chart SeriesCollection Series 3DProperties Axis ChartFrame Line Area
PivotField PivotFields PivotTable PivotTables
Style Characters Font Pictures Picture DocumentProperties PageSetup


Copyright © 2005, SoftArtisans, Inc.