存取及修改資料透視表細分群組。
方法
內容詳盡的說明文件
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