在外接程序对话框中同步excel上下文出错



在我的excel任务窗格中,我使用下面的代码显示了一个来自主网页的对话框。

Office.context.ui.displayDialogAsync(window.location.origin + "/Sample.html", { height: 50, width: 23 });

在Sample.html中,我有下面的代码,它抛出了一个错误'发生了内部错误'。控件确实在文档内部。准备好了。请告诉我如何在插件对话框中使用office.js方法。

Office.initialize = function (reason) {
$(document).ready(function () {
Excel.run(function (ctx) {
var sheet = ctx.workbook.worksheets.getActiveWorksheet();  
sheet.getRange("A1").values = [["test"]];
return ctx.sync()
.then(function () {
})
.then(ctx.sync);
})
.catch(errorHandler);
});
}

这里已经存在一个类似的问题,但它与对话框无关。

在一个对话框中只能使用两个Office JavaScript api:isSetSupportedmessageParent。见本页1/3处的重要说明:Office外接程序中的对话框API。

最新更新