GetParentTable
返回包含当前表格的表格。
语法
expression.GetParentTable();
expression - 表示 ApiTable 类的变量。
参数
此方法没有任何参数。
返回值
ApiTable | null
示例
访问文档中包含嵌套表格的外部表格。
// How do I navigate from a nested table up to its surrounding table in a document?
// Locate the enclosing table so its rows can be modified in a document.
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 parentTable = table2.GetParentTable();
cell = parentTable.GetRow(2).GetCell(0);
parentTable.RemoveRow(cell);