|
|
@ -680,7 +680,7 @@ const luckysheetformula = { |
|
|
|
|
|
|
|
let sheettxt = "", |
|
|
|
rangetxt = "", |
|
|
|
sheetIndex = -1, |
|
|
|
sheetIndex = null, |
|
|
|
sheetdata = null; |
|
|
|
|
|
|
|
let luckysheetfile = getluckysheetfile(); |
|
|
@ -1279,7 +1279,7 @@ const luckysheetformula = { |
|
|
|
|
|
|
|
if(getObjType(value) == "string" && value.slice(0, 1) == "=" && value.length > 1){ |
|
|
|
let v = _this.execfunction(value, r, c, true); |
|
|
|
|
|
|
|
isRunExecFunction = false; |
|
|
|
curv = _this.execFunctionGroupData[r][c]; |
|
|
|
curv.f = v[2]; |
|
|
|
|
|
|
@ -1307,7 +1307,7 @@ const luckysheetformula = { |
|
|
|
|
|
|
|
if(getObjType(valueFunction) == "string" && valueFunction.slice(0, 1) == "=" && valueFunction.length > 1){ |
|
|
|
let v = _this.execfunction(valueFunction, r, c, true); |
|
|
|
|
|
|
|
isRunExecFunction = false; |
|
|
|
// get v/m/ct
|
|
|
|
|
|
|
|
curv = _this.execFunctionGroupData[r][c]; |
|
|
@ -1337,7 +1337,7 @@ const luckysheetformula = { |
|
|
|
|
|
|
|
if(getObjType(valueFunction) == "string" && valueFunction.slice(0, 1) == "=" && valueFunction.length > 1){ |
|
|
|
let v = _this.execfunction(valueFunction, r, c, true); |
|
|
|
|
|
|
|
isRunExecFunction = false; |
|
|
|
// get v/m/ct
|
|
|
|
curv = _this.execFunctionGroupData[r][c]; |
|
|
|
|
|
|
@ -1392,7 +1392,7 @@ const luckysheetformula = { |
|
|
|
else { |
|
|
|
if(getObjType(value) == "string" && value.slice(0, 1) == "=" && value.length > 1){ |
|
|
|
let v = _this.execfunction(value, r, c, true); |
|
|
|
|
|
|
|
isRunExecFunction = false; |
|
|
|
value = { |
|
|
|
"v": v[1], |
|
|
|
"f": v[2] |
|
|
@ -1419,7 +1419,7 @@ const luckysheetformula = { |
|
|
|
|
|
|
|
if(getObjType(valueFunction) == "string" && valueFunction.slice(0, 1) == "=" && valueFunction.length > 1){ |
|
|
|
let v = _this.execfunction(valueFunction, r, c, true); |
|
|
|
|
|
|
|
isRunExecFunction = false; |
|
|
|
// value = {
|
|
|
|
// "v": v[1],
|
|
|
|
// "f": v[2]
|
|
|
@ -1894,7 +1894,7 @@ const luckysheetformula = { |
|
|
|
else if (orient == "l" && !freezonFuc[1]) { |
|
|
|
col -= step; |
|
|
|
} |
|
|
|
else if (!freezonFuc[0]) { |
|
|
|
else if (orient == "d" && !freezonFuc[0]) { |
|
|
|
row += step; |
|
|
|
} |
|
|
|
|
|
|
@ -1966,7 +1966,7 @@ const luckysheetformula = { |
|
|
|
col[1] -= step; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else if(orient=="d") { |
|
|
|
if (!freezonFuc0[0]) { |
|
|
|
row[0] += step; |
|
|
|
} |
|
|
@ -4150,7 +4150,7 @@ const luckysheetformula = { |
|
|
|
setluckysheetfile(luckysheetfile); |
|
|
|
}, |
|
|
|
isFunctionRangeSave: false, |
|
|
|
isFunctionRange1: function(txt, r, c) { |
|
|
|
isFunctionRangeSimple: function(txt, r, c,dynamicArray_compute) { |
|
|
|
let _this = this; |
|
|
|
|
|
|
|
if (_this.operatorjson == null) { |
|
|
@ -4182,7 +4182,7 @@ const luckysheetformula = { |
|
|
|
} |
|
|
|
|
|
|
|
let luckysheetfile = getluckysheetfile(); |
|
|
|
let dynamicArray_compute = luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dynamicArray_compute"] == null ? {} : luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dynamicArray_compute"]; |
|
|
|
|
|
|
|
|
|
|
|
while (i < funcstack.length) { |
|
|
|
let s = funcstack[i]; |
|
|
@ -4201,12 +4201,12 @@ const luckysheetformula = { |
|
|
|
} |
|
|
|
else if (s == ")" && matchConfig.dquote == 0) { |
|
|
|
matchConfig.bracket -= 1; |
|
|
|
function_str += _this.isFunctionRange(str, r, c) + ")"; |
|
|
|
function_str += _this.isFunctionRangeSimple(str, r, c,dynamicArray_compute) + ")"; |
|
|
|
str = ""; |
|
|
|
} |
|
|
|
else if (s == ',' && matchConfig.dquote == 0) { |
|
|
|
//matchConfig.comma += 1;
|
|
|
|
function_str += _this.isFunctionRange(str, r, c) + ','; |
|
|
|
function_str += _this.isFunctionRangeSimple(str, r, c,dynamicArray_compute) + ','; |
|
|
|
str = ""; |
|
|
|
} |
|
|
|
else if (s in _this.operatorjson && matchConfig.dquote == 0) { |
|
|
@ -4218,7 +4218,7 @@ const luckysheetformula = { |
|
|
|
|
|
|
|
if ((s + s_next) in _this.operatorjson) { |
|
|
|
if (str.length > 0) { |
|
|
|
function_str += _this.isFunctionRange(str, r, c) + s + s_next; |
|
|
|
function_str += _this.isFunctionRangeSimple(str, r, c,dynamicArray_compute) + s + s_next; |
|
|
|
str = ""; |
|
|
|
} |
|
|
|
else { |
|
|
@ -4229,7 +4229,7 @@ const luckysheetformula = { |
|
|
|
} |
|
|
|
else { |
|
|
|
if (str.length > 0) { |
|
|
|
function_str += _this.isFunctionRange(str, r, c) + s; |
|
|
|
function_str += _this.isFunctionRangeSimple(str, r, c,dynamicArray_compute) + s; |
|
|
|
str = ""; |
|
|
|
} |
|
|
|
else { |
|
|
@ -4243,48 +4243,50 @@ const luckysheetformula = { |
|
|
|
|
|
|
|
if (i == funcstack.length - 1) { |
|
|
|
if (_this.iscelldata($.trim(str))) { |
|
|
|
if (r != null && c != null) { |
|
|
|
let range = _this.getcellrange($.trim(str)); |
|
|
|
let row = range.row, |
|
|
|
col = range.column; |
|
|
|
|
|
|
|
if ((r + "_" + c) in dynamicArray_compute) { |
|
|
|
let isd_range = false; |
|
|
|
|
|
|
|
for (let d_r = row[0]; d_r <= row[1]; d_r++) { |
|
|
|
for (let d_c = col[0]; d_c <= col[1]; d_c++) { |
|
|
|
if ((d_r + "_" + d_c) in dynamicArray_compute && dynamicArray_compute[d_r + "_" + d_c].r == r && dynamicArray_compute[d_r + "_" + d_c].c == c) { |
|
|
|
isd_range = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (isd_range) { |
|
|
|
_this.isFunctionRangeSave = _this.isFunctionRangeSave || true; |
|
|
|
} |
|
|
|
else { |
|
|
|
_this.isFunctionRangeSave = _this.isFunctionRangeSave || false; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
if (r >= row[0] && r <= row[1] && c >= col[0] && c <= col[1]) { |
|
|
|
_this.isFunctionRangeSave = _this.isFunctionRangeSave || true; |
|
|
|
} |
|
|
|
else { |
|
|
|
_this.isFunctionRangeSave = _this.isFunctionRangeSave || false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
let sheetlen = $.trim(str).split("!"); |
|
|
|
|
|
|
|
if (sheetlen.length > 1) { |
|
|
|
_this.isFunctionRangeSave = _this.isFunctionRangeSave || true; |
|
|
|
} |
|
|
|
else { |
|
|
|
_this.isFunctionRangeSave = _this.isFunctionRangeSave || false; |
|
|
|
} |
|
|
|
} |
|
|
|
_this.isFunctionRangeSaveChange(str, r, c, dynamicArray_compute); |
|
|
|
// if (r != null && c != null) {
|
|
|
|
|
|
|
|
// let range = _this.getcellrange($.trim(str));
|
|
|
|
// let row = range.row,
|
|
|
|
// col = range.column;
|
|
|
|
|
|
|
|
// if ((r + "_" + c) in dynamicArray_compute) {
|
|
|
|
// let isd_range = false;
|
|
|
|
|
|
|
|
// for (let d_r = row[0]; d_r <= row[1]; d_r++) {
|
|
|
|
// for (let d_c = col[0]; d_c <= col[1]; d_c++) {
|
|
|
|
// if ((d_r + "_" + d_c) in dynamicArray_compute && dynamicArray_compute[d_r + "_" + d_c].r == r && dynamicArray_compute[d_r + "_" + d_c].c == c) {
|
|
|
|
// isd_range = true;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (isd_range) {
|
|
|
|
// _this.isFunctionRangeSave = _this.isFunctionRangeSave || true;
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// _this.isFunctionRangeSave = _this.isFunctionRangeSave || false;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// if (r >= row[0] && r <= row[1] && c >= col[0] && c <= col[1]) {
|
|
|
|
// _this.isFunctionRangeSave = _this.isFunctionRangeSave || true;
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// _this.isFunctionRangeSave = _this.isFunctionRangeSave || false;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// let sheetlen = $.trim(str).split("!");
|
|
|
|
|
|
|
|
// if (sheetlen.length > 1) {
|
|
|
|
// _this.isFunctionRangeSave = _this.isFunctionRangeSave || true;
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// _this.isFunctionRangeSave = _this.isFunctionRangeSave || false;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
} |
|
|
|
else { |
|
|
|
//console.log(str);
|
|
|
@ -4296,7 +4298,19 @@ const luckysheetformula = { |
|
|
|
//console.log(function_str);
|
|
|
|
return function_str; |
|
|
|
}, |
|
|
|
isFunctionRange: function (txt, r, c) { |
|
|
|
isFunctionRangeSelect:function(txt, r, c, dynamicArray_compute){ |
|
|
|
if(txt==null || txt==""){ |
|
|
|
return; |
|
|
|
} |
|
|
|
let txt1 = txt.toUpperCase(); |
|
|
|
if(txt1.indexOf("INDIRECT")>-1 || txt1.indexOf("OFFSET")>-1){ |
|
|
|
this.isFunctionRange(txt, r, c, dynamicArray_compute); |
|
|
|
} |
|
|
|
else{ |
|
|
|
this.isFunctionRangeSimple(txt, r, c, dynamicArray_compute); |
|
|
|
} |
|
|
|
}, |
|
|
|
isFunctionRange: function (txt, r, c, dynamicArray_compute) { |
|
|
|
let _this = this; |
|
|
|
|
|
|
|
if (_this.operatorjson == null) { |
|
|
@ -4329,8 +4343,8 @@ const luckysheetformula = { |
|
|
|
"braces": 0 |
|
|
|
} |
|
|
|
|
|
|
|
let luckysheetfile = getluckysheetfile(); |
|
|
|
let dynamicArray_compute = luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dynamicArray_compute"] == null ? {} : luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dynamicArray_compute"]; |
|
|
|
// let luckysheetfile = getluckysheetfile();
|
|
|
|
// let dynamicArray_compute = luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dynamicArray_compute"] == null ? {} : luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dynamicArray_compute"];
|
|
|
|
|
|
|
|
//bracket 0为运算符括号、1为函数括号
|
|
|
|
let cal1 = [], cal2 = [], bracket = []; |
|
|
@ -4358,7 +4372,7 @@ const luckysheetformula = { |
|
|
|
let bt = bracket.pop(); |
|
|
|
|
|
|
|
if (bracket.length == 0) { |
|
|
|
function_str += _this.isFunctionRange(str,r,c) + ")"; |
|
|
|
function_str += _this.isFunctionRange(str,r,c,dynamicArray_compute) + ")"; |
|
|
|
str = ""; |
|
|
|
} |
|
|
|
else { |
|
|
@ -4385,7 +4399,7 @@ const luckysheetformula = { |
|
|
|
} |
|
|
|
else if (s == ',' && matchConfig.dquote == 0 && matchConfig.braces == 0) { |
|
|
|
if (bracket.length <= 1) { |
|
|
|
function_str += _this.isFunctionRange(str, r, c) + ","; |
|
|
|
function_str += _this.isFunctionRange(str, r, c,dynamicArray_compute) + ","; |
|
|
|
str = ""; |
|
|
|
} |
|
|
|
else { |
|
|
@ -4403,7 +4417,7 @@ const luckysheetformula = { |
|
|
|
if ((s + s_next) in _this.operatorjson) { |
|
|
|
if (bracket.length == 0) { |
|
|
|
if ($.trim(str).length > 0) { |
|
|
|
cal2.unshift(_this.isFunctionRange($.trim(str), r, c)); |
|
|
|
cal2.unshift(_this.isFunctionRange($.trim(str), r, c,dynamicArray_compute)); |
|
|
|
} |
|
|
|
else if ($.trim(function_str).length > 0) { |
|
|
|
cal2.unshift($.trim(function_str)); |
|
|
@ -4432,7 +4446,7 @@ const luckysheetformula = { |
|
|
|
else { |
|
|
|
if (bracket.length == 0) { |
|
|
|
if ($.trim(str).length > 0) { |
|
|
|
cal2.unshift(_this.isFunctionRange($.trim(str), r, c)); |
|
|
|
cal2.unshift(_this.isFunctionRange($.trim(str), r, c,dynamicArray_compute)); |
|
|
|
} |
|
|
|
else if ($.trim(function_str).length > 0) { |
|
|
|
cal2.unshift($.trim(function_str)); |
|
|
@ -4538,9 +4552,10 @@ const luckysheetformula = { |
|
|
|
if (r != null && c != null) { |
|
|
|
let range = _this.getcellrange($.trim(str)); |
|
|
|
let row = range.row, |
|
|
|
col = range.column; |
|
|
|
col = range.column, |
|
|
|
index = range.sheetIndex; |
|
|
|
|
|
|
|
if ((r + "_" + c) in dynamicArray_compute) { |
|
|
|
if ((r + "_" + c) in dynamicArray_compute && (Store.currentSheetIndex==index || index==null)) { |
|
|
|
let isd_range = false; |
|
|
|
|
|
|
|
for (let d_r = row[0]; d_r <= row[1]; d_r++) { |
|
|
@ -4559,7 +4574,7 @@ const luckysheetformula = { |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
if (r >= row[0] && r <= row[1] && c >= col[0] && c <= col[1]) { |
|
|
|
if (r >= row[0] && r <= row[1] && c >= col[0] && c <= col[1] && (Store.currentSheetIndex==index || index==null)) { |
|
|
|
_this.isFunctionRangeSave = _this.isFunctionRangeSave || true; |
|
|
|
} |
|
|
|
else { |
|
|
@ -4571,7 +4586,7 @@ const luckysheetformula = { |
|
|
|
let sheetlen = $.trim(str).split("!"); |
|
|
|
|
|
|
|
if (sheetlen.length > 1) { |
|
|
|
_this.isFunctionRangeSave = _this.isFunctionRangeSave || true; |
|
|
|
_this.isFunctionRangeSave = _this.isFunctionRangeSave || true;//if change sheet, it must be true, but this is very slow
|
|
|
|
} |
|
|
|
else { |
|
|
|
_this.isFunctionRangeSave = _this.isFunctionRangeSave || false; |
|
|
@ -4655,8 +4670,10 @@ const luckysheetformula = { |
|
|
|
window.luckysheet_offset_check = luckysheet_offset_check; |
|
|
|
window.luckysheet_calcADPMM = luckysheet_calcADPMM; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_this.execFunctionGroupData = $.extend(true, [], data); |
|
|
|
let luckysheetfile = getluckysheetfile(); |
|
|
|
let dynamicArray_compute = luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dynamicArray_compute"] == null ? {} : luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dynamicArray_compute"]; |
|
|
|
|
|
|
|
if (value != null) { |
|
|
|
//此处setcellvalue 中this.execFunctionGroupData会保存想要更新的值,本函数结尾不要设为null,以备后续函数使用
|
|
|
@ -4675,8 +4692,6 @@ const luckysheetformula = { |
|
|
|
|
|
|
|
_this.execvertex = {}; |
|
|
|
if (_this.execFunctionExist == null) { |
|
|
|
let luckysheetfile = getluckysheetfile(); |
|
|
|
|
|
|
|
for (let i = 0; i < group.length; i++) { |
|
|
|
let item = group[i]; |
|
|
|
let file =luckysheetfile[getSheetIndex(item["index"])]; |
|
|
@ -4702,10 +4717,10 @@ const luckysheetformula = { |
|
|
|
_this.isFunctionRangeSave = true; |
|
|
|
} |
|
|
|
else if (origin_r != null && origin_c != null) { |
|
|
|
_this.isFunctionRange(calc_funcStr, origin_r, origin_c); |
|
|
|
_this.isFunctionRangeSelect(calc_funcStr, origin_r, origin_c, dynamicArray_compute); |
|
|
|
} |
|
|
|
else { |
|
|
|
_this.isFunctionRange(calc_funcStr); |
|
|
|
_this.isFunctionRangeSelect(calc_funcStr, undefined, undefined ,dynamicArray_compute); |
|
|
|
} |
|
|
|
|
|
|
|
if (_this.isFunctionRangeSave) { |
|
|
@ -4738,7 +4753,7 @@ const luckysheetformula = { |
|
|
|
_this.isFunctionRangeSave = true; |
|
|
|
} |
|
|
|
else{ |
|
|
|
_this.isFunctionRange(calc_funcStr, cell.r, cell.c); |
|
|
|
_this.isFunctionRangeSelect(calc_funcStr, cell.r, cell.c, dynamicArray_compute); |
|
|
|
} |
|
|
|
|
|
|
|
if (_this.isFunctionRangeSave) { |
|
|
@ -4749,7 +4764,7 @@ const luckysheetformula = { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
while (stack.length > 0) { |
|
|
|
let u = stack.shift(); |
|
|
|
|
|
|
@ -4761,7 +4776,7 @@ const luckysheetformula = { |
|
|
|
_this.isFunctionRangeSave = false; |
|
|
|
let item = vertex1[name]; |
|
|
|
let calc_funcStr = getcellFormula(item.r, item.c, item.index, _this.execFunctionGroupData); |
|
|
|
_this.isFunctionRange(calc_funcStr, u.r, u.c); |
|
|
|
_this.isFunctionRangeSelect(calc_funcStr, u.r, u.c, dynamicArray_compute); |
|
|
|
|
|
|
|
if (_this.isFunctionRangeSave) { |
|
|
|
let v = vertex1[name]; |
|
|
@ -4798,10 +4813,8 @@ const luckysheetformula = { |
|
|
|
//深度优先算法,处理多级调用函数
|
|
|
|
functionDFS: function(u) { |
|
|
|
let _this = this; |
|
|
|
|
|
|
|
u.color = "g"; |
|
|
|
u.times += 1; |
|
|
|
|
|
|
|
for (let chd in u.chidren) { |
|
|
|
let v = _this.execvertex[chd]; |
|
|
|
if (v.color == "w") { |
|
|
@ -4813,6 +4826,7 @@ const luckysheetformula = { |
|
|
|
u.color = "b"; |
|
|
|
window.luckysheet_getcelldata_cache = null; |
|
|
|
let calc_funcStr = getcellFormula(u.r, u.c, u.index, _this.execFunctionGroupData); |
|
|
|
|
|
|
|
let v = _this.execfunction(calc_funcStr, u.r, u.c); |
|
|
|
|
|
|
|
let value = _this.execFunctionGroupData[u.r][u.c]; |
|
|
|