访问和修改数据透视表细分群组。
方法
详细文档
add Manual Grouping Rule(groupName, groupMembers)
为此透视组添加手动分组规则。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
group | String | 相应分组规则的名称。 |
group | Object[] | 相应分组规则中包含的值。 |
返回
Pivot - 用于链接的透视组。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
are Labels Repeated()
返回标签是否显示为重复。
返回
Boolean - 如果标签重复,则为 true;否则返回 false。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
clear Grouping Rule()
从相应透视组中移除所有分组规则。
返回
Pivot - 用于链接的透视组。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
clear Sort()
移除应用于相应群组的所有排序。
返回
Pivot - 用于链接的透视组。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Date Time Grouping Rule()
返回透视组的日期时间分组规则;如果未设置日期时间分组规则,则返回 null。
返回
Date - 日期时间分组规则。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Dimension()
get Group Limit()
返回透视组的透视组限制。如果未设置数据透视表元素组限制,则返回 null。
返回
Pivot - 数据透视表元素组限制。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Index()
返回相应透视组在当前组顺序中的索引。
返回
Integer - 透视组的索引
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Pivot Table()
返回相应分组所属的 Pivot。
返回
Pivot - 此组所属的数据透视表。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Source Data Column()
返回相应组汇总的源数据列的数量。此索引从 1 开始,如果此组汇总了电子表格中“A”列的源数据,则此方法会返回 1。
返回
Integer - 源数据列号
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Source Data Source Column()
返回透视组所处理的数据源列。如果数据透视表不是 {DataSourcePivotTableApi},则返回 null。
返回
Data - 数据透视组所处理的数据源列。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
hide Repeated Labels()
隐藏相应分组的重复标签。如果标签已隐藏,则此方法不会执行任何操作。 如果在有多个行或列分组之前调用此方法,则在添加其他分组时,重复的标签会被隐藏。
返回
Pivot - 用于链接的透视组。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
is Sort Ascending()
如果排序顺序为升序,则返回 true;如果排序顺序为降序,则返回 false。
返回
Boolean - true(如果排序顺序为升序)。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
move To Index(index)
将此组移动到当前行组或列组列表中的指定位置。这些指数从 0 开始。例如,如果此群组应移至第一个位置,则应使用 0 调用此方法。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
index | Integer | 要将相应分组移至的索引。 |
返回
Pivot - 用于链接的透视组。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
remove()
从表格中移除相应透视组。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
remove Manual Grouping Rule(groupName)
移除具有指定 group 的手动分组规则。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
group | String | 要移除的分组规则的名称。 |
返回
Pivot - 用于链接的透视组。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
reset Display Name()
将数据透视表中相应群组的显示名称重置为默认值。
返回
Pivot - 用于链接的透视组。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Date Time Grouping Rule(dateTimeGroupingRuleType)
设置透视组的日期时间分组规则。
如需移除规则,请使用 clear。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
date | Date | 要设置的规则类型。 |
返回
Pivot - 用于链接的透视组。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Display Name(name)
设置透视表中相应组的显示名称。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
name | String | 要设置的显示名称。 |
返回
Pivot - 用于链接的透视组
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Group Limit(countLimit)
设置数据透视表元素组的数据透视表元素组限制。此操作仅支持 Data。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
count | Integer | 要设置的行数或列数上限。必须为正值。 |
返回
Pivot - 用于链接的透视组。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Histogram Grouping Rule(minValue, maxValue, intervalSize)
为此透视组设置直方图分组规则。直方图规则会将源数据列中的值整理到大小恒定的桶中。从 min 到 max 的所有值都将放入大小为 interval 的组中。所有低于 min 的值以及所有高于 max 的值都将放入一个分桶中。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
min | Integer | 商品归入相应分桶的最低价值。小于此值的值会合并到一个分桶中。 |
max | Integer | 要放入分桶中的商品的最大值。大于此值的值会合并到一个分桶中。 |
interval | Integer |
返回
Pivot - 用于链接的透视组。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
show Repeated Labels()
如果存在多个行或列分组,此方法会针对后续分组的每个条目显示相应分组的标签。如果标签已重复,则此方法不会执行任何操作。如果此方法是在存在多个行或列分组之前调用的,那么在添加其他分组时,系统会显示重复的标签。
返回
Pivot - 用于链接的透视组。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
show Totals(showTotals)
设置是否在表格中显示相应数据透视分组的总值。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
show | Boolean | 是否显示总计。 |
返回
Pivot - 用于链接的透视组。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
sort Ascending()
将排序顺序设置为升序。
返回
Pivot - 用于链接的透视组。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
sort By(value, oppositeGroupValues)
按指定 Pivot 对来自 opposite 的值进行排序。
// Sorts the item group by the "SUM of Quantity" pivot value for the specified // salespersons. const sheet = SpreadsheetApp.getActiveSheet(); const pivotTable = sheet.getPivotTables()[0]; const itemGroup = pivotTable.getRowGroups()[0]; const sumQuantityValue = pivotTable.getPivotValues()[0]; itemGroup.sortBy(sumQuantityValue, ['Beth', 'Amir', 'Devyn']);
参数
| 名称 | 类型 | 说明 |
|---|---|---|
value | Pivot | 要排序的数据透视值。 |
opposite | Object[] | 用于排序的相反透视组(如果对行组进行排序,则为列组;如果对列组进行排序,则为行组)的值。这些值的顺序决定了打破平局的优先级。 |
返回
Pivot - 用于链接的透视组。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
sort Descending()
将排序顺序设置为降序。
返回
Pivot - 用于链接的透视组。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
totals Are Shown()
返回相应透视组是否目前显示总值。
返回
Boolean - 如果显示相应透视组的总值,则为 true;否则为 false。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets