Office.EventType.DocumentSelectionChanged(in Excel) 不适用于所有网络浏览器
Office.EventType.DocumentSelectionChanged(in Excel) not working in all web browsers
我正在尝试在 Excel 在线文档中添加 DocumentSelectionChanged
事件句柄(已在所有浏览器中测试)。从过去 15 天开始,创建此事件失败。
请帮帮我
P.S:同一事件在 Excel 2013 桌面环境
中工作正常
Office.context.document.addHandlerAsync(Office.EventType.DocumentSelectionChanged, function(eventArgs) {
console.log(eventArgs);
}, function(asyncResult) {
console.log(asyncResult);
});
OSF.DDA.AsyncResult {value: undefined, status: "failed", error: OSF.DDA.Error}error: OSF.DDA.Errorcode: 5001message: "An internal error has occurred."name: "Internal Error"proto: OSF.DDA.Errorconstructor: (n,t,i)proto: Objectstatus: "failed"value: undefined__proto__: OSF.DDA.AsyncResultconstructor: (n,t)proto: Object
这里 link 在 http://aka.ms/R2yi5b
进行测试
更新(2015 年 11 月 6 日下午):
经进一步调查,似乎 是 Excel Online 中的一个已知错误,它导致了此问题。回归问题在几周前就已被发现并已得到修复,但是该修复尚未适用于所有端点(这解释了为什么有些人看到了它,而其他人,包括我自己在内,却没有看到)。我们正在寻找可以加快补丁推出的方法。
随着修复程序在系统中的应用,我们将持续更新此线程。
原回答(2015年11月6日上午):
我刚刚试过了,没看到失败。
不过,我注意到的一件事是共享 link 上的代码有一个错误。 addHandlerAsync 的语法是它首先接受事件类型,然后是处理程序,然后是报告事件处理是否成功的回调函数。在共享项目的情况下,它看起来像是假设第二个参数是成功处理程序,第二个是失败处理程序(?)。相反,对于最后一个参数,您应该检查 asyncStatus.status
以检查成功状态。
(function() {
'use strict';
// The initialize function must be run each time a new page is loaded
Office.initialize = function(reason) {
$(document).ready(function() {
app.initialize();
addDocumentHandler();
});
};
function addDocumentHandler() {
Office.context.document.addHandlerAsync(
Office.EventType.DocumentSelectionChanged,
eventHandler,
function(asyncResult) {
if (asyncResult.status == "succeeded") {
app.showNotification("Success", "Error handler was added");
} else {
app.showNotification("Error setting event: ", JSON.stringify(asyncResult));
}
}
);
function eventHandler(eventArgs) {
Office.context.document.getSelectedDataAsync(Office.CoercionType.Text, function(asyncResult) {
if (asyncResult.status == "succeeded") {
app.showNotification("Value of selection: ", asyncResult.value);
} else {
app.showNotification("Error", "Cannot read selection value");
}
});
}
}
})();
我也尝试使用 Office API Tutorial App,"SelectionChanged" 教程。那里也一切正常。你能试试吗?
~ Michael Zlatkovsky,Office 可扩展性团队开发人员,MSFT
感谢您的耐心等待。我很高兴地告诉您,此修复程序已经部署,并且现在可以在所有 Web 浏览器上运行。再次感谢您提交反馈。
干杯,
天空
我正在尝试在 Excel 在线文档中添加 DocumentSelectionChanged
事件句柄(已在所有浏览器中测试)。从过去 15 天开始,创建此事件失败。
请帮帮我
P.S:同一事件在 Excel 2013 桌面环境
中工作正常 Office.context.document.addHandlerAsync(Office.EventType.DocumentSelectionChanged, function(eventArgs) {
console.log(eventArgs);
}, function(asyncResult) {
console.log(asyncResult);
});
OSF.DDA.AsyncResult {value: undefined, status: "failed", error: OSF.DDA.Error}error: OSF.DDA.Errorcode: 5001message: "An internal error has occurred."name: "Internal Error"proto: OSF.DDA.Errorconstructor: (n,t,i)proto: Objectstatus: "failed"value: undefined__proto__: OSF.DDA.AsyncResultconstructor: (n,t)proto: Object
这里 link 在 http://aka.ms/R2yi5b
进行测试更新(2015 年 11 月 6 日下午):
经进一步调查,似乎 是 Excel Online 中的一个已知错误,它导致了此问题。回归问题在几周前就已被发现并已得到修复,但是该修复尚未适用于所有端点(这解释了为什么有些人看到了它,而其他人,包括我自己在内,却没有看到)。我们正在寻找可以加快补丁推出的方法。
随着修复程序在系统中的应用,我们将持续更新此线程。
原回答(2015年11月6日上午):
我刚刚试过了,没看到失败。
不过,我注意到的一件事是共享 link 上的代码有一个错误。 addHandlerAsync 的语法是它首先接受事件类型,然后是处理程序,然后是报告事件处理是否成功的回调函数。在共享项目的情况下,它看起来像是假设第二个参数是成功处理程序,第二个是失败处理程序(?)。相反,对于最后一个参数,您应该检查 asyncStatus.status
以检查成功状态。
(function() {
'use strict';
// The initialize function must be run each time a new page is loaded
Office.initialize = function(reason) {
$(document).ready(function() {
app.initialize();
addDocumentHandler();
});
};
function addDocumentHandler() {
Office.context.document.addHandlerAsync(
Office.EventType.DocumentSelectionChanged,
eventHandler,
function(asyncResult) {
if (asyncResult.status == "succeeded") {
app.showNotification("Success", "Error handler was added");
} else {
app.showNotification("Error setting event: ", JSON.stringify(asyncResult));
}
}
);
function eventHandler(eventArgs) {
Office.context.document.getSelectedDataAsync(Office.CoercionType.Text, function(asyncResult) {
if (asyncResult.status == "succeeded") {
app.showNotification("Value of selection: ", asyncResult.value);
} else {
app.showNotification("Error", "Cannot read selection value");
}
});
}
}
})();
我也尝试使用 Office API Tutorial App,"SelectionChanged" 教程。那里也一切正常。你能试试吗?
~ Michael Zlatkovsky,Office 可扩展性团队开发人员,MSFT
感谢您的耐心等待。我很高兴地告诉您,此修复程序已经部署,并且现在可以在所有 Web 浏览器上运行。再次感谢您提交反馈。
干杯, 天空