Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #346 from kdevilpf/master
Browse files Browse the repository at this point in the history
修改了EVALUATE函数代码
  • Loading branch information
Dushusir committed Dec 14, 2020
2 parents 95e26c3 + 5c5f2cb commit 669ed2a
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 15 deletions.
19 changes: 11 additions & 8 deletions src/function/functionImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -27562,19 +27562,22 @@ const functionImplementation = {
}

try {
var cell_r = window.luckysheetCurrentRow;
var cell_c = window.luckysheetCurrentColumn;
var sheetindex_now = window.luckysheetCurrentIndex;
//公式文本
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);
//在文本公式前面添加=
if(strtext.trim().indexOf('=')!=0)
{
strtext ='='+strtext;
}
//console.log(strtext);
var result_this = formula.execstringformula(strtext,cell_r,cell_c,sheetindex_now);
return result_this[1];
}
catch (e) {
var err = e;
Expand Down
5 changes: 5 additions & 0 deletions src/global/formula.js
Original file line number Diff line number Diff line change
Expand Up @@ -5758,6 +5758,11 @@ const luckysheetformula = {
return false;
}
},
//供function/functionImplementation.js的EVALUATE函数调用。
execstringformula: function (txt, r, c, index) {
let _this = this;
return this.execfunction(txt, r, c, index);
},
functionResizeData: {},
functionResizeStatus: false,
functionResizeTimeout: null,
Expand Down
4 changes: 2 additions & 2 deletions src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -8820,8 +8820,8 @@ export default {
"m": [1, 1],
"p": [{
"name": "expression",
"example": '"5*6"',
"detail": "Formula or expression only supports numbers+-/*.()",
"example": '"A1+5*2^2"',
"detail": "Formula or expression",
"require": "m",
"repeat": "n",
"type": "rangeall"
Expand Down
4 changes: 2 additions & 2 deletions src/locale/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -8820,8 +8820,8 @@ export default {
"m": [1, 1],
"p": [{
"name": "expression",
"example": '"5*6"',
"detail": "Formula or expression only supports numbers+-/*.()",
"example": '"A1+5*2^2"',
"detail": "Formula or expression",
"require": "m",
"repeat": "n",
"type": "rangeall"
Expand Down
6 changes: 3 additions & 3 deletions src/locale/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -9040,13 +9040,13 @@ export default {
{
"n": "EVALUATE",
"t": "3",
"d": "对以文字表示的一个公式或者表达式求值,并返回结果",
"d": "对以文字表示的公式或者表达式求值,并返回结果",
"a": "根据文字公式或者表达式求值。",
"m": [1, 1],
"p": [{
"name": "公式",
"example": '"5*6"',
"detail": "公式或表达式仅支持数字+-/*.()",
"example": '"A1+5*2^2"',
"detail": "公式或表达式",
"require": "m",
"repeat": "n",
"type": "rangeall"
Expand Down
14 changes: 14 additions & 0 deletions src/locale/zh_tw.js
Original file line number Diff line number Diff line change
Expand Up @@ -9038,6 +9038,20 @@ export default {
'repeat' : 'n',
'type' : 'rangenumber'
}]
},{
'n': 'EVALUATE',
't': '3',
'd': '對以文字表示的公式或者表達式求值,並返回結果。',
'a': '根據文字公式或者表達式求值。',
'm': [1, 1],
"p": [{
"name": "公式",
"example": '"A1+5*2^2"',
"detail": "公式或表達式",
"require": "m",
"repeat": "n",
"type": "rangeall"
}]
},
],
toolbar: {
Expand Down

0 comments on commit 669ed2a

Please sign in to comment.