Stay organized with collections Save and categorize content based on your preferences.
PivotTableAccess and modify pivot tables.
Detailed documentationaddCalculatedPivotValue(name, formula)
Creates a new pivot value in the pivot table calculated from the specified formula
with the specified name
.
name
String
The name for this calculated pivot value. formula
String
The formula used to calculate this value. Return
PivotValue
— the newly created PivotValue
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
addColumnGroup(sourceDataColumn)
Defines a new pivot column grouping in the pivot table. The specified sourceDataColumn
indicates the column in the source data this grouping is based on.
sourceDataColumn
Integer
The number of the column this group summarizes. This index represents the absolute number of the column in the spreadsheet; 1
representing column "A," 2
representing column B, etc. Return
PivotGroup
— the newly created PivotGroup
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
addFilter(sourceDataColumn, filterCriteria)
Creates a new pivot filter for the pivot table. The specified sourceDataColumn
indicates the column in the source data this filter operates on.
sourceDataColumn
Integer
The number of the column this group summarizes. This index represents the absolute number of the column in the spreadsheet; 1
representing column "A," 2
representing column B, etc. filterCriteria
FilterCriteria
The filter criteria used to perform the filtering. Return
PivotFilter
— the newly created PivotFilter
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
addPivotValue(sourceDataColumn, summarizeFunction)
Defines a new pivot value in the pivot table with the specified summarizeFunction
. The specified sourceDataColumn
indicates the column in the source data this value is based on.
sourceDataColumn
Integer
The number of the column this group summarizes. This index represents the absolute number of the column in the spreadsheet; 1
representing column "A," 2
representing column B, etc. summarizeFunction
PivotTableSummarizeFunction
Return
PivotValue
— the newly created PivotValue
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
addRowGroup(sourceDataColumn)
Defines a new pivot row grouping in the pivot table. The specified sourceDataColumn
indicates the column in the source data this grouping is based on.
sourceDataColumn
Integer
The number of the column this group summarizes. This index represents the absolute number of the column in the spreadsheet; 1
representing column "A," 2
representing column B, etc. Return
PivotGroup
— the newly created PivotGroup
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
asDataSourcePivotTable()
Returns the pivot table as a data source pivot table if the pivot table is linked to a DataSource
, or null
otherwise.
DataSourcePivotTable
— A data source pivot table.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
getAnchorCell()
Returns the Range
representing the cell where this pivot table is anchored.
Range
— this pivot table's anchor cell
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
getColumnGroups()
Returns an ordered list of the column groups in this pivot table.
ReturnPivotGroup[]
— the column groups in this pivot table
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
getFilters()
Returns an ordered list of the filters in this pivot table.
ReturnPivotFilter[]
— the filters in this pivot table
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
getPivotValues()
Returns an ordered list of the pivot values in this pivot table.
ReturnPivotValue[]
— the pivot values in this pivot table
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
getRowGroups()
Returns an ordered list of the row groups in this pivot table.
ReturnPivotGroup[]
— the row groups in this pivot table
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
getSourceDataRange()
Returns the source data range on which the pivot table is constructed.
ReturnRange
— The source data range of this pivot table.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
getValuesDisplayOrientation()
Returns whether values are displayed as rows or columns.
ReturnDimension
— whether values are displayed as rows or columns
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
remove()
Deletes this pivot table. Further operations on this pivot table results in an error.
AuthorizationScripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
setValuesDisplayOrientation(dimension)
Sets the layout of this pivot table to display values as columns or rows.
Parameters Name Type Descriptiondimension
Dimension
The dimension indicating how to display pivot values. Return
PivotTable
— the pivot table for chaining
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-03 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-03 UTC."],[[["The `PivotTable` class allows programmatic access and modification of pivot tables within Google Sheets."],["Developers can utilize methods to add calculated values, define row/column groupings, apply filters, and manage the overall structure of pivot tables."],["The `PivotTable` object provides functionalities to retrieve its anchor cell, source data range, column/row groups, filters, and pivot values, giving comprehensive control."],["It offers features to modify the layout, like setting the display orientation for values as rows or columns, and can be completely removed using the `remove()` method."],["Each method within the `PivotTable` class requires specific authorization scopes to ensure secure access and manipulation of spreadsheet data."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4