Git Product home page Git Product logo

Comments (1)

kdevilpf avatar kdevilpf commented on May 21, 2024

1、函数实现代码如下:
"EVALUATE": function() {
//必要参数个数错误检测
if (arguments.length < this.m[0] || arguments.length > this.m[1]) {
return formula.error.na;
}

    //参数类型错误检测
    for (var i = 0; i < arguments.length; i++) {
        var p = formula.errorParamCheck(this.p, arguments[i], i);

        if (!p[0]) {
            return formula.error.v;
        }
    }

    try {
        //公式文本
        var strtext = func_methods.getFirstValue(arguments[0]).toString();
        if(valueIsError(strtext)){
            return strtext;
        }

        //if (!window.luckysheet_function.ISIDCARD.f(UUserCard)) {
        //    return formula.error.v;
        //}
        //匹配简单公式,只能包含  空格 数字-+*/.()
        var formulastr = /[ \d\+\*\-\/\(\)\.]+/;
        var strtext2=strtext.match(formulastr)[0];
        return eval(strtext2);
    }
    catch (e) {
        var err = e;
        //计算错误检测
        err = formula.errorInfo(err);
        return [formula.error.v, err];
    }
},

2、中文语言包zh.js代码如下
// EVALUATE
{
"n": "EVALUATE",
"t": "3",
"d": "对以文字表示的一个公式或者表达式求值,并返回结果",
"a": "根据文字公式或者表达式求值。",
"m": [1, 1],
"p": [{
"name": "公式",
"example": '"56"',
"detail": "公式或表达式仅支持数字+-/
.()",
"require": "m",
"repeat": "n",
"type": "rangeall"
}]
},

from luckyexcel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.