Page tree
Skip to end of metadata
Go to start of metadata

你可以给 单元格, 列, 行, 标题区域和小组件设置颜色。

颜色分为两种,前景色和背景色。前景色控制字体或内容的颜色,背景色控制背景的颜色。
您可以使用 backColor 设置背景色,使用 foreColor 设置前景色。您可以在小组件中使用 backColor 设置背景色。 您可以使用 options.grayAreaBackColor 来设置灰色区域(内容区域的空白部分)的背景色.

如果您想了解更多关于主题的信息,请访问 Using Themes 一节。你也可以使用样式(Styles)来设置表格的外观。如果你想了解更多关于样式(Styles)的信息,请访问 Setting Styles.
参考代码
本代码为 B2 单元格设置了前景色背景色

JavaScript
//Set the backcolor and forecolor of cells.
    var cell = activeSheet.getCell(1, 1, GC.Spread.Sheets.SheetArea.viewport);
    cell.backColor("Blue");
    cell.foreColor("Red");
    cell.value("Color");

示例代码

以下代码演示了如何给标题区域设置颜色

JavaScript
//Set the backcolor and forecolor for the entire column header.
     var row = activeSheet.getRange(0, -1, 1, -1, GC.Spread.Sheets.SheetArea.colHeader);
     row.backColor("Red");
     row.foreColor("White");
     //Set the backcolor for the second row header.
     activeSheet.getCell(1, 0, GC.Spread.Sheets.SheetArea.rowHeader).backColor("Yellow");

更多信息

Using Custom Themes from ThemeRoller
Object Inheritance
Setting Styles
Working with Selections
Workbook Method

  • No labels