您好,可以参考以下代码实现:
spread.options.allowDynamicArray = true;
var result = [
["苹果", 5],
["香蕉", 3],
["橙子", 8],
];
var Test = function () {};
Test.prototype = new GC.Spread.CalcEngine.Functions.AsyncFunction("Test");
Test.prototype.defaultValue = function () {
return "Loading...";
};
Test.prototype.evaluateAsync = function (context, arg) {
setTimeout(() => {
context.setAsyncResult(new GC.Spread.CalcEngine.CalcArray(result));
}, 3000);
};
sheet.addCustomFunction(new Test());
sheet.setFormula(1, 1, "Test()");
sheet.setFormula(6, 1, '=VLOOKUP("苹果", Test(), 2, FALSE)')
|