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

Commit

Permalink
fix(formula -(1-2) error): fix it
Browse files Browse the repository at this point in the history
  • Loading branch information
tubiaoge committed Aug 26, 2020
1 parent 20f3cb3 commit dee2333
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
31 changes: 16 additions & 15 deletions src/function/func.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
import func_methods from '../global/func_methods';
import formula from '../global/formula';
import tooltip from '../global/tooltip';
import { isRealNum, valueIsError } from '../global/validate';
import { isRealNum, valueIsError,error } from '../global/validate';
import { getdatabyselectionD } from '../global/getdata';
import { genarate } from '../global/format';
import { inverse } from '../function/matrix_methods';
import { getSheetIndex, getluckysheetfile, getRangetxt } from '../methods/get';
import { getObjType, ABCatNum } from '../utils/util';
import Store from '../store';

const error = {
v: "#VALUE!", //错误的参数或运算符
n: "#NAME?", //公式名称错误
na: "#N/A", //函数或公式中没有可用数值
r: "#REF!", //删除了由其他公式引用的单元格
d: "#DIV/0!", //除数是0或空单元格
nm: "#NUM!", //当公式或函数中某个数字有问题时
nl: "#NULL!", //交叉运算符(空格)使用不正确
sp: "#SPILL!" //数组范围有其它值
}

//函数功能:比较或运算
function luckysheet_compareWith() {
//第一个参数和第三个参数,返回比较结果的布尔值或者运算值
Expand Down Expand Up @@ -89,7 +78,19 @@ function luckysheet_compareWith() {
sp = "==";
}

if(sp == "-" && fp == null){
if(fp==null && tp==null){
return "#INVERSE!";
}
else if(fp=="#INVERSE!"){
fp =0;
if(sp=="-"){
sp = "+";
}
else if(sp=="+"){
sp = "-";
}
}
else if(sp == "-" && fp == null){
fp = 0;
}

Expand Down Expand Up @@ -965,7 +966,7 @@ function luckysheet_compareWith() {
value = error.d;
}
else{
value = eval(parseFloat(fp[n]) + sp + parseFloat(tp[n]));
value = eval(parseFloat(fp[n]) + sp + "(" + parseFloat(tp[n]) + ")" );
}
}
else{
Expand Down Expand Up @@ -1096,7 +1097,7 @@ function luckysheet_compareWith() {
result = error.d;
}
else{
result = eval(parseFloat(fp) + sp + parseFloat(tp));
result = eval(parseFloat(fp) + sp + "(" + parseFloat(tp) + ")");
}
}
else{
Expand Down
2 changes: 1 addition & 1 deletion src/global/formula.js
Original file line number Diff line number Diff line change
Expand Up @@ -3845,7 +3845,7 @@ const luckysheetformula = {

i++;
}

console.log(function_str);
return function_str;
},
addFunctionGroup: function(r, c, func, index) {
Expand Down
2 changes: 1 addition & 1 deletion src/global/validate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import luckysheetConfigsetting from '../controllers/luckysheetConfigsetting';
import Store from '../store';

const error = {
export const error = {
v: "#VALUE!", //错误的参数或运算符
n: "#NAME?", //公式名称错误
na: "#N/A", //函数或公式中没有可用数值
Expand Down

0 comments on commit dee2333

Please sign in to comment.