访问和修改数据透视表。
方法
| 方法 | 返回类型 | 简介 |
|---|---|---|
add | Pivot | 根据指定的 formula 和 name,在数据透视表中创建一个新的数据透视值。 |
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 | 设置相应数据透视表的布局,以将值显示为列或行。 |
详细文档
add Calculated Pivot Value(name, formula)
根据指定的 formula 和 name,在数据透视表中创建一个新的数据透视值。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
name | String | 相应计算出的透视值的名称。 |
formula | String | 用于计算此值的公式。 |
返回
Pivot - 新创建的 Pivot
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
add Column Group(sourceDataColumn)
在数据透视表中定义新的数据透视列分组。指定的 source 表示此分组所依据的源数据中的列。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
source | Integer | 相应组所汇总的列的编号。此索引表示电子表格中列的绝对编号;1 表示列“A”,2 表示列 B,依此类推。 |
返回
Pivot - 新创建的 Pivot
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
add Filter(sourceDataColumn, filterCriteria)
为数据透视表创建新的数据透视过滤条件。指定的 source 表示此过滤条件所作用的源数据中的列。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
source | Integer | 相应组所汇总的列的编号。此索引表示电子表格中列的绝对编号;1 表示列“A”,2 表示列 B,依此类推。 |
filter | Filter | 用于执行过滤的过滤条件。 |
返回
Pivot - 新创建的 Pivot
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
add Pivot Value(sourceDataColumn, summarizeFunction)
在数据透视表中定义具有指定 summarize 的新透视值。指定的 source 表示此值所依据的源数据中的列。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
source | Integer | 相应组所汇总的列的编号。此索引表示电子表格中列的绝对编号;1 表示列“A”,2 表示列 B,依此类推。 |
summarize | Pivot |
返回
Pivot - 新创建的 Pivot
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
add Row Group(sourceDataColumn)
在数据透视表中定义新的数据透视行分组。指定的 source 表示此分组所依据的源数据中的列。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
source | Integer | 相应组所汇总的列的编号。此索引表示电子表格中列的绝对编号;1 表示列“A”,2 表示列 B,依此类推。 |
返回
Pivot - 新创建的 Pivot
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
as Data Source Pivot Table()
如果数据透视表已关联到 Data,则返回数据透视表作为数据源数据透视表;否则返回 null。
返回
Data - 数据源数据透视表。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Anchor Cell()
get Column Groups()
返回相应透视表中列组的有序列表。
返回
Pivot - 此数据透视表中的列组
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Filters()
返回相应透视表中过滤器的有序列表。
返回
Pivot - 此数据透视表中的过滤条件
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Pivot Values()
返回相应数据透视表中数据透视值的有序列表。
返回
Pivot - 此数据透视表中的透视值
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Row Groups()
返回相应透视表中行组的有序列表。
返回
Pivot - 此数据透视表中的行组
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Source Data Range()
get Values Display Orientation()
remove()
删除相应的数据透视表。对相应数据透视表执行进一步操作会导致错误。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Values Display Orientation(dimension)
设置相应数据透视表的布局,以将值显示为列或行。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
dimension | Dimension | 用于指明如何显示透视值的维度。 |
返回
Pivot - 用于链接的数据透视表
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets