Excel中的异步自定义函数添加总是返回#BUSY!错误

问题描述

我一直在尝试使用异步自定义函数,并尝试了来自Office-add-in在线文档的样本,但是它们始终返回#BUSY !,没有异步函数可以正常工作,因此我假设清单文件已建立正确。

这是我的functions.js和functions.json文件中的示例代码。

function.js

async function getStarCount(userName,repoName) {
  try {
    //You can change this URL to any web request you want to work with.
    const url = "https://api.github.com/repos/" + userName + "/" + repoName;
    const response = await fetch(url);
    //Expect that status code is in 200-299 range
    if (!response.ok) {
      throw new Error(response.statusText)
    }
      const jsonResponse = await response.json();
      return jsonResponse.watchers_count;
  }
  catch (error) {
    return error;
  }
}

/**
 * @customfunction
 * @param address range's address
 **/
async function getRangeValue (address) {
  var context = new Excel.RequestContext();
  var range = context.workbook.worksheets.getActiveWorksheet().getRange(address);
  range.load();
  await context.sync();
  return range.values[0][0];
 }

CustomFunctions.associate("STARCOUNT",getStarCount);
CustomFunctions.associate("RANGEVALUE",getRangeValue);

functions.json

{
    "functions": [
        {
            "description": "Get start count","id": "STARCOUNT","name": "STARCOUNT","parameters": [
                {
                    "description": "user name","name": "userName","type": "string"
                },{
                    "description": "repo name","name": "repoName","type": "string"
                }
            ],"result": {
                "type": "any"
            }
        },{
            "description": "Get value for range","id": "RANGEVALUE","name": "RANGEVALUE","parameters": [
                {
                    "description": "address","name": "address","result": {
                "type": "any"
            }
        }
    ]
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...