Skip to main content

Rows

Rows

JSSDK: 1.3.0、zOffice V6 支持

指定表格行的集合。

属性

count

行数量。

语法

Rows.count

返回值

Promise<number>

示例

async function example() {
const table = await Application.ActiveDocument.Tables.item(1);
const row = await table.Rows.count;
}

方法

add

插入行。

语法

Rows.add(index, cnt, isBefore)

参数

属性数据类型必填说明
indexnumber行序号(从1开始)
cntnumber插入数量 (从1开始, 最大不超过200)
isBeforeboolean布尔值 (true: 在上方插入行;false:在下方插入行)

返回值

Promise<boolean> 是否插入成功

示例

async function example(index, cnt, isBefore) {
const table = await Application.ActiveDocument.Tables.item(1);
const rows = await table.Rows;
const success = await rows.add(index, cnt, isBefore);
}

deleteRows

删除指定行。

语法

Rows.deleteRows(index, cnt, isBefore)

参数

属性数据类型必填说明
indexnumber行序号(从1开始)
cntnumber删除数量 (默认为1行)
isBeforeboolean布尔值 (true: 往上方删除行;false:往下方删除行,默认为false)

返回值

Promise<boolean>

示例

async function example(index, cnt, isBefore) {
const table = await Application.ActiveDocument.Tables.item(1);
const success = await table.Rows.deleteRows(index, cnt, isBefore);
}

item

根据参数获取表格行。

语法

Rows.item(index)

参数

属性数据类型必填说明
indexnumber行序号(从1开始)

返回值

Promise<Word.Row>

示例

async function example(index, cnt, isBefore) {
const table = await Application.ActiveDocument.Tables.item(1);
const row = await table.Rows.item(1);
}