AddElement
使用在单元格中的位置添加段落、表格或块级内容控件。
语法
expression.AddElement(nPos, oElement);
expression - 表示 ApiTableCell 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| nPos | 必需 | number | 将添加当前元素的位置。 | |
| oElement | 必需 | DocumentElement | 将在当前位置添加的文档元素。 |
返回值
boolean
示例
此示例使用在单元格中的位置添加段落。
// Insert new paragraph into the current cell.
// Get the cell, add an element to it.
let doc = Api.GetDocument();
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(3, 3);
table.SetWidth("percent", 100);
table.SetStyle(tableStyle);
doc.Push(table);
let paragraph = Api.CreateParagraph();
paragraph.AddText("This is just a sample text in the first cell.");
let cell = table.GetCell(0, 0);
cell.AddElement(0, paragraph);