跳到主要内容

ReplaceByElement

用新元素替换当前表格。

语法

expression.ReplaceByElement(oElement);

expression - 表示 ApiTable 类的变量。

参数

名称必需/可选数据类型默认值描述
oElement必需DocumentElement用于替换当前表格的元素。

返回值

boolean

示例

此示例用段落替换当前表格。

// How to replace table with a paragraph.

// Create paragraph and put it instead of the table.

let doc = Api.GetDocument();
let table = Api.CreateTable(3, 3);
doc.AddElement(0, table);
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
table.SetStyle(tableStyle);
let paragraph = Api.CreateParagraph();
paragraph.AddText("The table was replaced with the current paragraph.");
table.ReplaceByElement(paragraph);