使用这个我在表中添加新行如何为其单元格赋予值
await Word.run(async (context) => {
const selection = context.document.getSelection();
selection.load('parentTableCellOrNullObject');
await context.sync();
if (!selection.isNull && !selection.parentTableCellOrNullObject.isNull) {
const parentCell = selection.parentTableCellOrNullObject;
const parentRow = parentCell.parentRow;
parentRow.insertRows(Word.InsertLocation.after, 1);
await context.sync();
console.log('Table row added after the selected row.');
} else {
console.log('Selection is not inside a table cell.');
}
});
您将这些值添加为
insertRow
方法上的附加参数。请参阅插入行。或者,您可以使用 TableRow.values 属性为行分配值。
您在过去几天提出了几个 StackOverflow 问题,这表明您在使用 Office JavaScript API 时犯了基本错误。在 StackOverflow 上发布问题之前,请多花点功夫阅读参考文档。