Snapman多人协作电子表格是一个即时工作系统。

Snapman中嵌入了Exprtk脚本进行公式数据运算。Exprtk是一种高性能的脚本,经测试它的数据运算性能只比C#和java底20%。

一、Exprtk的类型和变量定义

  Exprtk的数据类型只有三种:Scalar(数字), Vector(数字数组), String(字符串);特别说明:Exprtk没有字符串数组

  基本的运算符有:+, -, *, /, %, ^

  赋值运算符有::=, +=, -=, *=, /=, %=

  判断运算符有:=, ==, <>, !=, <, <=, >, >=

  逻辑运算符有:and, mand, mor, nand, nor, not, or, shl, shr,xnor, xor, true, false

  字符串运算符有:in, like, ilike, concatenation

  Exprtk的变量定义为:

var iData := ;          //数字变量定义
var sData := 'Hello word.'; //字符串变量定义
var vData[] := {,,,}; //数组变量定义

  Snapman中Exprtk定义了四种特殊变量:

  1、单元格数字变量,列字母+行号数字,如:A1,H234

  2、单元格字符串变量,列字母+行号数字+下划线,如:A1_,H234_

  3、选择集数组,列字母+行号数字+冒号+列字母+行号数字,这是一个数字数组元素次序是按单元格从左往右从上往下,如:F2:G5

  4、列数组,列字母+冒号+列字母,这是一个数字数组元素次序是按单元格从左往右从上往下,如:F:H

  所以Snapman中Exprtk的变量定义都不要使用数字结尾或数字加下划线结尾

二、Exprtk的if、switch、for、while、continue、break语句

  1、if语句的类型

    A、if表达式:if (x, y, z) ;如果x为真返回y否则返回z;例如:

var x := ;
var y := ;
var z := ;
var w := 58.7;
var v := ;
var data := if ((x + ) > 2y, z + , w / v) ;
print(tostring(data));

    B、if语句块

if (x < y or (x + z) > y)
{
z := x + ;
y := x - z;
}
else if (abs(2y - z) >= )
y := x - z;
else
{
z := abs(x * x);
x * y * z;
};

  2、switch语句的类型

    switch语句会逐句判断case的条件,成立就执行代码表达式,如果case条件都不成立就执行default的代码表达式,最后将代码表达式的结果返回,如:

var x := ;
var y := ;
var z := ;
var a := switch
{
case x > (y + z) : * x / abs(y - z);
case x < : sin(x + y);
default : + x;
};
print(tostring(a));

    注意:case的条件和语句只允许有一条语句

  3、for语句

  for语句和C语言类似,但是它是一个表达式所以记住大括号后面需要有分号,如:

for (var x := ; (x < n) and (x != y); x += )
{
y := y + x / - z;
w := u + y;
};

  4、while语句

  while语句和C语言类似,但它是一个表达式所以记住大括号后面需要有分号,如:

while ((i += ) < )
{
if (i < )
j -= i + ;
else if (i % == )
break;
else
break[2i + ];
};

  5、continue、break、break[]语句

  continue、break和其C语言类似,break[]的意思是for和while语句是一条有返回值的表达式,break返回的是NaN,而break[]却是返回中括号中表达式的值,如上一个样例。

三、Exprtk的数组运算

  Exprtk有一个非常强大的数组运算,可以对数组变量进行批量运算和赋值

  1、赋值运算符都支持数组变量,如下面样例数组中每个变量都增加了13:

var vData[] := {, , , , };
vData += ;

  2、其他支持数组的运算符:+, -, *, /, %, ^

  3、支持的函数:avg, max, min, mul, sum, count

  4、当存在2个数组变量的时候,运算以个数少的为运算次数;当运算符为单维运算符或者单维函数,数组变量会取第一个元素进行运算

四、Exprtk的Snapman函数接口

  1、tolower(str),将字符串str转换成小写字母并返回,例如:e2_:=tolower('AHFGHJHKJDewiuri73972389HHJGJG中华人民共和国')
  2、toupper(str),将字符串str转换成大写字母并返回,例如:e3_:=toupper('AHFGHJHKJDewiuri73972389HHJGJG中华人民共和国')
  3、tostring(double),将数字转换成字符串并返回,例如:e4_:=tostring(0.4444488)
  4、tonumber(str),将字符串转换成数字并返回,例如:e5:=tonumber('5643786587')
  5、get(row,col),获取第row行、col列的单元格的数字,例如:e6:=get(7,1)
  6、set(row,col,double),设置第row行、col列的单元格的数字,例如:set(7,5,98766)
  7、get_(row,col),获取第row行、col列的单元格的字符串,例如:e8_:=get_(8,2)
  8、set_(row,col,str),设置第row行、col列的单元格的字符串,例如:set_(9,5,'大不了的给开发商')
  9、set_progress(n),设置进度条,n必须大于等于0,例如:set_progress(10)
  10、set_total_progress(t),设置进度条的最大值,t必须大于0,例如:set_total_progress(100)
  11、sleep(n),让线程睡眠n毫秒,例如:sleep(1000)
  12、get_tick_count(),获取从操作系统启动所经过的毫秒数,例如:E12:=get_tick_count()
  13、save(),保存当前电子表格,例如:save()
  14、count(vec),获取数组vec的个数,例如:E14:=count(C4:C11)
  15、print(str),打印str的内容,例如:print('Hello world.')
  16、set_background(row,col,str_lafer),设置第row行、col列的单元格背景的lafer,例如:set_background(16,5,'[[18,#9845f2,8,8,8],[18,#F865f2,16,55,8]]')

  17,get_row_count(),获取当前表格有内容的单元格行数,例如:set(18,5,get_row_count())
  18,get_col_count(),获取当前表格有内容的单元格列数,例如:set(19,5,get_col_count())

  19、E17或者e17,表格数据变量:字母表示列,数字表示行,例如:E17 := 100000.567;
  20、E18_或者e18_,表格字符串变量:字母表示列,数字表示行,例如:E18_ := '我是中国人。'
  21、E19:E21或者A:B,表格数据变量数组,先从左到右然后从上到下,没有数字代表从某列到某列,例如:E19:E21 := A17:A19

五、Exprtk自带的函数

    +----------+---------------------------------------------------------+
| FUNCTION | DEFINITION |
+----------+---------------------------------------------------------+
| abs | Absolute value of x. (eg: abs(x)) |
+----------+---------------------------------------------------------+
| avg | Average of all the inputs. |
| | (eg: avg(x,y,z,w,u,v) == (x + y + z + w + u + v) / ) |
+----------+---------------------------------------------------------+
| ceil | Smallest integer that is greater than or equal to x. |
+----------+---------------------------------------------------------+
| clamp | Clamp x in range between r0 and r1, where r0 < r1. |
| | (eg: clamp(r0,x,r1)) |
+----------+---------------------------------------------------------+
| equal | Equality test between x and y using normalised epsilon |
+----------+---------------------------------------------------------+
| erf | Error function of x. (eg: erf(x)) |
+----------+---------------------------------------------------------+
| erfc | Complimentary error function of x. (eg: erfc(x)) |
+----------+---------------------------------------------------------+
| exp | e to the power of x. (eg: exp(x)) |
+----------+---------------------------------------------------------+
| expm1 | e to the power of x minus , where x is very small. |
| | (eg: expm1(x)) |
+----------+---------------------------------------------------------+
| floor | Largest integer that is less than or equal to x. |
| | (eg: floor(x)) |
+----------+---------------------------------------------------------+
| frac | Fractional portion of x. (eg: frac(x)) |
+----------+---------------------------------------------------------+
| hypot | Hypotenuse of x and y (eg: hypot(x,y) = sqrt(x*x + y*y))|
+----------+---------------------------------------------------------+
| iclamp | Inverse-clamp x outside of the range r0 and r1. Where |
| | r0 < r1. If x is within the range it will snap to the |
| | closest bound. (eg: iclamp(r0,x,r1) |
+----------+---------------------------------------------------------+
| inrange | In-range returns 'true' when x is within the range r0 |
| | and r1. Where r0 < r1. (eg: inrange(r0,x,r1) |
+----------+---------------------------------------------------------+
| log | Natural logarithm of x. (eg: log(x)) |
+----------+---------------------------------------------------------+
| log10 | Base logarithm of x. (eg: log10(x)) |
+----------+---------------------------------------------------------+
| log1p | Natural logarithm of + x, where x is very small. |
| | (eg: log1p(x)) |
+----------+---------------------------------------------------------+
| log2 | Base logarithm of x. (eg: log2(x)) |
+----------+---------------------------------------------------------+
| logn | Base N logarithm of x. where n is a positive integer. |
| | (eg: logn(x,)) |
+----------+---------------------------------------------------------+
| max | Largest value of all the inputs. (eg: max(x,y,z,w,u,v)) |
+----------+---------------------------------------------------------+
| min | Smallest value of all the inputs. (eg: min(x,y,z,w,u)) |
+----------+---------------------------------------------------------+
| mul | Product of all the inputs. |
| | (eg: mul(x,y,z,w,u,v,t) == (x * y * z * w * u * v * t)) |
+----------+---------------------------------------------------------+
| ncdf | Normal cumulative distribution function. (eg: ncdf(x)) |
+----------+---------------------------------------------------------+
| nequal | Not-equal test between x and y using normalised epsilon |
+----------+---------------------------------------------------------+
| pow | x to the power of y. (eg: pow(x,y) == x ^ y) |
+----------+---------------------------------------------------------+
| root | Nth-Root of x. where n is a positive integer. |
| | (eg: root(x,) == x^(/)) |
+----------+---------------------------------------------------------+
| round | Round x to the nearest integer. (eg: round(x)) |
+----------+---------------------------------------------------------+
| roundn | Round x to n decimal places (eg: roundn(x,)) |
| | where n > and is an integer. |
| | (eg: roundn(1.2345678,) == 1.2346) |
+----------+---------------------------------------------------------+
| sgn | Sign of x, - where x < , + where x > , else zero. |
| | (eg: sgn(x)) |
+----------+---------------------------------------------------------+
| sqrt | Square root of x, where x >= . (eg: sqrt(x)) |
+----------+---------------------------------------------------------+
| sum | Sum of all the inputs. |
| | (eg: sum(x,y,z,w,u,v,t) == (x + y + z + w + u + v + t)) |
+----------+---------------------------------------------------------+
| swap | Swap the values of the variables x and y and return the |
| <=> | current value of y. (eg: swap(x,y) or x <=> y) |
+----------+---------------------------------------------------------+
| trunc | Integer portion of x. (eg: trunc(x)) |
+----------+---------------------------------------------------------+
| acos | Arc cosine of x expressed in radians. Interval [-,+] |
| | (eg: acos(x)) |
+----------+---------------------------------------------------------+
| acosh | Inverse hyperbolic cosine of x expressed in radians. |
| | (eg: acosh(x)) |
+----------+---------------------------------------------------------+
| asin | Arc sine of x expressed in radians. Interval [-,+] |
| | (eg: asin(x)) |
+----------+---------------------------------------------------------+
| asinh | Inverse hyperbolic sine of x expressed in radians. |
| | (eg: asinh(x)) |
+----------+---------------------------------------------------------+
| atan | Arc tangent of x expressed in radians. Interval [-,+] |
| | (eg: atan(x)) |
+----------+---------------------------------------------------------+
| atan2 | Arc tangent of (x / y) expressed in radians. [-pi,+pi] |
| | eg: atan2(x,y) |
+----------+---------------------------------------------------------+
| atanh | Inverse hyperbolic tangent of x expressed in radians. |
| | (eg: atanh(x)) |
+----------+---------------------------------------------------------+
| cos | Cosine of x. (eg: cos(x)) |
+----------+---------------------------------------------------------+
| cosh | Hyperbolic cosine of x. (eg: cosh(x)) |
+----------+---------------------------------------------------------+
| cot | Cotangent of x. (eg: cot(x)) |
+----------+---------------------------------------------------------+
| csc | Cosecant of x. (eg: csc(x)) |
+----------+---------------------------------------------------------+
| sec | Secant of x. (eg: sec(x)) |
+----------+---------------------------------------------------------+
| sin | Sine of x. (eg: sin(x)) |
+----------+---------------------------------------------------------+
| sinc | Sine cardinal of x. (eg: sinc(x)) |
+----------+---------------------------------------------------------+
| sinh | Hyperbolic sine of x. (eg: sinh(x)) |
+----------+---------------------------------------------------------+
| tan | Tangent of x. (eg: tan(x)) |
+----------+---------------------------------------------------------+
| tanh | Hyperbolic tangent of x. (eg: tanh(x)) |
+----------+---------------------------------------------------------+
| deg2rad | Convert x from degrees to radians. (eg: deg2rad(x)) |
+----------+---------------------------------------------------------+
| deg2grad | Convert x from degrees to gradians. (eg: deg2grad(x)) |
+----------+---------------------------------------------------------+
| rad2deg | Convert x from radians to degrees. (eg: rad2deg(x)) |
+----------+---------------------------------------------------------+
| grad2deg | Convert x from gradians to degrees. (eg: grad2deg(x)) |
+----------+---------------------------------------------------------+

六、Exprtk样例

//1、各行求和
for(var row := get_row_count() - ; row > ; row := row - )
{
var isum := ;
for(var col := get_col_count() - ; col >= ; col := col - )
{
isum += get(row,col);
}
set(row,get_col_count() - ,isum);
};
//2、各列求和
for(var col := get_col_count() - ; col >= ; col := col - )
{
var isum := ;
for(var row := get_row_count() - ; row > ; row := row - )
{
isum += get(row,col);
}
set(get_row_count() - ,col,isum);
};

  Exprtk的具体语法,请参考:Exprtk语言语法说明

七、Snapman的下载地址

  Snapman下载的官网地址:http://www.snapman.xyz

  Snapman技术支持QQ群:596654328

  

四、Snapman多人协作电子表格之——Exprtk脚本的更多相关文章

  1. 五、Snapman多人协作电子表格之——Python脚本

    Snapman多人协作电子表格是一个即时工作系统. Snapman中嵌入了Python脚本进行数据处理. 一.Snapman集合python语言介绍 将单元格设置为python脚本的方法:用Snapm ...

  2. 三、Snapman多人协作电子表格之——软件的基本功能

    Snapman多人协作电子表格是一个即时工作系统. 一.SnapmanServer服务端 SnapmanServer服务端在安装Snapman软件一起自带,是一个小巧的控制台程序SnapmanServ ...

  3. 二、Snapman多人协作电子表格之——软件下载安装与配置

    Snapman多人协作电子表格是一个即时工作系统. 一.软件下载地址 Snapman下载的官网地址:http://www.snapman.xyz 在官网下载Snapman主程序安装: snapman_ ...

  4. 一、Snapman多人协作电子表格之——Snapman自我介绍

    一.Snapman系统介绍 Snapman是一个真正现代化的电子表格系统:QQ是即时通讯软件,那Snapman就是一个即时工作系统. 微软CEO纳德拉说:Excel才是微软最伟大的产品,Excel将所 ...

  5. Snapde电子表格编写Exprtk脚本进行数据运算

    Snapde,一个专门为编辑超大型数据量CSV文件而设计的单机版电子表格软件:它运行的速度非常快,反应非常灵敏. 一.打开文件:用Snapde打开需要运算的CSV文件 二.添加行列:在编辑菜单找到设置 ...

  6. GitHub笔记(三)——分支管理和多人协作

    三.分支管理 0 语句: 查看分支:git branch 创建分支:git branch <name> 切换分支:git checkout <name> 创建+切换分支:git ...

  7. 五、git学习之——分支管理策略、Bug分支、feature分支、多人协作

    一.分支管理策略 通常,合并分支时,如果可能,Git会用Fast forward模式,但这种模式下,删除分支后,会丢掉分支信息. 如果要强制禁用Fast forward模式,Git就会在merge时生 ...

  8. Git详细教程---多人协作开发

    Git可以完成两件事情: 1. 版本控制 2.多人协作开发 如今的项目,规模越来越大,功能越来越多,需要有一个团队进行开发. 如果有多个开发人员共同开发一个项目,如何进行协作的呢. Git提供了一个非 ...

  9. Git版本控制之多人协作

         上篇文章我们主要简单的介绍了有关git的一些基本常识和一些简单的命令.但那终究是皮毛,我们使用git最主要的目的还是管理我们的项目,多人协作.本篇文章主要涉及以下两个大模块: 分支的概念及原 ...

随机推荐

  1. Itest(爱测试),最懂测试人的开源测试管理软件隆重发布

    测试人自己开发,汇聚10年沉淀,独创流程驱动测试.度量展现测试人价值的测试协同软件,开源免费   官网刚上线,近期发布源码:http://www.itest.work 在线体验 http://www. ...

  2. kubernetes实践之二:Kubernetes可视WEB UI Dashboard搭建

    Kubernetes可视WEBUI Dashboard搭建 支持浏览器:火狐 一.Dashboard下载地址 git clone https://github.com/kubernetes/kuber ...

  3. C# .NET Web API 如何自訂 ModelBinder

    各位好!這次要來替大家介紹的是如何在 .NET  Web API 中自訂一個 ModelBinder 透過自定義的 ModelBinder 我們可以很簡單的將 QueryString 傳過來的參數綁定 ...

  4. .net double类型转string类型的坑

    之前项目当中的接入的高德逆地理编码功能偶尔会出现参数错误的bug,经过排查服务端异常log,发现请求的url中的location参数中的小数点变成了逗号. 代码如下 public async Task ...

  5. 小程序后端项目【Springboot框架】部署到阿里云服务器【支持https访问】

    前言: 我的后端项目是Java写的,用的Springboot框架.在部署服务器并配置https访问过程中,因为做了一些令人窒息的操作(事后发现),所以老是不能成功. 不成功具体点说就是:域名地址可以正 ...

  6. 2018-08-20 中文代码之Spring Boot集成H2内存数据库

    续前文: 中文代码之Spring Boot添加基本日志, 源码库地址相同. 鉴于此项目中的数据总量不大(即使万条词条也在1MB之内), 当前选择轻量级而且配置简单易于部署的H2内存数据库比较合理. 此 ...

  7. 【IIS】解决IIS无响应假死状态,asp突然无法访问重启后可以使用是什么原因

    在IIS6下,经常出现w3wp的内存占用不能及时释放,从而导致服务器响应速度很慢. 可以做以下配置:1.在IIS中对每个网站进行单独的应用程序池配置.即互相之间不影响.2.设置应用程序池的回收时间,默 ...

  8. Exp5 Msf基础应用 20164312 马孝涛

    1.本实践目标是掌握metasploit的基本应用方式,重点常用的三种攻击方式的思路.具体需要完成: 1.1一个主动攻击实践,如ms08_067; (1分) 1.2 一个针对浏览器的攻击,如ms11_ ...

  9. lombok的安装

    Lombok简介 Lombok是一个可以通过简单的注解形式来帮助我们简化消除一些必须有但显得很臃肿的Java代码的工具,通过使用对应的注解,可以在编译源码的时候生成对应的方法.官方地址:https:/ ...

  10. Cocos Creator—最佳构建部署实践

    这篇文章主要是我们团队在使用Cocos Creator过程中的一些关于部署方面的实践总结,标题党了一回,严格来说,应该是<快看漫画游戏研发团队使用Cocos Creator构建部署最佳实践> ...