Represents a slicer, which is used
to filter ranges, charts and pivot tables in a non-collaborative manner. This class contains
methods to access and modify existing slicers. To create a new slicer, use Sheet.insertSlicer(range, anchorRowPos, anchorColPos)
.
Methods
Method | Return type | Brief description |
---|---|---|
get | Color | Return the background Color of the slicer. |
get | Integer | Returns the column position (relative to the data range of the slicer) on which the filter is
applied in the slicer, or null if the column position is not set. |
get | Container | Gets information about where the slicer is positioned in the sheet. |
get | Filter | Returns the filter criteria of the slicer, or null if the filter criteria is not set. |
get | Range | Gets the data range on which the slicer is applied to. |
get | String | Returns the title of the slicer. |
get | String | Gets the horizontal alignment of the title. |
get | Text | Returns the text style of the slicer's title. |
is | Boolean | Returns whether the given slicer is applied to pivot tables. |
remove() | void | Deletes the slicer. |
set | Slicer | Sets if the given slicer should be applied to pivot tables in the worksheet. |
set | Slicer | Sets the background color of the slicer. |
set | Slicer | Sets the background Color of the slicer. |
set | Slicer | Sets the column index and filtering criteria of the slicer. |
set | Slicer | Sets the position where the slicer appears on the sheet. |
set | Slicer | Sets the data range on which the slicer is applied. |
set | Slicer | Sets the title of the slicer. |
set | Slicer | Sets the horizontal alignment of the title in the slicer. |
set | Slicer | Sets the text style of the slicer. |
Detailed documentation
getBackgroundColorObject()
Return the background Color
of the slicer.
Return
Color
— The background color of this slicer. Returns null
if no color is set.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getColumnPosition()
Returns the column position (relative to the data range of the slicer) on which the filter is
applied in the slicer, or null
if the column position is not set. This should be
1-indexed position of the column similar to filter.
Return
Integer
— The column position of this slicer.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getContainerInfo()
Gets information about where the slicer is positioned in the sheet.
Return
Container
— An object containing the slicer's container position.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getFilterCriteria()
Returns the filter criteria of the slicer, or null
if the filter criteria is not set.
Return
Filter
— The filter criteria of this slicer.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getRange()
getTitle()
Returns the title of the slicer.
Return
String
— This slicer, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getTitleHorizontalAlignment()
Gets the horizontal alignment of the title.
Return
String
— The horizontal alignment of this slicer's title.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getTitleTextStyle()
Returns the text style of the slicer's title.
Return
Text
— The text style of this slicer's title.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
isAppliedToPivotTables()
Returns whether the given slicer is applied to pivot tables.
Return
Boolean
— true
if this slicer is applied to pivot tables, otherwise false
.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
remove()
Deletes the slicer.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setApplyToPivotTables(applyToPivotTables)
Sets if the given slicer should be applied to pivot tables in the worksheet.
Parameters
Name | Type | Description |
---|---|---|
apply | Boolean | Specifies whether this slicer should apply to pivot tables. |
Return
Slicer
— This slicer, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setBackgroundColor(color)
Sets the background color of the slicer. A null
value resets the background color.
Parameters
Name | Type | Description |
---|---|---|
color | String | The new background color of this slicer in CSS notation (such as '#ffffff'). |
Return
Slicer
— This slicer, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setBackgroundColorObject(color)
Sets the background Color
of the slicer. A null
value resets the background
color.
Parameters
Name | Type | Description |
---|---|---|
color | Color | The new background color of this slicer. |
Return
Slicer
— This slicer, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setColumnFilterCriteria(columnPosition, filterCriteria)
Sets the column index and filtering criteria of the slicer. A null
value resets the
slicer filter.
Parameters
Name | Type | Description |
---|---|---|
column | Integer | The new column position of this slicer. |
filter | Filter | The new filter criteria of this slicer. |
Return
Slicer
— This slicer, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setPosition(anchorRowPos, anchorColPos, offsetX, offsetY)
Sets the position where the slicer appears on the sheet. The anchor row and column position indices are 1-indexed.
Parameters
Name | Type | Description |
---|---|---|
anchor | Integer | The slicer's top side is anchored in this row. |
anchor | Integer | The slicer's top side is anchored in this col. |
offsetX | Integer | The horizontal offset from cell corner in pixels. |
offsetY | Integer | The vertical offset from cell corner in pixels. |
Return
Slicer
— This slicer, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setRange(rangeApi)
Sets the data range on which the slicer is applied.
Parameters
Name | Type | Description |
---|---|---|
range | Range | The new range for this slicer. |
Return
Slicer
— This slicer, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setTitle(title)
Sets the title of the slicer. An empty title resets the title to default value.
Parameters
Name | Type | Description |
---|---|---|
title | String | The new title of this slicer. |
Return
Slicer
— This slicer, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setTitleHorizontalAlignment(horizontalAlignment)
Sets the horizontal alignment of the title in the slicer. A null
value resets the
alignment.
Parameters
Name | Type | Description |
---|---|---|
horizontal | String | The new horizontal alignment of this slicer's title. |
Return
Slicer
— This slicer, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setTitleTextStyle(textStyle)
Sets the text style of the slicer.
Parameters
Name | Type | Description |
---|---|---|
text | Text | The new text style of the slicer's title. |
Return
Slicer
— This slicer, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets