AI-generated Key Takeaways
-
ColorBuilder
facilitates the creation and customization of color objects within Google Sheets using Apps Script. -
Methods such as
setRgbColor()
andsetThemeColor()
are used to define the color, whilebuild()
generates the finalColor
object. -
asRgbColor()
andasThemeColor()
methods enable the conversion of the color to specific color types. -
getColorType()
reveals the color's current type (RGB or Theme). -
Several of these methods necessitate authorization with relevant scopes for access to spreadsheet data.
The builder for Color
. To create a new builder, use Spreadsheet
.
Methods
Method | Return type | Brief description |
---|---|---|
as | Rgb | Converts this color to an Rgb . |
as | Theme | Converts this color to a Theme . |
build() | Color | Creates a color object from the settings supplied to the builder. |
get | Color | Get the type of this color. |
set | Color | Sets as RGB color. |
set | Color | Sets as theme color. |
Detailed documentation
asRgbColor()
Converts this color to an Rgb
.
Return
Rgb
— The RGB color.
Throws
Error
— if the color is not an Rgb
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
asThemeColor()
Converts this color to a Theme
.
Return
Theme
— The theme color.
Throws
Error
— if the color is not a Theme
.
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
build()
Creates a color object from the settings supplied to the builder.
Return
Color
— A color object created from this builder.
getColorType()
setRgbColor(cssString)
Sets as RGB color.
Parameters
Name | Type | Description |
---|---|---|
css | String | The RGB color in CSS notation (such as '#ffffff'). |
Return
Color
— This builder, for chaining.
setThemeColor(themeColorType)
Sets as theme color.
Parameters
Name | Type | Description |
---|---|---|
theme | Theme | The theme color type. |
Return
Color
— This builder, for chaining.