GetRow
通过在表格中的位置返回表格行。
语法
expression.GetRow(rowIndex);
expression - 表示 ApiTable 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| rowIndex | 必需 | number | 表格中的行索引。 |
返回值
示例
按位置从文档中的表格检索特定行。
// How do I access a particular row of a table by its index in a document?
// Use an existing row as a reference point to insert a new row in a document.
let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("We create a 2x2 table and add a new row, so that it becomes 2x3:");
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(2, 2);
table.SetWidth("percent", 100);
table.SetStyle(tableStyle);
table.AddRow(table.GetRow(1).GetCell(0), true);
doc.Push(table);