跳到主要内容

SetBackgroundColor

设置当前表格单元格的背景颜色。

语法

expression.SetBackgroundColor(color);

expression - 表示 ApiTableCell 类的变量。

参数

名称必需/可选数据类型默认值描述
color可选ApiColor如果未传递,将清除背景颜色。

返回值

boolean

示例

在文档中为表格单元格应用背景颜色。

// How do I fill a table cell with a specific color in a document?

// Give a cell a colored background to highlight it visually in a document.

let doc = Api.GetDocument();
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(2, 2);
table.SetWidth("percent", 100);
table.SetStyle(tableStyle);
let cell = table.GetRow(0).GetCell(0);
cell.SetBackgroundColor(Api.HexColor('#FF6F3D'));
doc.Push(table);