0

从这个链接考虑这个例子:https ://docs.microsoft.com/en-us/office/dev/add-ins/excel/excel-tutorial-custom-functions#create-a-custom-function-that-requests -来自网络的数据

function stockPrice(ticker) {
var url = "https://api.iextrading.com/1.0/stock/" + ticker + "/price";
return fetch(url)
    .then(function(response) {
        return response.text();
    })
    .then(function(text) {
        return parseFloat(text);
    });

// Note: in case of an error, the returned rejected Promise
//    will be bubbled up to Excel to indicate an error.
}

CustomFunctionMappings.STOCKPRICE = stockPrice;

是否有可能通过在一个请求中为它提供每一行的所有参数来批处理 Web 服务请求并仅调用一次,从而使用从服务返回的相应响应一次更新所有行,而不是调用 Web 服务每一行?这将有助于在大量行的情况下。

4

1 回答 1

0

是的,可以通过这种方式批量处理请求。我们的一位自定义函数工程师 Michael Zlatkovsky 在GitHub gist中准备了一个示例,说明如何执行此操作。此外,在接下来的一个月中,自定义函数文档团队正在编写一个专门解决批处理问题的文档,因为我们知道人们对这个主题很感兴趣。如果您需要其他帮助,请告诉我 - 谢谢!

于 2018-10-24T22:28:14.320 回答