ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 11797|回复: 14

[求助] WPS新出的JS宏谁会啊教教萌新啊

[复制链接]

TA的精华主题

TA的得分主题

发表于 2021-2-21 17:56 | 显示全部楼层 |阅读模式
有没有教程啊

TA的精华主题

TA的得分主题

发表于 2021-2-22 10:55 来自手机 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2021-3-3 12:15 来自手机 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
zpy2 发表于 2021-2-22 10:55
http://club.excelhome.net/forum.php?mod=viewthread&tid=1567535&fromguid=hot&extra=&mobile=这种吗?

不是,支持js宏,就像支持vba一样

评分

1

查看全部评分

TA的精华主题

TA的得分主题

发表于 2021-3-10 12:07 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
问过金山办公的工作人员,说是直接使用JS宏,金山没做改变,没出专门教程,让需要的用户自行查阅JS宏资料。

TA的精华主题

TA的得分主题

发表于 2021-3-10 13:38 | 显示全部楼层
lavill 发表于 2021-3-10 12:07
问过金山办公的工作人员,说是直接使用JS宏,金山没做改变,没出专门教程,让需要的用户自行查阅JS宏资料。

ES6的语法,看样子还没完全实现。无法进行第三方扩展的话,还不如vba.window,dom对象没有,弱化很多。当然好处是跨平台支持简单,但这个也不在一般办公人员需求和考虑之中。

TA的精华主题

TA的得分主题

发表于 2021-5-10 23:23 | 显示全部楼层
只有企业版才能启用 宏。你们是怎么尝鲜的呢?

TA的精华主题

TA的得分主题

发表于 2021-7-15 12:25 | 显示全部楼层
正在研究,贴一个自己写的例子:
  1. class ParameterTypeError extends Error {
  2.         constructor(paramName, paramType) {
  3.                 if (!(typeof paramName == 'string'))
  4.                         throw new ParameterTypeError('paramName', String);
  5.                 if (!(paramType instanceof Function))
  6.                         throw new ParameterTypeError('paramType', Function);
  7.                
  8.                 let msg = 'Parameter "' + paramName +
  9.                         '" must be a ' + paramType.name +
  10.                         ' object.';
  11.                 super(msg);
  12.                                                
  13.                 this.ParameterName = paramName;
  14.                 this.ParameterType = paramType;
  15.         }
  16.        
  17.         toString() {
  18.                 return ParameterTypeError.name + ' : ' + this.message;
  19.         }
  20.        
  21.         static check(param, paramName, paramType) {
  22.                 if (!((param instanceof paramType) ||
  23.                         (typeof param == paramType.name.toLowerCase())))
  24.                         throw new ParameterTypeError(paramName, paramType);
  25.         }
  26. }

  27. class Point {       
  28.         constructor(x, y) {
  29.                 ParameterTypeError.check(x, 'x', Number);
  30.                 ParameterTypeError.check(y, 'y', Number);
  31.                
  32.                 this.x = x;
  33.                 this.y = y;
  34.                
  35.                 if (Point._count == undefined) {
  36.                         Point._count = 1;
  37.                 } else {               
  38.                         Point._count++;
  39.                 }

  40.         }
  41.        
  42.         static get count() {
  43.                 if (Point._count == undefined)
  44.                         return 0;
  45.                 else
  46.                         return Point._count;
  47.         }
  48.        
  49.         static get Version() {
  50.                 return '2D';
  51.         }
  52.        
  53.         toString() {
  54.                 return '(' + this.x + ', ' + this.y + ')';
  55.         }
  56.        
  57.         distanceTo(p) {
  58.                 ParameterTypeError.check(p, 'p', Point);

  59.                 return Math.sqrt(
  60.                         Math.pow(this.x - p.x, 2) +
  61.                         Math.pow(this.y - p.y, 2));
  62.         }
  63.        
  64.         static distanceBetween(p1, p2) {
  65.                 ParameterTypeError.check(p1, 'p1', Point);
  66.                 ParameterTypeError.check(p2, 'p2', Point);
  67.                
  68.                 return Math.sqrt(
  69.                         Math.pow(p1.x - p2.x, 2) +
  70.                         Math.pow(p1.y - p2.y, 2));
  71.         }
  72. }


  73. class NamedPoint extends Point {
  74.         constructor(name, x, y) {
  75.                 ParameterTypeError.check(name, 'name', String);
  76.                
  77.                 super(x, y);
  78.                 this._name = name;
  79.         }
  80.        
  81.         get name() {
  82.                 return this._name;
  83.         }
  84.        
  85.         toString() {
  86.                 return this._name + super.toString();
  87.         }
  88. }


  89. function classTest() {
  90.         let p = new Point(3, 4);
  91.         Console.log(p);
  92.         let np = new NamedPoint("ShotTarget", 6, 8);
  93.         Console.log(np);
  94.         //为只读属性赋值是无效的,但也不报错
  95.         np.name = "WTF";
  96.         Console.log(np);
  97.         Console.log(np.name);
  98.         Console.log(p.distanceTo(np));
  99.         Console.log('instance count : ' + Point.count);
  100.         //静态方法会被子类继承
  101.         Console.log(NamedPoint.distanceBetween(np, p));
  102.         //实例方法会被子类继承
  103.         Console.log(np.distanceTo(p));
  104.         //静态属性
  105.         Console.log('static property Version : ' + Point.Version);
  106.         //自定义异常
  107.         try {
  108.                 p.distanceTo(33);
  109.         } catch(e) {
  110.                 Console.log(e.message);
  111.                 Console.log(e);
  112.         }
  113.         Console.log(JSON.stringify(np));
  114. }


复制代码

TA的精华主题

TA的得分主题

发表于 2021-7-15 12:43 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
再贴一个:
  1. function ExcelTest() {
  2.         let rng = Application.InputBox("请选择单元格区域:",
  3.                 "选取单元格区域", undefined, undefined,
  4.                 undefined, undefined, undefined, 8);

  5.         try {
  6.                 for(let x in rng) {
  7.                         let v = rng[x];
  8.                         if (typeof v == 'function') {
  9.                                 Console.log(x + " => " + x + "(...)");
  10.                         } else {
  11.                                 if (!v.hasOwnProperty('toString')) continue;
  12.                                 Console.log(x + " => " + v);
  13.                         }
  14.                 }
  15.         } catch {}       
  16.        

  17.         for(let iRow = 1; iRow <= rng.Rows.Count; iRow++)
  18.                 for(let iColumn = 1; iColumn <= rng.Columns.Count; iColumn++) {
  19.                         let c = rng.Cells.Item(iRow, iColumn);
  20.                         Console.log(c.Value2);
  21.                 }       
  22.        
  23. }

复制代码


TA的精华主题

TA的得分主题

发表于 2021-7-15 15:05 | 显示全部楼层
一般办公人员劝退,很多东西都不成熟,没有大量的精力还是不要参和

TA的精华主题

TA的得分主题

发表于 2021-7-15 16:11 | 显示全部楼层
是啊,心里想着是要支持国产软件,但是无论是服务还是资源都非常有限,学起来非常的困难,这个实在是让人无法深入地做下去。
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-9-29 20:28 , Processed in 0.035494 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表