Class Slicer  |  Apps Script  |  Google for Developers (original) (raw)

Class Slicer

Stay organized with collections Save and categorize content based on your preferences.

Methods

Method Return type Brief description
getBackgroundColorObject() Color Return the background Color of the slicer.
getColumnPosition() 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.
getContainerInfo() ContainerInfo Gets information about where the slicer is positioned in the sheet.
getFilterCriteria() FilterCriteria Returns the filter criteria of the slicer, or null if the filter criteria is not set.
getRange() Range Gets the data range on which the slicer is applied to.
getTitle() String Returns the title of the slicer.
getTitleHorizontalAlignment() String Gets the horizontal alignment of the title.
getTitleTextStyle() TextStyle Returns the text style of the slicer's title.
isAppliedToPivotTables() Boolean Returns whether the given slicer is applied to pivot tables.
remove() void Deletes the slicer.
setApplyToPivotTables(applyToPivotTables) Slicer Sets if the given slicer should be applied to pivot tables in the worksheet.
setBackgroundColor(color) Slicer Sets the background color of the slicer.
setBackgroundColorObject(color) Slicer Sets the background Color of the slicer.
setColumnFilterCriteria(columnPosition, filterCriteria) Slicer Sets the column index and filtering criteria of the slicer.
setPosition(anchorRowPos, anchorColPos, offsetX, offsetY) Slicer Sets the position where the slicer appears on the sheet.
setRange(rangeApi) Slicer Sets the data range on which the slicer is applied.
setTitle(title) Slicer Sets the title of the slicer.
setTitleHorizontalAlignment(horizontalAlignment) Slicer Sets the horizontal alignment of the title in the slicer.
setTitleTextStyle(textStyle) Slicer Sets the text style of the slicer.

Deprecated methods

Method Return type Brief description
getBackgroundColor() String Returns the background color of the slicer in CSS notation (such as '#ffffff').

Detailed documentation

getBackgroundColorObject()

Return the background [Color](/apps-script/reference/spreadsheet/color) of the slicer.

Return

[Color](/apps-script/reference/spreadsheet/color) — The background color of this slicer. Returns null if no color is set.

Scripts that use this method require authorization with one or more of the following scopes:


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:


getContainerInfo()

Gets information about where the slicer is positioned in the sheet.

Return

[ContainerInfo](/apps-script/reference/spreadsheet/container-info) — An object containing the slicer's container position.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:


getFilterCriteria()

Returns the filter criteria of the slicer, or null if the filter criteria is not set.

Return

[FilterCriteria](/apps-script/reference/spreadsheet/filter-criteria) — The filter criteria of this slicer.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:


getRange()

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

Return

[Range](/apps-script/reference/spreadsheet/range) — The slicer range.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:


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:


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:


getTitleTextStyle()

Returns the text style of the slicer's title.

Return

[TextStyle](/apps-script/reference/spreadsheet/text-style) — The text style of this slicer's title.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:


isAppliedToPivotTables()

Returns whether the given slicer is applied to pivot tables.

Return

Booleantrue 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:


remove()

Deletes the slicer.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:


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:


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:


setBackgroundColorObject(color)

Sets the background [Color](/apps-script/reference/spreadsheet/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:


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:


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:


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:


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:


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:


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:

Deprecated methods

getBackgroundColor()

Deprecated. Replaced by [getBackgroundColorObject()](#getBackgroundColorObject%28%29)

Returns the background color of the slicer in CSS notation (such as '#ffffff').

Return

String — 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:

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-12-03 UTC.