使用Office的JavaScript API,我尝试使用下面的代码填写所选表:的MS Word API:表中的值没有设置
Word.run(function (context) {
var table = context.document.getSelection().parentTable;
context.load(table);
return context.sync()
.then(function() {
if (table.isNullObject == true || !table) {
console.log("selection ist not table");
errorHandler("selection is not a table");
} else {
// loop over table
for (var row = 0; row < table.values.length; row++) {
for (var column = 0; column < table.values[row].length; column++) {
console.log(table.values[row][column]);
table.values[row][column] = "Test " + row + " " + column;
}
context.sync().then(function() {
console.log("done");
}).catch(function (e) {
console.log(e);
});
}
}
});
});
脚本运行正常,表对象存在,值记录并最终“完成”。但是表格保持原样 - 没有更新值。我错过了什么?