Class PivotTable

資料透視表

存取及修改資料透視表。

方法

方法傳回類型簡短說明
addCalculatedPivotValue(name, formula)PivotValue在資料透視表中建立新的透視值,該值是根據指定 formulaname 計算而得。
addColumnGroup(sourceDataColumn)PivotGroup在資料透視表中定義新的透視欄分組。
addFilter(sourceDataColumn, filterCriteria)PivotFilter為資料透視表建立新的資料透視篩選器。
addPivotValue(sourceDataColumn, summarizeFunction)PivotValue在資料透視表中,使用指定的 summarizeFunction 定義新的資料透視值。
addRowGroup(sourceDataColumn)PivotGroup在資料透視表中定義新的資料透視列分組。
asDataSourcePivotTable()DataSourcePivotTable|null如果資料透視表已連結至 DataSource,則傳回資料透視表做為資料來源資料透視表,否則傳回 null
getAnchorCell()Range傳回代表這個資料透視表錨定儲存格的 Range
getColumnGroups()PivotGroup[]傳回這個資料透視表中的資料欄群組排序清單。
getFilters()PivotFilter[]傳回這個樞紐分析表中的篩選器排序清單。
getPivotValues()PivotValue[]傳回這份資料透視表中的資料透視值排序清單。
getRowGroups()PivotGroup[]傳回這個資料透視表中的列群組排序清單。
getSourceDataRange()Range傳回資料透視表所依據的來源資料範圍。
getValuesDisplayOrientation()Dimension傳回值是否顯示為資料列或資料欄。
remove()void刪除這個資料透視表。
setValuesDisplayOrientation(dimension)PivotTable設定這個資料透視表的版面配置,以欄或列的形式顯示值。

內容詳盡的說明文件

addCalculatedPivotValue(name, formula)

在資料透視表中建立新的透視值,該值是根據指定 formulaname 計算而得。

參數

名稱類型說明
nameString這個計算樞紐值的名稱。
formulaString計算這個值的公式。

回攻員

PivotValue:新建立的 PivotValue

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

addColumnGroup(sourceDataColumn)

在資料透視表中定義新的透視欄分組。指定的 sourceDataColumn 代表這個分組依據的來源資料欄。

參數

名稱類型說明
sourceDataColumnInteger這個群組匯總的欄數。這個索引代表試算表中的絕對欄數;1 代表「A」欄,2 代表 B 欄,依此類推。

回攻員

PivotGroup:新建立的 PivotGroup

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

addFilter(sourceDataColumn, filterCriteria)

為資料透視表建立新的資料透視篩選器。指定的 sourceDataColumn 表示篩選器要處理的來源資料欄。

參數

名稱類型說明
sourceDataColumnInteger這個群組匯總的欄數。這個索引代表試算表中的絕對欄數;1 代表「A」欄,2 代表 B 欄,依此類推。
filterCriteriaFilterCriteria用於執行篩選作業的篩選條件。

回攻員

PivotFilter:新建立的 PivotFilter

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

addPivotValue(sourceDataColumn, summarizeFunction)

在資料透視表中,使用指定的 summarizeFunction 定義新的資料透視值。指定 sourceDataColumn:指出這個值所依據的來源資料欄。

參數

名稱類型說明
sourceDataColumnInteger這個群組匯總的欄數。這個索引代表試算表中的絕對欄數;1 代表「A」欄,2 代表 B 欄,依此類推。
summarizeFunctionPivotTableSummarizeFunction

回攻員

PivotValue:新建立的 PivotValue

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

addRowGroup(sourceDataColumn)

在資料透視表中定義新的資料透視列分組。指定的 sourceDataColumn 代表這個分組依據的來源資料欄。

參數

名稱類型說明
sourceDataColumnInteger這個群組匯總的欄數。這個索引代表試算表中的絕對欄數;1 代表「A」欄,2 代表 B 欄,依此類推。

回攻員

PivotGroup:新建立的 PivotGroup

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

asDataSourcePivotTable()

如果資料透視表已連結至 DataSource,則傳回資料透視表做為資料來源資料透視表,否則傳回 null

回攻員

DataSourcePivotTable|null - 資料來源資料透視表。

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

getAnchorCell()

傳回代表這個資料透視表錨定儲存格的 Range

回攻員

Range - 這個資料透視表的錨定儲存格

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

getColumnGroups()

傳回這個資料透視表中的資料欄群組排序清單。

回攻員

PivotGroup[]:這個資料透視表中的欄群組

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

getFilters()

傳回這個樞紐分析表中的篩選器排序清單。

回攻員

PivotFilter[]:這個資料透視表中的篩選器

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

getPivotValues()

傳回這份資料透視表中的資料透視值排序清單。

回攻員

PivotValue[]:這份資料透視表中的資料透視值

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

getRowGroups()

傳回這個資料透視表中的列群組排序清單。

回攻員

PivotGroup[]:這個資料透視表中的列群組

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

getSourceDataRange()

傳回資料透視表所依據的來源資料範圍。

回攻員

Range - 這個資料透視表的來源資料範圍。

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

getValuesDisplayOrientation()

傳回值是否顯示為資料列或資料欄。

回攻員

Dimension:值是以資料列或資料欄的形式顯示

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

  • 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

setValuesDisplayOrientation(dimension)

設定這個資料透視表的版面配置,以欄或列的形式顯示值。

參數

名稱類型說明
dimensionDimension指出如何顯示樞紐分析表值的維度。

回攻員

PivotTable:用於串連的樞紐資料表

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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