跳到主要内容

GetTableCellPr

返回当前样式的表格单元格属性。

语法​

expression.GetTableCellPr();

expression - 表示 ApiStyle 类的变量。

参数​

此方法没有任何参数。

返回值​

ApiTableCellPr | null | undefined

示例​

通过样式设置文档中各个表格单元格的背景颜色。

// How do I change the background color of specific table cells using a style in a document?

// Color the corner cells of a table differently by editing their style settings in a document.

let doc = Api.GetDocument();
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
let table = Api.CreateTable(3, 3);
table.SetWidth("percent", 100);
doc.Push(table);
table.SetStyle(tableStyle);
table.SetTableLook(true, true, true, true, true, true);
tableStyle.GetConditionalTableStyle("topLeftCell").GetTableCellPr().SetShd(Api.CreateShd("clear", Api.Color(255, 111, 61)));
tableStyle.GetConditionalTableStyle("topRightCell").GetTableCellPr().SetShd(Api.CreateShd("clear", Api.Color(51, 51, 51)));
tableStyle.GetConditionalTableStyle("bottomLeftCell").GetTableCellPr().SetShd(Api.CreateShd("clear", Api.Color(128, 128, 128)));
tableStyle.GetConditionalTableStyle("bottomRightCell").GetTableCellPr().SetShd(Api.CreateShd("clear", Api.Color(255, 213, 191)));