Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

You can set background and foreground colors for cells, columns, rows, headers, and the widget.
Image Removed
Set the backColor or foreColor methods for cells, columns, headers, or rows. You can set the backColor method or use themes for the widget. You can use the options.grayAreaBackColor property for the gray area.
For more information about themes, refer to Using Themes. You can also use styles to set cell colors. For more information, refer to Setting Styles.
Using Code
This example sets the foreColor and backColor for cell B2.你可以给 单元格, 列, 行, 标题区域和小组件设置颜色。
Image Added

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

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

JavaScript

Copy Code

//

Set the backcolor and forecolor of cells.    var

给单元格设置前景色和背景色

 var cell = activeSheet.getCell(1, 1, GC.Spread.Sheets.SheetArea.viewport);

    cell

    

cell.backColor("Blue");

    cell

   

 cell.foreColor("Red");

    cell

    

cell.value("Color");

 

Using Code
This example sets the forecolor and backcolor for the header.示例代码
以下代码演示了如何给标题区域设置颜色

JavaScript

Copy Code

//

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");

 

See Also更多信息
Using Custom Themes from ThemeRoller
Object Inheritance
Setting Styles
Working with Selections
Workbook Method