SpssPivotTable Class (Python)

The SpssPivotTable class allows you to operate on the table as a whole as well as providing access to objects for working with the footnotes, data cells, row or column labels, and layer labels associated with the table. Pivot tables are output items and are accessed from the list of output items associated with an output document.

Example: Getting Pivot Tables

import SpssClient
SpssClient.StartClient()

OutputDoc = SpssClient.GetDesignatedOutputDoc()
OutputItems = OutputDoc.GetOutputItems()

for index in range(OutputItems.Size()):
   OutputItem = OutputItems.GetItemAt(index)
   if OutputItem.GetType() == SpssClient.OutputItemType.PIVOT:
        PivotTable = OutputItem.GetSpecificType()
  • Pivot tables have an output item type of SpssClient.OutputItemType.PIVOT.
  • Once an output item has been identified as a pivot table, you get an SpssPivotTable object by calling the GetSpecificType method on the output item object. In this example, PivotTable is an SpssPivotTable object.

Example: Getting the First Selected Pivot Table

import SpssClient
SpssClient.StartClient()

OutputDoc = SpssClient.GetDesignatedOutputDoc()
OutputItems = OutputDoc.GetOutputItems()

for index in range(OutputItems.Size()):
   OutputItem = OutputItems.GetItemAt(index)
   if OutputItem.GetType() == SpssClient.OutputItemType.PIVOT \
      and OutputItem.IsSelected():
        PivotTable = OutputItem.GetSpecificType()

Example: Getting the First Pivot Table Labeled "Statistics"

import SpssClient
SpssClient.StartClient()

OutputDoc = SpssClient.GetDesignatedOutputDoc()
OutputItems = OutputDoc.GetOutputItems()

for index in range(OutputItems.Size()):
   OutputItem = OutputItems.GetItemAt(index)
   if OutputItem.GetType() == SpssClient.OutputItemType.PIVOT \
      and OutputItem.GetDescription() == "Statistics":
        PivotTable = OutputItem.GetSpecificType()