简体   繁体   中英

BindingDataChanged doesn't work in Excel Web App

I'm working on an Office Add-in (formerly Apps for office) using office.js library.

My app adds a handler to get notified about data changes in excel sheet:

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

It's working fine when I'm using this app in Excel. But it doesn't work when I'm running it in the web (Excel Online).

In the web, the handler is added successfully. But the handler isn't called when data changes on the excel.

I test your code in Excel Online. The issue you are reporting doesn't repro.

You could verify your code with the "API Tutorial for Office" app. Just create a new Excel document in Onedrive, and insert this app in "Apps for Office" under "INSERT" tab.

You could paste any JavaScript source code and run it.

Here is my repro step:

First, create a binding:

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);
    }
});

Then assign the event handler to the binding:

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");
}

I verify that when changing the cell, the event handler is working correctly.

在Excel Online下验证处理程序

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM