Class Slicer

Slicer

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
Color Return the background Color of the slicer.
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.
ContainerInfo Gets information about where the slicer is positioned in the sheet.
FilterCriteria Returns the filter criteria of the slicer, or null if the filter criteria is not set.
Range Gets the data range on which the slicer is applied to.
String Returns the title of the slicer.
String Gets the horizontal alignment of the title.
TextStyle Returns the text style of the slicer's title.
Boolean Returns whether the given slicer is applied to pivot tables.
void Deletes the slicer.
Slicer Sets if the given slicer should be applied to pivot tables in the worksheet.
Slicer Sets the background color of the slicer.
Slicer Sets the background Color of the slicer.
Slicer Sets the column index and filtering criteria of the slicer.
Slicer Sets the position where the slicer appears on the sheet.
Slicer Sets the data range on which the slicer is applied.
Slicer Sets the title of the slicer.
Slicer Sets the horizontal alignment of the title in the slicer.
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

ContainerInfo — 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

FilterCriteria — 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()

Gets the data range on which the slicer is applied to.

Return

Range — The slicer range.

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

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

TextStyle — 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
applyToPivotTables
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
columnPosition
Integer The new column position of this slicer.
filterCriteria
FilterCriteria 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
anchorRowPos
Integer The slicer's top side is anchored in this row.
anchorColPos
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
rangeApi
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
horizontalAlignment
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
textStyle
TextStyle 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

Deprecated methods