SetBackgroundColor
设置当前表格中所有单元格的背景颜色。
语法
expression.SetBackgroundColor(color);
expression - 表示 ApiTable 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| color | 可选 | ApiColor | 如果未传递,将清除背景颜色。 |
返回值
boolean
示例
此示例设置表格中所有单元格的背景颜色。
// How to color a background of the table.
// Color background to the middle washed rose color.
let doc = Api.GetDocument();
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(4, 2);
table.SetWidth("percent", 100);
table.SetStyle(tableStyle);
table.SetBackgroundColor(Api.HexColor('#FF6F3D'));
doc.Push(table);