访问和修改数据透视表细分组。
方法
详细文档
addManualGroupingRule(groupName, groupMembers)
为此数据透视分组添加手动分组规则。
参数
名称 | 类型 | 说明 |
---|---|---|
groupName | String | 此分组规则的名称。 |
groupMembers | Object[] | 此分组规则中包含的值。 |
弃踢回攻
PivotGroup
- 用于链接的数据透视组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
areLabelsRepeated()
返回标签是否显示为重复。
弃踢回攻
Boolean
- 如果标签重复,则为 true
;否则返回 false
。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
clearGroupingRule()
从此数据透视分组中移除所有分组规则。
弃踢回攻
PivotGroup
- 用于链接的数据透视组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
clearSort()
移除对此群组应用的任何排序。
弃踢回攻
PivotGroup
- 用于链接的数据透视组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getDateTimeGroupingRule()
返回数据透视表的日期时间分组规则,如果未设置日期时间分组规则,则返回 null
。
弃踢回攻
DateTimeGroupingRule
- 日期时间分组规则。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getDimension()
getGroupLimit()
返回数据透视表元素组的限制。如果未设置数据透视表元素组限制,则返回 null
。
弃踢回攻
PivotGroupLimit
- 数据透视表元素组限制。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getIndex()
返回此数据透视分组在当前分组顺序中的索引。
弃踢回攻
Integer
- 数据透视组的索引
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getPivotTable()
返回此分组所属的 PivotTable
。
弃踢回攻
PivotTable
- 此群组所属的数据透视表。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getSourceDataColumn()
返回此组汇总的源数据列数。此索引从 1 开始,如果此组汇总了电子表格的“A”列中的源数据,则此方法会返回 1
。
弃踢回攻
Integer
- 源数据列编号
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getSourceDataSourceColumn()
返回数据透视组所处理的数据源列。如果数据透视表不是 {DataSourcePivotTableApi},则返回 null
。
弃踢回攻
DataSourceColumn
- 数据透视组所处理的数据源列。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
hideRepeatedLabels()
隐藏此分组的重复标签。如果标签已隐藏,则会导致空操作。如果在存在多个行或列分组之前调用此方法,则在添加其他分组时,会隐藏重复标签。
弃踢回攻
PivotGroup
- 用于链接的数据透视组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
isSortAscending()
如果排序是升序,则返回 true
;如果排序是降序,则返回 false
。
弃踢回攻
Boolean
- 如果排序顺序是升序,则为 true
。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
moveToIndex(index)
将该组移到当前行组或列组列表的指定位置。这些索引从 0 开始。例如,如果应将组移至第一个位置,则应使用 0
调用此方法。
参数
名称 | 类型 | 说明 |
---|---|---|
index | Integer | 要将此分组移至的索引。 |
弃踢回攻
PivotGroup
- 用于链接的数据透视组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
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
removeManualGroupingRule(groupName)
移除具有指定 groupName
的手动分组规则。
参数
名称 | 类型 | 说明 |
---|---|---|
groupName | String | 要移除的分组规则的名称。 |
弃踢回攻
PivotGroup
- 用于链接的数据透视组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
resetDisplayName()
将此组在数据透视表中的显示名称重置为默认值。
弃踢回攻
PivotGroup
- 用于链接的数据透视组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setDateTimeGroupingRule(dateTimeGroupingRuleType)
针对数据透视表设置日期时间分组规则。
如需移除规则,请使用 clearGroupingRule()
。
参数
名称 | 类型 | 说明 |
---|---|---|
dateTimeGroupingRuleType | DateTimeGroupingRuleType | 要设置的规则类型。 |
弃踢回攻
PivotGroup
- 用于串联的数据透视组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setDisplayName(name)
设置此组在数据透视表中的显示名称。
参数
名称 | 类型 | 说明 |
---|---|---|
name | String | 要设置的显示名称。 |
弃踢回攻
PivotGroup
- 用于链接的数据透视组
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setGroupLimit(countLimit)
为数据透视分组设置数据透视分组限制。只有 DataSourcePivotTable
支持此操作。
参数
名称 | 类型 | 说明 |
---|---|---|
countLimit | Integer | 要设置的行数或列数限制。必须为正值。 |
弃踢回攻
PivotGroup
- 用于链接的数据透视组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setHistogramGroupingRule(minValue, maxValue, intervalSize)
为此数据透视分组设置直方图分组规则。直方图规则将源数据列中的值整理到大小相同的存储分区中。从 minValue
到 maxValue
的所有值均按大小为 interval
的组进行分组。系统会将 minValue
以下的所有值和所有大于 maxValue
的值置于一个分桶中。
参数
名称 | 类型 | 说明 |
---|---|---|
minValue | Integer | 要放入存储分区的项的最小值。小于此值的值将合并到一个存储分区中。 |
maxValue | Integer | 要放入存储分区的项的最大值。大于此值的值将合并到一个存储分区中。 |
intervalSize | Integer |
弃踢回攻
PivotGroup
- 用于链接的数据透视组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
showRepeatedLabels()
如果有多个行或列分组,此方法会为后续分组的每个条目显示此分组的标签。如果标签已经重复,则会导致空操作。如果在存在多个行或列分组之前调用此方法,则在添加了其他分组时会显示重复的标签。
弃踢回攻
PivotGroup
- 用于链接的数据透视组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
showTotals(showTotals)
设置是否在表格中显示此数据透视表组的总值。
参数
名称 | 类型 | 说明 |
---|---|---|
showTotals | Boolean | 是否显示总计。 |
弃踢回攻
PivotGroup
- 用于链接的数据透视组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
sortAscending()
将排序顺序设置为升序。
弃踢回攻
PivotGroup
- 用于链接的数据透视组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
sortBy(value, oppositeGroupValues)
按 oppositeGroupValues
中的值的指定 PivotValue
对此群组进行排序。
// Sorts the item group by the "SUM of Quantity" pivot value for the specified salespersons. var sheet = SpreadsheetApp.getActiveSheet(); var pivotTable = sheet.getPivotTables()[0]; var itemGroup = pivotTable.getRowGroups()[0]; var sumQuantityValue = pivotTable.getPivotValues()[0]; itemGroup.sortBy(sumQuantityValue, ['Beth', 'Amir', 'Devyn']);
参数
名称 | 类型 | 说明 |
---|---|---|
value | PivotValue | 要排序的数据透视值。 |
oppositeGroupValues | Object[] | 用于排序的相反数据透视组(如果对行组排序,则为列组;如果对列组排序,则为行组)的值。这些值的顺序决定了决定平分的优先级。 |
弃踢回攻
PivotGroup
- 用于链接的数据透视组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
sortDescending()
将排序顺序设置为降序。
弃踢回攻
PivotGroup
- 用于链接的数据透视组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
totalsAreShown()
返回此数据透视组当前是否显示总计值。
弃踢回攻
Boolean
- 如果显示此数据透视组的总计值,则为 true
;否则返回 false
。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets