BindingDataChanged在Excel Web App中不起作用 [英] BindingDataChanged doesn't work in Excel Web App

查看:169
本文介绍了BindingDataChanged在Excel Web App中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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

  Microsoft.Office.WebExtension.select(bindings#orderBinding, onBindingNotFound)
.addHandlerAsync(
Microsoft.Office.WebExtension.EventType.BindingDataChanged,
(eventArgs)=> {
console.dir('excel'中的数据已更改);
}
);

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



在网络中,处理程序已成功添加。但是当excel上的数据发生更改时,不会调用处理程序。

解决方案

我在Excel Online中测试您的代码。您报告的问题不会重现。



您可以使用API Tutorial for Office应用验证您的代码。只需在Onedrive中创建一个新的Excel文档,然后在INSERT选项卡下的Apps for Office中插入此应用程序。



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



这是我的重复步骤:



首先,创建一个绑定:

  Office.context.document.bindings.addFromSelectionAsync(table,{id:orderBinding},function(asyncResult) {
if(asyncResult.status ==failed){
showMessage(Action failed with error:+ asyncResult.error.message);
}
else {
showMessage(添加了新的绑定类型:+ asyncResult.value.type +和id:+ asyncResult.value.id);
}
});

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

  Microsoft.Office.WebExtension.select(bindings#orderBinding,onBindingNotFound)
.addHandlerAsync(
Microsoft.Office。 WebExtension.EventType.BindingDataChanged,
function(eventArgs){
showMessage('excel'中的数据已更改);
}
);

函数onBindingNotFound(){
showMessage(未找到绑定对象。+
请返回上一步创建绑定);
}

我验证在更改单元格时,事件处理程序正常工作。 / p>


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.

这篇关于BindingDataChanged在Excel Web App中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆