【发布时间】:2018-10-04 05:27:09
【问题描述】:
我正在尝试使用 Office.js 在文档正文中插入表格,但无济于事。
我使用了以下代码:
function insertSampleTable() {
showNotification("Insert Table", "Inserting table...")
Word.run(function (context) {
// Create a proxy object for the document body.
var body = context.document.body;
body.insertTable(2, 2, Word.InsertLocation.end, ["a"]);
// Synchronize the document state by executing the queued commands, and return a promise to indicate task completion.
return context.sync();
})
.catch(errorHandler);
}
但是在点击按钮时,它给了我以下错误:
Error: TypeError: Object doesn't support property or method 'insertTable'
任何帮助将不胜感激。我曾尝试查看 Microsoft Office Dev 网站,但他们没有类似的示例。
谢谢!
【问题讨论】:
-
Michael 我们添加了一个表对象作为 1.3 API 的一部分。检查开放规范:github.com/OfficeDev/office-js-docs/tree/WordJs_1.3_Openspec
标签: javascript ms-office office-addins office-js