Class Slicer

切片器

代表篩選器控制項,用於以非協作方式篩選範圍、圖表和資料透視表。這個類別包含存取及修改現有切片器的相關方法。如要建立新的篩選器,請使用 Sheet.insertSlicer(range, anchorRowPos, anchorColPos)

方法

方法傳回類型簡短說明
getBackgroundColorObject()Color|null傳回 Slicer 的背景 Color
getColumnPosition()Integer|null傳回篩選器套用至篩選器資料範圍的欄位置 (以篩選器資料範圍為準),如果未設定欄位置,則傳回 null
getContainerInfo()ContainerInfo取得資料分割器在工作表中的位置資訊。
getFilterCriteria()FilterCriteria|null傳回 Slicer 的篩選條件,如果未設定篩選條件,則傳回 null
getRange()Range取得套用篩選器的資料範圍。
getTitle()String傳回 Slicer 的標題。
getTitleHorizontalAlignment()String取得標題的水平對齊方式。
getTitleTextStyle()TextStyle傳回 Slicer 標題的文字樣式。
isAppliedToPivotTables()Boolean傳回指定 Slicer 是否套用至資料透視表。
remove()void刪除篩選器。
setApplyToPivotTables(applyToPivotTables)Slicer設定是否要將指定的篩選器控制項套用至工作表中的資料透視表。
setBackgroundColor(color)Slicer設定 Slicer 的背景顏色。
setBackgroundColorObject(color)Slicer設定 Slicer 的背景 Color
setColumnFilterCriteria(columnPosition, filterCriteria)Slicer設定資料分割器的資料欄索引和篩選條件。
setPosition(anchorRowPos, anchorColPos, offsetX, offsetY)Slicer設定資料分割器在工作表中的顯示位置。
setRange(rangeApi)Slicer設定要套用篩選器的資料範圍。
setTitle(title)Slicer設定 Slicer 的標題。
setTitleHorizontalAlignment(horizontalAlignment)Slicer設定篩選器中標題的水平對齊方式。
setTitleTextStyle(textStyle)Slicer設定 Slicer 的文字樣式。

內容詳盡的說明文件

getBackgroundColorObject()

傳回 Slicer 的背景 Color

回攻員

Color|null - 這個交叉分析篩選器的背景顏色。如果未設定任何顏色,則傳回 null

授權

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

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

getColumnPosition()

傳回篩選器套用至篩選器時的資料欄位置 (相對於篩選器的資料範圍),如果未設定資料欄位置,則傳回 null。這應該是類似篩選器的欄的 1 索引位置。

回攻員

Integer|null:這個篩選器的欄位置。

授權

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

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

getContainerInfo()

取得資料分割器在工作表中的位置資訊。

回攻員

ContainerInfo:包含 Slicer 容器位置的物件。

授權

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

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

getFilterCriteria()

傳回 Slicer 的篩選條件,如果未設定篩選條件,則傳回 null

回攻員

FilterCriteria|null:這個切片器的篩選條件。

授權

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

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

getRange()

取得套用篩選器的資料範圍。

回攻員

Range - 篩選器範圍。

授權

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

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

getTitle()

傳回 Slicer 的標題。

回攻員

String - 這個切片器用於鏈結。

授權

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

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

getTitleHorizontalAlignment()

取得標題的水平對齊方式。

回攻員

String:這個 Slicer 標題的水平對齊方式。

授權

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

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

getTitleTextStyle()

傳回 Slicer 標題的文字樣式。

回攻員

TextStyle:這個篩選器的標題文字樣式。

授權

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

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

isAppliedToPivotTables()

傳回指定 Slicer 是否套用至資料透視表。

回攻員

Boolean:如果這個篩選器套用至資料透視表,則為 true,否則為 false

授權

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

  • 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

setApplyToPivotTables(applyToPivotTables)

設定是否要將指定的篩選器控制項套用至工作表中的資料透視表。

參數

名稱類型說明
applyToPivotTablesBoolean指定這個篩選器是否應套用至資料透視表。

回攻員

Slicer - 這個切片器用於鏈結。

授權

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

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

setBackgroundColor(color)

設定 Slicer 的背景顏色。null 值會重設背景顏色。

參數

名稱類型說明
colorString以 CSS 標記表示的篩選器新背景顏色 (例如「#ffffff」)。

回攻員

Slicer - 這個切片器用於鏈結。

授權

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

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

setBackgroundColorObject(color)

設定 Slicer 的背景 Colornull 值會重設背景顏色。

參數

名稱類型說明
colorColor這個篩選器的全新背景顏色。

回攻員

Slicer - 這個切片器用於鏈結。

授權

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

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

setColumnFilterCriteria(columnPosition, filterCriteria)

設定資料分割器的資料欄索引和篩選條件。null 值會重設篩選器。

參數

名稱類型說明
columnPositionInteger這個 Slicer 的新資料欄位置。
filterCriteriaFilterCriteria這個 Slicer 的新篩選條件。

回攻員

Slicer - 這個切片器用於鏈結。

授權

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

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

setPosition(anchorRowPos, anchorColPos, offsetX, offsetY)

設定篩選器在工作表中的顯示位置。錨定列和欄位置索引是以 1 為起始。

參數

名稱類型說明
anchorRowPosInteger這個資料列會固定為篩選器的頂端。
anchorColPosInteger這個 col 會錨定 Slicer 的頂端。
offsetXInteger以像素為單位的儲存格角落水平偏移。
offsetYInteger以像素為單位的儲存格角落垂直偏移。

回攻員

Slicer - 這個切片器用於鏈結。

授權

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

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

setRange(rangeApi)

設定要套用篩選器的資料範圍。

參數

名稱類型說明
rangeApiRange這個篩選器的全新範圍。

回攻員

Slicer - 這個切片器用於鏈結。

授權

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

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

setTitle(title)

設定 Slicer 的標題。如果標題為空白,系統會將標題重設為預設值。

參數

名稱類型說明
titleString這個 Slicer 的新標題。

回攻員

Slicer - 這個切片器用於鏈結。

授權

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

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

setTitleHorizontalAlignment(horizontalAlignment)

設定篩選器中標題的水平對齊方式。null 值會重設對齊方式。

參數

名稱類型說明
horizontalAlignmentString這個 Slicer 標題的新水平對齊方式。

回攻員

Slicer - 這個切片器用於鏈結。

授權

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

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

setTitleTextStyle(textStyle)

設定 Slicer 的文字樣式。

參數

名稱類型說明
textStyleTextStyle新的 Slicer 標題文字樣式。

回攻員

Slicer - 這個切片器用於鏈結。

授權

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

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

已淘汰的方法