BindingDataChanged在Excel Web App中不起作用

我正在使用office.js库处理Office加载项(以前的Office应用程序)。

我的应用程序添加了一个处理程序来获取有关Excel表中数据更改的通知:

Microsoft.Office.WebExtension.select("bindings#orderBinding", onBindingNotFound) .addHandlerAsync( Microsoft.Office.WebExtension.EventType.BindingDataChanged, (eventArgs) => { console.dir('Data changed in excel'); } ); 

当我在Excel中使用这个应用程序时,它工作正常。 但是,当我在网上运行它时,它不起作用(Excel Online)。

在Web中,处理程序已成功添加。 但是,当数据在Excel中更改时,处理程序不会被调用。

我在Excel Online中testing您的代码。 您正在报告的问题不重复。

您可以使用“API Tutorial for Office”应用程序validation您的代码。 只需在Onedrive中创build一个新的Excel文档,并将该应用程序插入“INSERT”选项卡下的“Apps for Office”中。

您可以粘贴任何JavaScript源代码并运行它。

这是我的repro步骤:

首先,创build一个绑定:

 Office.context.document.bindings.addFromSelectionAsync("table", { id: "orderBinding" }, function (asyncResult) { if (asyncResult.status == "failed") { showMessage("Action failed with error: " + asyncResult.error.message); } else { showMessage("Added new binding with type: " + asyncResult.value.type + " and id: " + asyncResult.value.id); } }); 

然后将事件处理程序分配给绑定:

 Microsoft.Office.WebExtension.select("bindings#orderBinding", onBindingNotFound) .addHandlerAsync( Microsoft.Office.WebExtension.EventType.BindingDataChanged, function (eventArgs){ showMessage('Data changed in excel'); } ); function onBindingNotFound(){ showMessage("The binding object was not found. "+ "Please return to previous step to create the binding"); } 

我确认在更改单元格时,事件处理程序正常工作。

在Excel Online中验证处理程序

Interesting Posts