【发布时间】:2018-02-15 00:15:43
【问题描述】:
我正在尝试在内容控件中插入一个表格。这是我的代码:
function insertTable() {
Word.run(function (context) {
var range = context.document.getSelection();
var cc = range.insertContentControl();
cc.title = "My Table";
var values = [["Apple", "red", "round"], ["Banana", "yellow", "long"], ["Pear", "green", "oblong"]];
context.load(cc);
return context.sync().then(function () {
var table = cc.insertTable(3, 3, 'Start', values);
})
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
.then(context.sync);
})
.catch(function (error) {
console.log('Error: ' + JSON.stringify(error));
if (error instanceof OfficeExtension.Error) {
console.log('Debug info: ' + JSON.stringify(error.debugInfo));
}
});
}
但是我收到了这个错误。
Error: {"name":"OfficeExtension.Error","code":"InvalidArgument","message":"InvalidArgument","traceMessages":[],"innerError":null,"debugInfo":{"code":"InvalidArgument","message":"InvalidArgument","errorLocation":""},"stack":"InvalidArgument: InvalidArgument\n at Anonymous function (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:211625)\n at yi (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:249536)\n at st (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:249623)\n at d (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:249443)\n at c (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:248029)"}
我正在使用 beta 单词 api:
<script src="https://appsforoffice.microsoft.com/lib/beta/hosted/office.js" type="text/javascript"></script>
因为在 api 版本 1.1 上没有方法 insertTable。知道为什么它不起作用吗?我在文档中看到此方法可用于 api 版本 1.3,它们是否已发布?
谢谢
【问题讨论】:
标签: javascript ms-word office365 office-js