找回密码
 立即注册

QQ登录

只需一步,快速开始

Silhouette

注册会员

7

主题

9

帖子

58

积分

注册会员

积分
58
  • 140

    金币

  • 7

    主题

  • 9

    帖子

Silhouette
注册会员   /  发表于:2022-10-27 18:12  /   查看:986  /  回复:1
10金币
1. 创建自定义函数并注册到Spread 其中函数如下, 调用函数会打印code参数




const DemoFunction = function () {};

DemoFunction.prototype = new GC.Spread.CalcEngine.Functions.AsyncFunction('
DemoFunction', 1, 255, {
  description: '实例函数',
  parameters: [
    {
      name: 'code',
    }
  ],
});


DemoFunction.prototype.evaluateAsync = (context, ...args) => {
  const code = args[0];
  console.log('code', code)

};











2. 执行函数

sheet.setFormula(0, 0, `=DemoFunction('010343')`);

期望code打印出来为010343

实际code打印出来为10343

最佳答案

查看完整内容

您好, 在您提供代码基础上做了一些修改,测试结果如下图,具体请参考附件demo。

1 个回复

倒序浏览
最佳答案
最佳答案
Lynn.Dou讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2022-10-27 18:12:11
来自 2#
您好,
在您提供代码基础上做了一些修改,测试结果如下图,具体请参考附件demo。
image.png353605651.png

demo_function.zip

2.5 KB, 下载次数: 14

回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部