跳到主要内容

GetParentTableCell

返回包含当前表格的表格单元格。

语法

expression.GetParentTableCell();

expression - 表示 ApiTable 类的变量。

参数

此方法没有任何参数。

返回值

ApiTableCell | null

示例

此示例展示如何获取包含表格的表格单元格。

// How to get the parent table cell.

// Retrieve the parent table cell, apply the shading to it.

let doc = Api.GetDocument();
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table1 = Api.CreateTable(3, 3);
table1.SetWidth("percent", 100);
table1.SetStyle(tableStyle);
doc.Push(table1);
let table2 = Api.CreateTable(2, 2);
table2.SetWidth("percent", 100);
table2.SetStyle(tableStyle);
let cell = table1.GetCell(0, 0);
table1.AddElement(cell, 0, table2);
let parentTableCell = table2.GetParentTableCell();
parentTableCell.SetShd("clear", Api.HexColor('#FF6F3D'));