Class PivotGroup

PivotGroup

存取及修改資料透視表細分群組。

方法

方法傳回類型簡短說明
addManualGroupingRule(groupName, groupMembers)PivotGroup為這個資料透視表新增手動分組規則。
areLabelsRepeated()Boolean傳回標籤是否重複顯示。
clearGroupingRule()PivotGroup用於移除這個資料透視表群組的所有分組規則。
clearSort()PivotGroup移除套用至這個群組的任何排序方式。
getDateTimeGroupingRule()DateTimeGroupingRule傳回資料透視表的日期時間分組規則;如未設定日期時間分組規則,則傳回 null
getDimension()Dimension傳回這是資料列或欄群組。
getGroupLimit()PivotGroupLimit傳回資料透視表群組的資料透視表元素群組限制。
getIndex()Integer以目前的群組順序傳回這個資料透視表群組的索引。
getPivotTable()PivotTable傳回這個分組所屬的 PivotTable
getSourceDataColumn()Integer傳回這個群組摘要的來源資料欄數量。
getSourceDataSourceColumn()DataSourceColumn傳回資料透視表執行時所在的資料來源資料欄。
hideRepeatedLabels()PivotGroup隱藏此分組的重複標籤。
isSortAscending()Boolean如果排序是遞增,則傳回 true。如果排序順序為遞減,則傳回 false
moveToIndex(index)PivotGroup將這個群組移至目前列或欄群組清單內的指定位置。
remove()void從表格中移除這個資料透視表元素。
removeManualGroupingRule(groupName)PivotGroup移除包含指定 groupName 的手動分組規則。
resetDisplayName()PivotGroup將資料透視表中這個群組的顯示名稱重設為預設值。
setDateTimeGroupingRule(dateTimeGroupingRuleType)PivotGroup為資料透視表設定日期時間分組規則。
setDisplayName(name)PivotGroup設定這個群組在資料透視表中的顯示名稱。
setGroupLimit(countLimit)PivotGroup設定資料透視表元素分組的限制。
setHistogramGroupingRule(minValue, maxValue, intervalSize)PivotGroup為這個資料透視表設定直方圖分組規則。
showRepeatedLabels()PivotGroup如有多個資料列或資料欄分組,這個方法會針對後續分組的每個項目顯示這個群組的標籤。
showTotals(showTotals)PivotGroup設定是否要在表格中顯示這個資料透視表群組的總值。
sortAscending()PivotGroup將排序順序設為遞增。
sortBy(value, oppositeGroupValues)PivotGroup針對 oppositeGroupValues 中的值,按照指定的 PivotValue 為這個群組排序。
sortDescending()PivotGroup將排序順序設為遞減。
totalsAreShown()Boolean傳回系統目前是否顯示這個資料透視表群組的總值。

內容詳盡的說明文件

addManualGroupingRule(groupName, groupMembers)

為這個資料透視表新增手動分組規則。

參數

名稱類型說明
groupNameString這項分組規則的名稱。
groupMembersObject[]這項分組規則包含的值。

回攻員

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()

傳回這是資料列或欄群組。

回攻員

Dimension:代表這個群組類型的維度

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

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 呼叫這個方法。

參數

名稱類型說明
indexInteger要將這個分組移至哪個索引。

回攻員

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 的手動分組規則。

參數

名稱類型說明
groupNameString要移除的分組規則名稱。

回攻員

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()

參數

名稱類型說明
dateTimeGroupingRuleTypeDateTimeGroupingRuleType要設定的規則類型。

回攻員

PivotGroup — 用於鏈結的資料透視表群組。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setDisplayName(name)

設定這個群組在資料透視表中的顯示名稱。

參數

名稱類型說明
nameString要設定的顯示名稱。

回攻員

PivotGroup:用於鏈結的樞紐分析群組

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setGroupLimit(countLimit)

設定資料透視表元素分組的限制。這項操作僅適用於 DataSourcePivotTable

參數

名稱類型說明
countLimitInteger要設定的資料列或資料欄數量限制。必須為正數。

回攻員

PivotGroup — 用於鏈結的資料透視群組。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setHistogramGroupingRule(minValue, maxValue, intervalSize)

為這個資料透視表設定直方圖分組規則。直方圖規則會將來源資料欄中的值整理為常數大小的值區,minValuemaxValue 的所有值都會放在 interval 大小的群組。minValue 以下的所有值都會放在一個值區中,如所有大於 maxValue 的值。

參數

名稱類型說明
minValueInteger要放置在區塊中項目的最小值。小於這個值的值會合併為單一值區。
maxValueInteger要放置在區塊中的項目最大值。大於這個值的值會合併為單一值區。
intervalSizeInteger

回攻員

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)

設定是否要在表格中顯示這個資料透視表群組的總值。

參數

名稱類型說明
showTotalsBoolean是否要顯示總計。

回攻員

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']);

參數

名稱類型說明
valuePivotValue要排序的資料透視值。
oppositeGroupValuesObject[]相反資料透視表群組的值 (將資料列群組排序,則為欄群組;如果排序資料欄群組,則為資料列群組)。這些值的順序決定了平鋪中斷的優先順序。

回攻員

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