Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
提供意見
Class 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()
傳回篩選器的篩選條件,如果未設定篩選條件,則傳回 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()
傳回篩選器控制項標題的文字樣式。
回攻員
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)
設定是否要將指定的篩選器控制項套用至工作表中的資料透視表。
參數
名稱 類型 說明
apply To Pivot TablesBoolean指定這個篩選器是否應套用至資料透視表。
回攻員
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)
設定切片器的背景 Color 。null 值會重設背景顏色。
參數
名稱 類型 說明
colorColor 這個篩選器控制項的全新背景顏色。
回攻員
Slicer - 這個切片器用於鏈結。
授權
使用這個方法的指令碼需要下列一或多個範圍 的授權:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
setColumnFilterCriteria(columnPosition, filterCriteria)
設定資料分割器的資料欄索引和篩選條件。null 值會重設篩選器。
參數
名稱 類型 說明
column PositionInteger這個 Slicer 的新資料欄位置。
filter CriteriaFilter Criteria 這個 Slicer 的新篩選條件。
回攻員
Slicer - 這個切片器用於鏈結。
授權
使用這個方法的指令碼需要下列一或多個範圍 的授權:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
setPosition(anchorRowPos, anchorColPos, offsetX, offsetY)
設定篩選器在工作表中的顯示位置。錨定列和欄位置索引是以 1 為起始。
參數
名稱 類型 說明
anchor Row PosInteger這個資料列會錨定 Slicer 的頂端。
anchor Col PosInteger這個 col 會錨定 Slicer 的頂端。
offsetXInteger以像素為單位的儲存格角落水平偏移。
offsetYInteger以像素為單位的儲存格角落垂直偏移。
回攻員
Slicer - 這個切片器用於鏈結。
授權
使用這個方法的指令碼需要下列一或多個範圍 的授權:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
setRange(rangeApi)
設定要套用篩選器的資料範圍。
參數
名稱 類型 說明
range ApiRange 這個篩選器控制項的全新範圍。
回攻員
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 值會重設對齊方式。
參數
名稱 類型 說明
horizontal AlignmentString這個 Slicer 標題的新水平對齊方式。
回攻員
Slicer - 這個切片器用於鏈結。
授權
使用這個方法的指令碼需要下列一或多個範圍 的授權:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
setTitleTextStyle(textStyle)
設定篩選器控制項的文字樣式。
參數
回攻員
Slicer - 這個切片器用於鏈結。
授權
使用這個方法的指令碼需要下列一或多個範圍 的授權:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
已淘汰的方法
getBackgroundColor()
已淘汰。 已替換為 getBackgroundColorObject()
以 CSS 標記 (例如「#ffffff」) 傳回篩選器的背景顏色。
回攻員
String|null - 這個交叉分析篩選器的背景顏色。如果未設定任何顏色,則傳回 null。
授權
使用這個方法的指令碼需要下列一或多個範圍 的授權:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
提供意見
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權 ,程式碼範例則為阿帕契 2.0 授權 。詳情請參閱《Google Developers 網站政策 》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2026-04-13 (世界標準時間)。
想進一步說明嗎?
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2026-04-13 (世界標準時間)。"],[],["Slicers filter ranges, charts, and pivot tables. Key actions include: retrieving and modifying slicer properties like background color, column position, filter criteria, data range, and title. Slicers can be positioned and have their applicability to pivot tables set. You can also manage the title's horizontal alignment and text style. Slicers are created using `Sheet.insertSlicer`. The method to remove a slicer is `remove()`. The old method to obtain background colors is deprecated and should be replaced by `getBackgroundColorObject()`.\n"]]