表示一个切片器,用于以非协作方式过滤范围、图表和数据透视表。此类包含用于访问和修改现有切片器的方法。如需创建新的切片器,请使用 Sheet.insertSlicer(range, anchorRowPos, anchorColPos)。
方法
| 方法 | 返回类型 | 简介 |
|---|---|---|
get | Color|null | 返回切片器的背景 Color。 |
get | Integer|null | 返回切片器中应用过滤条件的列位置(相对于切片器的数据范围),如果未设置列位置,则返回 null。 |
get | Container | 获取有关切片器在工作表中的位置的信息。 |
get | Filter | 返回切片器的过滤条件;如果未设置过滤条件,则返回 null。 |
get | Range | 获取应用切片器的相应数据范围。 |
get | String | 返回切片器的标题。 |
get | String | 获取标题的水平对齐方式。 |
get | Text | 返回切片器标题的文字样式。 |
is | Boolean | 返回指定切片器是否应用于数据透视表。 |
remove() | void | 删除切片器。 |
set | Slicer | 设置指定切片器是否应应用于工作表中的数据透视表。 |
set | Slicer | 设置切片器的背景颜色。 |
set | Slicer | 设置切片器的背景 Color。 |
set | Slicer | 设置切片器的列索引和过滤条件。 |
set | Slicer | 设置切片器在工作表上的显示位置。 |
set | Slicer | 设置应用切片器的数据范围。 |
set | Slicer | 设置切片器的标题。 |
set | Slicer | 设置切片器中标题的水平对齐方式。 |
set | Slicer | 设置切片器的文本样式。 |
详细文档
get Background Color Object()
get Column Position()
返回切片器中应用过滤条件的列位置(相对于切片器的数据范围),如果未设置列位置,则返回 null。这应是列的从 1 开始的索引位置,与过滤条件类似。
返回
Integer|null - 相应切片器的列位置。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Container Info()
获取有关切片器在工作表中的位置的信息。
返回
Container - 包含切片器容器位置的对象。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Filter Criteria()
返回切片器的过滤条件;如果未设置过滤条件,则返回 null。
返回
Filter - 相应切片器的过滤条件。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Range()
get Title()
返回切片器的标题。
返回
String - 此切片器,用于链式调用。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Title Horizontal Alignment()
获取标题的水平对齐方式。
返回
String - 相应切片器标题的水平对齐方式。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Title Text Style()
is Applied To Pivot Tables()
返回指定切片器是否应用于数据透视表。
返回
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
set Apply To Pivot Tables(applyToPivotTables)
set Background Color(color)
set Background Color Object(color)
set Column Filter Criteria(columnPosition, filterCriteria)
设置切片器的列索引和过滤条件。值为 null 时,会重置切片器过滤条件。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
column | Integer | 相应切片器的新列位置。 |
filter | Filter | 相应切片器的新过滤条件。 |
返回
Slicer - 此切片器,用于链式调用。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Position(anchorRowPos, anchorColPos, offsetX, offsetY)
设置切片器在工作表上的显示位置。锚定行和列位置索引从 1 开始计数。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
anchor | Integer | 切片器的顶部固定在此行中。 |
anchor | Integer | 切片器的顶部固定在此列中。 |
offsetX | Integer | 单元格角部的水平偏移量(以像素为单位)。 |
offsetY | Integer | 单元格角部的垂直偏移量(以像素为单位)。 |
返回
Slicer - 此切片器,用于链式调用。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets