Class ColorBuilder
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
详细文档
asRgbColor()
将此颜色转换为 RgbColor
。
返回
RgbColor
- RGB 颜色。
抛出
Error
- 如果颜色不是 RgbColor
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
asThemeColor()
将此颜色转换为 ThemeColor
。
返回
ThemeColor
- 主题颜色。
抛出
Error
- 如果颜色不是 ThemeColor
。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
build()
根据向构建器提供的设置创建颜色对象。
返回
Color
- 通过此构建器创建的颜色对象。
getColorType()
获取此颜色的类型。
返回
ColorType
- 颜色类型。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setRgbColor(cssString)
设置为 RGB 颜色。
参数
名称 | 类型 | 说明 |
cssString | String | CSS 表示法中的 RGB 颜色(例如“#ffffff”)。 |
返回
ColorBuilder
- 此构建器,用于链式调用。
setThemeColor(themeColorType)
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[],["ColorBuilder facilitates creating color objects using `SpreadsheetApp.newColor()`. It allows conversion to `RgbColor` or `ThemeColor`. Key actions include `build()` to create a color object, `getColorType()` to retrieve the color type, `setRgbColor(cssString)` to define an RGB color, and `setThemeColor(themeColorType)` to define a theme color. Methods may require specific authorization scopes like `spreadsheets.currentonly` or `spreadsheets`. The builder can be chained.\n"],null,[]]