你好,看到你用了异步公式,异步公式的setAsyncResult一定要在evaluateAsync里异步执行,否则会清除掉内部标记。所以改成下面应该可以正确执行- let CrossWorkbookFormula = function () {};
- CrossWorkbookFormula.prototype = new GC.Spread.CalcEngine.Functions.AsyncFunction("CROSSWORKBOOK", 3, 3,
- {
- description: "跨表格取数公式",
- parameters: [{
- name: "workbookName",
- repeatable: false,
- optional: false
- },
- {
- name: "sheetName",
- repeatable: false,
- optional: false
- },
- {
- name: "range",
- repeatable: false,
- optional: false
- }]
- });
- CrossWorkbookFormula.prototype.defaultValue = function () { return '取数中...'; };
- CrossWorkbookFormula.prototype.evaluateAsync = (context, workbookName, sheetName, range) => {
- setTimeout(function(){context.setAsyncResult("123")});
- };
- GC.Spread.CalcEngine.Functions.defineGlobalCustomFunction("CROSSWORKBOOK", new CrossWorkbookFormula());
复制代码 |