Forums     Knowledge Base     OfficeWriter Online     
 
 
This documentation is for
OfficeWriter v3.7.1
ASP/COM Platform

View Docs for Another
Version or Platform

Programmer's Reference > ExcelApplication > Objects > PivotTables

ExcelApplication is not
available in ExcelWriterSE.

The PivotTables Collection (IPivotTables)

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.
[VBScript] -->

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.

[VBScript] -->

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





Copyright 2006 © SoftArtisans, Inc. All Rights Reserved.