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)
参数
| 属性 | 数据类型 | 必填 | 说明 |
|---|---|---|---|
| index | number | 是 | 行序号(从1开始) |
| cnt | number | 是 | 插入数量 (从1开始, 最大不超过200) |
| isBefore | boolean | 是 | 布尔值 (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)
参数
| 属性 | 数据类型 | 必填 | 说明 |
|---|---|---|---|
| index | number | 是 | 行序号(从1开始) |
| cnt | number | 否 | 删除数量 (默认为1行) |
| isBefore | boolean | 否 | 布尔值 (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)
参数
| 属性 | 数据类型 | 必填 | 说明 |
|---|---|---|---|
| index | number | 是 | 行序号(从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);
}