我有一个CustomFunctions javascript,它可以完美地与同步函数配合使用,但只要我尝试使用异步函数,我就会得到:
中第21行第707859列出现未处理的异常
https://appsforoffice.microsoft.com/lib/beta/hosted/excel-win32-16.01.js
0x800a139e-Der optstod en JavaScript krselsfejl:意外的消息类型
“”
这发生在对我的js文件调用任何javascript代码之前。消息类型是1002,因此如果在excel-win-16.01中指定的位置使用javascript,那么当然会抛出错误。js公司:
“”
if(i[t).messageType==1001)u.push(i[t]);否则抛出OfficeExtension。公用事业createRuntimeError(st.generalException,“意外消息类型”,
“”
函数的json描述为:
{
"name": "helloasync",
"description": "simple test string return",
"helpUrl": "https://www.konsolidator.com",
"result": {
"type": "string",
"dimensionality": "scalar"
},
"parameters": [],
"options": {"sync": false}
},
{
"name": "ADD42ASYNC",
"description": "asynchronously wait 250ms, then add 42",
"helpUrl": "http://dev.office.com",
"result": {
"type": "number",
"dimensionality": "scalar"
},
"parameters": [
{
"name": "num",
"description": "Number",
"type": "number",
"dimensionality": "scalar"
}
],
"options": {
"sync": false
}
}
JS代码:
function helloasync() {
return new OfficeExtension.Promise(function (setResult) {
setTimeout(function () {
setResult("hello");
}, 1000);
});
}
function ADD42ASYNC(num) {
// waits 1 second before returning the result
return new OfficeExtension.Promise(function (resolve,reject) {
//resolve(num);
//reject(num);
setTimeout(function () {
resolve(num + 42);
}, 1000);
});
}
我所有的异步CustomFunction都失败了!
边栏异步函数与同步函数一样正常工作。