访问和修改数据透视表。
方法
| 方法 | 返回值类型 | 简介 |
|---|---|---|
add | Pivot | 使用指定的 name,根据指定的 formula 在数据透视表中创建一个新的数据透视值。 |
add | Pivot | 在数据透视表中定义一个新的数据透视列分组。 |
add | Pivot | 为数据透视表创建一个新的数据透视过滤条件。 |
add | Pivot | 使用指定的 summarize 在数据透视表中定义一个新的数据透视值。 |
add | Pivot | 在数据透视表中定义一个新的数据透视行分组。 |
as | Data | 如果数据透视表链接到 Data,则将数据透视表作为数据源数据透视表返回;否则返回 null。 |
get | Range | 返回表示此数据透视表所锚定的单元格的 Range。 |
get | Pivot | 返回此数据透视表中的列分组的有序列表。 |
get | Pivot | 返回此数据透视表中的过滤条件的有序列表。 |
get | Pivot | 返回此数据透视表中的数据透视值的有序列表。 |
get | Pivot | 返回此数据透视表中的行分组的有序列表。 |
get | Range | 返回用于构建数据透视表的源数据范围。 |
get | Dimension | 返回值是显示为行还是列。 |
remove() | void | 删除此数据透视表。 |
set | Pivot | 设置此数据透视表的布局,以将值显示为列或行。 |
详细文档
addCalculatedPivotValue(name, formula)
使用指定的 name,根据指定的 formula 在数据透视表中创建一个新的数据透视值。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
name | String | 此计算出的数据透视值的名称。 |
formula | String | 用于计算此值的公式。 |
返回
PivotValue - 新创建的 PivotValue
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
addColumnGroup(sourceDataColumn)
在数据透视表中定义一个新的数据透视列分组。指定的 sourceDataColumn 表示此分组所基于的源数据中的列。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
source | Integer | 此组汇总的列数。此索引表示
电子表格中列的绝对编号;1表示列“A”,
2表示列 B,依此类推。 |
返回
PivotGroup - 新创建的 PivotGroup
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
addFilter(sourceDataColumn, filterCriteria)
为数据透视表创建一个新的数据透视过滤条件。指定的 sourceDataColumn 表示此过滤条件所作用的源数据中的列。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
source | Integer | 此组汇总的列数。此索引表示
电子表格中列的绝对编号;1表示列“A”,
2表示列 B,依此类推。 |
filter | Filter | 用于执行过滤的过滤条件。 |
返回
PivotFilter - 新创建的 PivotFilter
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
addPivotValue(sourceDataColumn, summarizeFunction)
使用指定的 summarizeFunction 在数据透视表中定义一个新的数据透视值。指定的 sourceDataColumn 表示此值所基于的源数据中的列。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
source | Integer | 此组汇总的列数。此索引表示
电子表格中列的绝对编号;1表示列“A”,
2表示列 B,依此类推。 |
summarize | Pivot |
返回
PivotValue - 新创建的 PivotValue
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
addRowGroup(sourceDataColumn)
在数据透视表中定义一个新的数据透视行分组。指定的 sourceDataColumn 表示此分组所基于的源数据中的列。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
source | Integer | 此组汇总的列数。此索引表示
电子表格中列的绝对编号;1表示列“A”,
2表示列 B,依此类推。 |
返回
PivotGroup - 新创建的 PivotGroup
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
asDataSourcePivotTable()
如果数据透视表链接到 DataSource,则将数据透视表作为数据源数据透视表返回;否则返回 null。
返回
DataSourcePivotTable|null - 数据源数据透视表。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
getAnchorCell()
getColumnGroups()
返回此数据透视表中的列分组的有序列表。
返回
PivotGroup[] - 此数据透视表中的列分组
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
getFilters()
返回此数据透视表中的过滤条件的有序列表。
返回
PivotFilter[] - 此数据透视表中的过滤条件
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
getPivotValues()
返回此数据透视表中的数据透视值的有序列表。
返回
PivotValue[] - 此数据透视表中的数据透视值
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
getRowGroups()
返回此数据透视表中的行分组的有序列表。
返回
PivotGroup[] - 此数据透视表中的行分组
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
getSourceDataRange()
getValuesDisplayOrientation()
remove()
删除此数据透视表。对此数据透视表执行进一步操作会导致错误。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
setValuesDisplayOrientation(dimension)
设置此数据透视表的布局,以将值显示为列或行。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
dimension | Dimension | 指示如何显示数据透视值的维度。 |
返回
PivotTable - 用于链接的数据透视表
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets