跳到主要内容

SetBackgroundColor

为当前表格中的所有单元格设置背景颜色。

语法​

expression.SetBackgroundColor(color);

expression - 表示 ApiTable 类的变量。

参数​

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

返回值​

boolean

示例​

设置 PDF 中表格所有单元格的背景颜色。

// Apply one background color to an entire table in a PDF.

// Create a table and apply an orange background color to all cells in a PDF.

const doc = Api.GetDocument();
const page = doc.GetPage(0);

const table = Api.CreateTable(3, 3);
const color = Api.RGB(255, 111, 61);
table.SetBackgroundColor(color);

page.AddObject(table);