@leankylin-sheet/core 5.2.31 → 5.2.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,12 @@ export declare function getCellValue(ctx: Context, row: number, column: number,
5
5
  type?: keyof Cell;
6
6
  }): any;
7
7
  export declare function setCellValue(ctx: Context, row: number, column: number, value: any, cellInput: HTMLDivElement | null, options?: CommonOptions): void;
8
+ export declare function setCellValueInBatch(ctx: Context, sheet: any, row: number, column: number, value: any, cellInput: HTMLDivElement | null, formulaCells: Array<{
9
+ r: number;
10
+ c: number;
11
+ f: string;
12
+ ct?: any;
13
+ }>): void;
8
14
  export declare function clearCell(ctx: Context, row: number, column: number, options?: CommonOptions): void;
9
15
  export declare function setCellFormat(ctx: Context, row: number, column: number, attr: keyof Cell, value: any, options?: CommonOptions): void;
10
16
  export declare function autoFillCell(ctx: Context, copyRange: SingleRange, applyRange: SingleRange, direction: "up" | "down" | "left" | "right"): void;
package/dist/index.esm.js CHANGED
@@ -36162,7 +36162,7 @@ function execfunction(ctx, txt, r, c, id, isrefresh, notInsertFunc) {
36162
36162
  f: txt
36163
36163
  };else data[r][c].f = txt;
36164
36164
  }
36165
- execFunctionGroup(ctx, r, c, _.isNil(formulaError) ? result : formulaError, id);
36165
+ execFunctionGroup(ctx, r, c, _.isNil(formulaError) ? result : formulaError, id, false, notInsertFunc);
36166
36166
  if (!hadFormulaField && data && data[r] && data[r][c]) {
36167
36167
  delete data[r][c].f;
36168
36168
  }
@@ -36226,6 +36226,7 @@ function groupValuesRefresh(ctx) {
36226
36226
  }
36227
36227
  function execFunctionGroup(ctx, origin_r, origin_c, value, id, data) {
36228
36228
  var isForce = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
36229
+ var notInsertFunc = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : true;
36229
36230
  if (_.isNil(data)) {
36230
36231
  data = getFlowdata(ctx);
36231
36232
  }
@@ -36510,13 +36511,14 @@ function execFunctionGroup(ctx, origin_r, origin_c, value, id, data) {
36510
36511
  if (_ret === 0) continue;
36511
36512
  }
36512
36513
  formulaRunList.reverse();
36514
+ console.time('formulaRunList');
36513
36515
  for (var _i14 = 0; _i14 < formulaRunList.length; _i14 += 1) {
36514
36516
  var formulaCell = formulaRunList[_i14];
36515
36517
  if (formulaCell.level === Math.max) {
36516
36518
  continue;
36517
36519
  }
36518
36520
  var calc_funcStr = formulaCell.calc_funcStr;
36519
- var v = execfunction(ctx, calc_funcStr, formulaCell.r, formulaCell.c, formulaCell.id);
36521
+ var v = execfunction(ctx, calc_funcStr, formulaCell.r, formulaCell.c, formulaCell.id, false, notInsertFunc);
36520
36522
  ctx.groupValuesRefreshData.push({
36521
36523
  r: formulaCell.r,
36522
36524
  c: formulaCell.c,
@@ -36530,6 +36532,7 @@ function execFunctionGroup(ctx, origin_r, origin_c, value, id, data) {
36530
36532
  f: v[2]
36531
36533
  };
36532
36534
  }
36535
+ console.timeEnd('formulaRunList');
36533
36536
  ctx.formulaCache.execFunctionExist = undefined;
36534
36537
  }
36535
36538
  function findrangeindex(ctx, v, vp) {
@@ -40495,7 +40498,7 @@ function updateCell(ctx, r, c, $input, value, canvas, sheetId) {
40495
40498
  } else {
40496
40499
  var _d$r3;
40497
40500
  delFunctionGroup(ctx, r, c);
40498
- execFunctionGroup(ctx, r, c, value);
40501
+ execFunctionGroup(ctx, r, c, value, undefined, undefined, false, false);
40499
40502
  curv = _.cloneDeep((d === null || d === void 0 ? void 0 : (_d$r3 = d[r]) === null || _d$r3 === void 0 ? void 0 : _d$r3[c]) || {});
40500
40503
  curv.v = value;
40501
40504
  delete curv.f;
@@ -40554,7 +40557,7 @@ function updateCell(ctx, r, c, $input, value, canvas, sheetId) {
40554
40557
  }
40555
40558
  } else {
40556
40559
  delFunctionGroup(ctx, r, c);
40557
- execFunctionGroup(ctx, r, c, value);
40560
+ execFunctionGroup(ctx, r, c, value, undefined, undefined, false, false);
40558
40561
  }
40559
40562
  }
40560
40563
  setCellValue(ctx, r, c, d, value);
@@ -42536,7 +42539,7 @@ function copy(ctx) {
42536
42539
  }
42537
42540
  cpString += "</tr>";
42538
42541
  }
42539
- var result = "<table border=\"1\" style=\"border-collapse:collapse\" data-type=\"leankylin-copy-action-table\">".concat(cpString, "</table>");
42542
+ var result = "<table border=\"1\" style=\"border-collapse:collapse; font-size: 13px\" data-type=\"leankylin-copy-action-table\">".concat(cpString, "</table>");
42540
42543
  clipboard.writeHtml(result);
42541
42544
  }
42542
42545
  function copy2(ctx) {
@@ -47619,6 +47622,7 @@ function runExecFunction(ctx, range, index, data) {
47619
47622
  ctx.formulaCache.execFunctionExist.reverse();
47620
47623
  execFunctionGroup(ctx, null, null, null, null, data);
47621
47624
  ctx.formulaCache.execFunctionGlobalData = null;
47625
+ updateFunctionGroup(ctx);
47622
47626
  }
47623
47627
  function jfrefreshgrid(ctx, data, range) {
47624
47628
  var isRunExecFunction = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
@@ -48894,8 +48898,9 @@ function autoSelectionFormula(ctx, cellInput, fxInput, formula, cache) {
48894
48898
  });
48895
48899
  if (!isfalse) {
48896
48900
  ctx.formulaCache.execFunctionExist.reverse();
48897
- execFunctionGroup(ctx, null, null, null, null, flowdata);
48901
+ execFunctionGroup(ctx, null, null, null, null, flowdata, false, false);
48898
48902
  ctx.formulaCache.execFunctionGlobalData = null;
48903
+ updateFunctionGroup(ctx);
48899
48904
  }
48900
48905
  }
48901
48906
  function cancelPaintModel(ctx) {
@@ -51877,7 +51882,8 @@ function updateDropCell(ctx) {
51877
51882
  cell.m = cell.v.toString();
51878
51883
  } else {
51879
51884
  if (cell.v.toString().indexOf("e") > -1) {
51880
- var len = cell.v.toString().split(".")[1].split("e")[0].length;
51885
+ var _cell$v, _cell$v$toString$spli, _cell$v$toString$spli2, _cell$v$toString$spli3, _cell$v$toString$spli4;
51886
+ var len = (_cell$v = cell.v) === null || _cell$v === void 0 ? void 0 : (_cell$v$toString$spli = _cell$v.toString().split(".")) === null || _cell$v$toString$spli === void 0 ? void 0 : (_cell$v$toString$spli2 = _cell$v$toString$spli[1]) === null || _cell$v$toString$spli2 === void 0 ? void 0 : (_cell$v$toString$spli3 = _cell$v$toString$spli2.split("e")) === null || _cell$v$toString$spli3 === void 0 ? void 0 : (_cell$v$toString$spli4 = _cell$v$toString$spli3[0]) === null || _cell$v$toString$spli4 === void 0 ? void 0 : _cell$v$toString$spli4.length;
51881
51887
  if (len > 5) {
51882
51888
  len = 5;
51883
51889
  }
@@ -55925,6 +55931,23 @@ function getSheetWithLatestCelldata(ctx) {
55925
55931
  });
55926
55932
  }
55927
55933
 
55934
+ var FORMAT_LIST = {
55935
+ bg: 1,
55936
+ ff: 1,
55937
+ fc: 1,
55938
+ bl: 1,
55939
+ it: 1,
55940
+ fs: 1,
55941
+ cl: 1,
55942
+ un: 1,
55943
+ vt: 1,
55944
+ ht: 1,
55945
+ mc: 1,
55946
+ tr: 1,
55947
+ tb: 1,
55948
+ rt: 1,
55949
+ qp: 1
55950
+ };
55928
55951
  function getCellValue$1(ctx, row, column) {
55929
55952
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
55930
55953
  if (!_.isNumber(row) || !_.isNumber(column)) {
@@ -55964,23 +55987,7 @@ function setCellValue$1(ctx, row, column, value, cellInput) {
55964
55987
  }
55965
55988
  var sheet = getSheet(ctx, options);
55966
55989
  var data = sheet.data;
55967
- var formatList = {
55968
- bg: 1,
55969
- ff: 1,
55970
- fc: 1,
55971
- bl: 1,
55972
- it: 1,
55973
- fs: 1,
55974
- cl: 1,
55975
- un: 1,
55976
- vt: 1,
55977
- ht: 1,
55978
- mc: 1,
55979
- tr: 1,
55980
- tb: 1,
55981
- rt: 1,
55982
- qp: 1
55983
- };
55990
+ var formatList = FORMAT_LIST;
55984
55991
  if (value == null || value.toString().length === 0) {
55985
55992
  delFunctionGroup(ctx, row, column);
55986
55993
  setCellValue(ctx, row, column, data, value);
@@ -56057,6 +56064,165 @@ function setCellValue$1(ctx, row, column, value, cellInput) {
56057
56064
  }
56058
56065
  }
56059
56066
  }
56067
+ function setCellValueInBatch(ctx, sheet, row, column, value, cellInput, formulaCells) {
56068
+ var data = sheet.data;
56069
+ var sheetId = sheet.id;
56070
+ if (value == null || value.toString().length === 0) {
56071
+ delFunctionGroup(ctx, row, column, sheetId);
56072
+ setCellValue(ctx, row, column, data, value);
56073
+ return;
56074
+ }
56075
+ if (value instanceof Object) {
56076
+ var _data$row2;
56077
+ var curv = {};
56078
+ if (!(data === null || data === void 0 ? void 0 : data[row])) {
56079
+ var needAddRow = row - ((data === null || data === void 0 ? void 0 : data.length) || 0) + 1;
56080
+ data === null || data === void 0 ? void 0 : data.push.apply(data, _toConsumableArray(Array.from({
56081
+ length: needAddRow
56082
+ }).map(function () {
56083
+ return [];
56084
+ })));
56085
+ }
56086
+ if ((data === null || data === void 0 ? void 0 : (_data$row2 = data[row]) === null || _data$row2 === void 0 ? void 0 : _data$row2[column]) == null) {
56087
+ data[row][column] = {};
56088
+ }
56089
+ var cell = data[row][column];
56090
+ if (value.f != null && value.v == null) {
56091
+ curv.f = value.f;
56092
+ if (value.ct != null) {
56093
+ curv.ct = value.ct;
56094
+ }
56095
+ Object.assign(cell, curv);
56096
+ if (_.isString(value.f)) {
56097
+ formulaCells.push({
56098
+ r: row,
56099
+ c: column,
56100
+ f: value.f,
56101
+ ct: value.ct
56102
+ });
56103
+ } else {
56104
+ updateCell(ctx, row, column, cellInput, curv);
56105
+ }
56106
+ } else {
56107
+ var needupdateFdev = false;
56108
+ var needUpdateM = false;
56109
+ var oldF = cell.f;
56110
+ var nf = value.f;
56111
+ var oldV = cell.v;
56112
+ var nv = value.v;
56113
+ if (value.ct != null) {
56114
+ curv.ct = value.ct;
56115
+ }
56116
+ if (value.f != null) {
56117
+ curv.f = value.f;
56118
+ }
56119
+ if (value.v != null) {
56120
+ curv.v = value.v;
56121
+ } else {
56122
+ curv.v = cell.v;
56123
+ }
56124
+ if (value.m != null) {
56125
+ curv.m = value.m;
56126
+ }
56127
+ if (nf !== undefined && nf !== oldF) {
56128
+ needupdateFdev = true;
56129
+ needUpdateM = true;
56130
+ }
56131
+ if (nv !== undefined && String(nv) !== String(oldV)) {
56132
+ needUpdateM = true;
56133
+ }
56134
+ if (needupdateFdev) {
56135
+ delFunctionGroup(ctx, row, column, sheetId);
56136
+ }
56137
+ if (needUpdateM) {
56138
+ setCellValue(ctx, row, column, data, curv);
56139
+ }
56140
+ }
56141
+ _.forEach(value, function (v, attr) {
56142
+ if (attr in FORMAT_LIST) {
56143
+ var foucsStatus = v;
56144
+ if (attr === "ht") {
56145
+ if (foucsStatus === "left") {
56146
+ foucsStatus = "1";
56147
+ } else if (foucsStatus === "center") {
56148
+ foucsStatus = "0";
56149
+ } else if (foucsStatus === "right") {
56150
+ foucsStatus = "2";
56151
+ }
56152
+ } else if (attr === "vt") {
56153
+ if (foucsStatus === "top") {
56154
+ foucsStatus = "1";
56155
+ } else if (foucsStatus === "middle") {
56156
+ foucsStatus = "0";
56157
+ } else if (foucsStatus === "bottom") {
56158
+ foucsStatus = "2";
56159
+ }
56160
+ } else if (attr === "tb") {
56161
+ if (foucsStatus === "overflow") {
56162
+ foucsStatus = "1";
56163
+ } else if (foucsStatus === "clip") {
56164
+ foucsStatus = "0";
56165
+ } else if (foucsStatus === "wrap") {
56166
+ foucsStatus = "2";
56167
+ }
56168
+ } else if (attr === "tr") {
56169
+ if (foucsStatus === "none") {
56170
+ foucsStatus = "0";
56171
+ } else if (foucsStatus === "angleup") {
56172
+ foucsStatus = "1";
56173
+ } else if (foucsStatus === "angledown") {
56174
+ foucsStatus = "2";
56175
+ } else if (foucsStatus === "vertical") {
56176
+ foucsStatus = "3";
56177
+ } else if (foucsStatus === "rotation-up") {
56178
+ foucsStatus = "4";
56179
+ } else if (foucsStatus === "rotation-down") {
56180
+ foucsStatus = "5";
56181
+ }
56182
+ }
56183
+ if (cell && _.isPlainObject(cell)) {
56184
+ if (cell.ct != null && Array.isArray(cell.ct.s) && _.isPlainObject(cell.ct.s[0])) {
56185
+ cell.ct.s.forEach(function (item) {
56186
+ item[attr] = foucsStatus;
56187
+ });
56188
+ }
56189
+ cell[attr] = foucsStatus;
56190
+ }
56191
+ } else {
56192
+ cell[attr] = v;
56193
+ }
56194
+ });
56195
+ data[row][column] = cell;
56196
+ } else {
56197
+ var text = value.toString();
56198
+ if (text.substr(0, 1) === "=" && text.length > 1) {
56199
+ var _data$row3;
56200
+ if (!(data === null || data === void 0 ? void 0 : data[row])) {
56201
+ var _needAddRow = row - ((data === null || data === void 0 ? void 0 : data.length) || 0) + 1;
56202
+ data === null || data === void 0 ? void 0 : data.push.apply(data, _toConsumableArray(Array.from({
56203
+ length: _needAddRow
56204
+ }).map(function () {
56205
+ return [];
56206
+ })));
56207
+ }
56208
+ if ((data === null || data === void 0 ? void 0 : (_data$row3 = data[row]) === null || _data$row3 === void 0 ? void 0 : _data$row3[column]) == null) {
56209
+ data[row][column] = {};
56210
+ }
56211
+ var _cell = data[row][column];
56212
+ _cell.f = text;
56213
+ formulaCells.push({
56214
+ r: row,
56215
+ c: column,
56216
+ f: text
56217
+ });
56218
+ } else if (text.substr(0, 5) === "<span") {
56219
+ updateCell(ctx, row, column, cellInput, value);
56220
+ } else {
56221
+ delFunctionGroup(ctx, row, column, sheetId);
56222
+ setCellValue(ctx, row, column, data, value);
56223
+ }
56224
+ }
56225
+ }
56060
56226
  function clearCell(ctx, row, column) {
56061
56227
  var _sheet$data, _sheet$data$row;
56062
56228
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
@@ -56377,7 +56543,7 @@ function setSelection(ctx, range, options) {
56377
56543
  function setCellValuesByRange(ctx, data, range, cellInput) {
56378
56544
  var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
56379
56545
  var setMerge = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
56380
- if (data == null) {
56546
+ if (data == null || !Array.isArray(data)) {
56381
56547
  throw INVALID_PARAMS;
56382
56548
  }
56383
56549
  if (range instanceof Array) {
@@ -56386,27 +56552,45 @@ function setCellValuesByRange(ctx, data, range, cellInput) {
56386
56552
  if (!_.isPlainObject(range)) {
56387
56553
  throw INVALID_PARAMS;
56388
56554
  }
56389
- var rowCount = range.row[1] - range.row[0] + 1;
56390
- var columnCount = range.column[1] - range.column[0] + 1;
56391
- if (data.length !== rowCount || data[0].length !== columnCount) {
56555
+ var rangeRow = range.row;
56556
+ var rangeColumn = range.column;
56557
+ if (!Array.isArray(rangeRow) || !Array.isArray(rangeColumn) || rangeRow.length < 2 || rangeColumn.length < 2 || !_.isNumber(rangeRow[0]) || !_.isNumber(rangeRow[1]) || !_.isNumber(rangeColumn[0]) || !_.isNumber(rangeColumn[1])) {
56558
+ throw INVALID_PARAMS;
56559
+ }
56560
+ var rowStart = rangeRow[0];
56561
+ var rowEnd = rangeRow[1];
56562
+ var colStart = rangeColumn[0];
56563
+ var colEnd = rangeColumn[1];
56564
+ if (rowStart < 0 || colStart < 0 || rowEnd < rowStart || colEnd < colStart) {
56565
+ throw INVALID_PARAMS;
56566
+ }
56567
+ var rowCount = rowEnd - rowStart + 1;
56568
+ var columnCount = colEnd - colStart + 1;
56569
+ if (!Array.isArray(data[0]) || data.length !== rowCount || data[0].length !== columnCount) {
56392
56570
  throw new Error("data size does not match range");
56393
56571
  }
56394
56572
  var sheet = getSheet(ctx, options);
56573
+ var flowdata = sheet.data;
56574
+ if (!Array.isArray(flowdata)) {
56575
+ throw SHEET_NOT_FOUND;
56576
+ }
56395
56577
  var cfg = sheet.config || {};
56396
56578
  if (cfg.merge == null) {
56397
56579
  cfg.merge = {};
56398
56580
  }
56581
+ var formulaCells = [];
56399
56582
  for (var i = 0; i < rowCount; i += 1) {
56400
56583
  for (var j = 0; j < columnCount; j += 1) {
56401
- var row = range.row[0] + i;
56402
- var column = range.column[0] + j;
56403
- setCellValue$1(ctx, row, column, data[i][j], cellInput, options);
56584
+ var row = rowStart + i;
56585
+ var column = colStart + j;
56586
+ var value = data[i][j];
56587
+ setCellValueInBatch(ctx, sheet, row, column, value, cellInput, formulaCells);
56404
56588
  if (setMerge) {
56405
- var _data$i$j, _data$i$j$mc, _data$i$j2, _data$i$j2$mc, _data$i$j3, _data$i$j3$mc, _data$i$j4, _data$i$j4$mc;
56406
- var r1 = (_data$i$j = data[i][j]) === null || _data$i$j === void 0 ? void 0 : (_data$i$j$mc = _data$i$j.mc) === null || _data$i$j$mc === void 0 ? void 0 : _data$i$j$mc.r;
56407
- var c1 = (_data$i$j2 = data[i][j]) === null || _data$i$j2 === void 0 ? void 0 : (_data$i$j2$mc = _data$i$j2.mc) === null || _data$i$j2$mc === void 0 ? void 0 : _data$i$j2$mc.c;
56408
- var rs = (_data$i$j3 = data[i][j]) === null || _data$i$j3 === void 0 ? void 0 : (_data$i$j3$mc = _data$i$j3.mc) === null || _data$i$j3$mc === void 0 ? void 0 : _data$i$j3$mc.rs;
56409
- var cs = (_data$i$j4 = data[i][j]) === null || _data$i$j4 === void 0 ? void 0 : (_data$i$j4$mc = _data$i$j4.mc) === null || _data$i$j4$mc === void 0 ? void 0 : _data$i$j4$mc.cs;
56589
+ var _value$mc, _value$mc2, _value$mc3, _value$mc4;
56590
+ var r1 = value === null || value === void 0 ? void 0 : (_value$mc = value.mc) === null || _value$mc === void 0 ? void 0 : _value$mc.r;
56591
+ var c1 = value === null || value === void 0 ? void 0 : (_value$mc2 = value.mc) === null || _value$mc2 === void 0 ? void 0 : _value$mc2.c;
56592
+ var rs = value === null || value === void 0 ? void 0 : (_value$mc3 = value.mc) === null || _value$mc3 === void 0 ? void 0 : _value$mc3.rs;
56593
+ var cs = value === null || value === void 0 ? void 0 : (_value$mc4 = value.mc) === null || _value$mc4 === void 0 ? void 0 : _value$mc4.cs;
56410
56594
  if (rs > 1 || cs > 1) {
56411
56595
  cfg.merge["".concat(r1, "_").concat(c1)] = {
56412
56596
  r: r1,
@@ -56421,18 +56605,84 @@ function setCellValuesByRange(ctx, data, range, cellInput) {
56421
56605
  if (setMerge) {
56422
56606
  sheet.config = cfg;
56423
56607
  }
56608
+ if (formulaCells.length > 0) {
56609
+ ctx.formulaCache.execFunctionExist = [];
56610
+ for (var k = 0; k < formulaCells.length; k += 1) {
56611
+ var fc = formulaCells[k];
56612
+ var v = execfunction(ctx, fc.f, fc.r, fc.c, sheet.id, false, true);
56613
+ setCellValue(ctx, fc.r, fc.c, flowdata, {
56614
+ v: v[1],
56615
+ f: v[2]
56616
+ });
56617
+ ctx.formulaCache.execFunctionExist.push({
56618
+ r: fc.r,
56619
+ c: fc.c,
56620
+ i: sheet.id
56621
+ });
56622
+ }
56623
+ ctx.formulaCache.execFunctionExist.reverse();
56624
+ execFunctionGroup(ctx, null, null, null, null, flowdata, false, true);
56625
+ groupValuesRefresh(ctx);
56626
+ updateFunctionGroup(ctx);
56627
+ }
56424
56628
  }
56425
56629
  function setCellValues(ctx, data, cellInput) {
56630
+ var _data$, _data$2;
56426
56631
  if (data == null) {
56427
56632
  throw INVALID_PARAMS;
56428
56633
  }
56429
- for (var j = 0; j < data.length; j += 1) {
56430
- var _data$j = data[j],
56431
- r = _data$j.r,
56432
- c = _data$j.c,
56433
- v = _data$j.v,
56434
- ops = _data$j.ops;
56435
- setCellValue$1(ctx, r, c, v, cellInput, ops);
56634
+ var pickSheet = function pickSheet(ops) {
56635
+ var _ops$index, _ops$id;
56636
+ return [(_ops$index = ops === null || ops === void 0 ? void 0 : ops.index) !== null && _ops$index !== void 0 ? _ops$index : null, (_ops$id = ops === null || ops === void 0 ? void 0 : ops.id) !== null && _ops$id !== void 0 ? _ops$id : null];
56637
+ };
56638
+ var first = pickSheet((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.ops);
56639
+ var canBatch = data.every(function (item) {
56640
+ var _pickSheet = pickSheet(item === null || item === void 0 ? void 0 : item.ops),
56641
+ _pickSheet2 = _slicedToArray(_pickSheet, 2),
56642
+ index = _pickSheet2[0],
56643
+ id = _pickSheet2[1];
56644
+ return index === first[0] && id === first[1];
56645
+ });
56646
+ if (!canBatch) {
56647
+ for (var j = 0; j < data.length; j += 1) {
56648
+ var _data$j = data[j],
56649
+ r = _data$j.r,
56650
+ c = _data$j.c,
56651
+ v = _data$j.v,
56652
+ ops = _data$j.ops;
56653
+ setCellValue$1(ctx, r, c, v, cellInput, ops);
56654
+ }
56655
+ return;
56656
+ }
56657
+ var sheet = getSheet(ctx, ((_data$2 = data[0]) === null || _data$2 === void 0 ? void 0 : _data$2.ops) || {});
56658
+ var flowdata = sheet.data;
56659
+ if (!Array.isArray(flowdata)) {
56660
+ throw SHEET_NOT_FOUND;
56661
+ }
56662
+ var formulaCells = [];
56663
+ for (var _j = 0; _j < data.length; _j += 1) {
56664
+ var _data$_j = data[_j],
56665
+ _r = _data$_j.r,
56666
+ _c = _data$_j.c,
56667
+ _v = _data$_j.v;
56668
+ setCellValueInBatch(ctx, sheet, _r, _c, _v, cellInput, formulaCells);
56669
+ }
56670
+ if (formulaCells.length > 0) {
56671
+ ctx.formulaCache.execFunctionExist = [];
56672
+ for (var k = 0; k < formulaCells.length; k += 1) {
56673
+ var fc = formulaCells[k];
56674
+ var val = execfunction(ctx, fc.f, fc.r, fc.c, sheet.id, false, false);
56675
+ setCellValue(ctx, fc.r, fc.c, flowdata, {
56676
+ v: val[1],
56677
+ f: val[2]
56678
+ });
56679
+ ctx.formulaCache.execFunctionExist.push({
56680
+ r: fc.r,
56681
+ c: fc.c,
56682
+ i: sheet.id
56683
+ });
56684
+ }
56685
+ ctx.formulaCache.execFunctionExist.reverse();
56436
56686
  }
56437
56687
  }
56438
56688
  function setCellFormatByRange(ctx, attr, value, range) {
@@ -56539,6 +56789,7 @@ var index = /*#__PURE__*/Object.freeze({
56539
56789
  celldataToData: celldataToData,
56540
56790
  getCellValue: getCellValue$1,
56541
56791
  setCellValue: setCellValue$1,
56792
+ setCellValueInBatch: setCellValueInBatch,
56542
56793
  clearCell: clearCell,
56543
56794
  setCellFormat: setCellFormat,
56544
56795
  autoFillCell: autoFillCell,
@@ -58943,6 +59194,7 @@ function postPasteCut(ctx, source, target, RowlChange) {
58943
59194
  ctx.luckysheetfile[getSheetIndex(ctx, target.sheetId)].dataVerification = target.curDataVerification;
58944
59195
  ctx.formulaCache.execFunctionExist.reverse();
58945
59196
  execFunctionGroup(ctx, null, null, null, null, target.curData);
59197
+ updateFunctionGroup(ctx);
58946
59198
  ctx.formulaCache.execFunctionGlobalData = null;
58947
59199
  storeSheetParamALL(ctx);
58948
59200
  }
@@ -60437,6 +60689,7 @@ function _handlePasteByLeanklin() {
60437
60689
  }
60438
60690
  return _context2.abrupt("return");
60439
60691
  case 6:
60692
+ console.time('handlePasteByLeanklin');
60440
60693
  rows = selectRange.row;
60441
60694
  columns = selectRange.column;
60442
60695
  _getClipboardData = getClipboardData(ctx, e, copyRich, rows[0], columns[0]), copyData = _getClipboardData.data, borderInfo = _getClipboardData.borderInfo, merge = _getClipboardData.merge;
@@ -60473,14 +60726,17 @@ function _handlePasteByLeanklin() {
60473
60726
  column: column
60474
60727
  };
60475
60728
  if (isAllowEdit(ctx, [range])) {
60476
- _context2.next = 24;
60729
+ _context2.next = 25;
60477
60730
  break;
60478
60731
  }
60479
60732
  return _context2.abrupt("return");
60480
- case 24:
60733
+ case 25:
60734
+ console.time('setCellValuesByRange');
60481
60735
  setCellValuesByRange(ctx, pasteData, range, null);
60736
+ console.timeEnd('setCellValuesByRange');
60482
60737
  ctx.luckysheet_select_save = [range];
60483
- case 26:
60738
+ console.timeEnd('handlePasteByLeanklin');
60739
+ case 30:
60484
60740
  case "end":
60485
60741
  return _context2.stop();
60486
60742
  }
package/dist/index.js CHANGED
@@ -36172,7 +36172,7 @@ function execfunction(ctx, txt, r, c, id, isrefresh, notInsertFunc) {
36172
36172
  f: txt
36173
36173
  };else data[r][c].f = txt;
36174
36174
  }
36175
- execFunctionGroup(ctx, r, c, ___default['default'].isNil(formulaError) ? result : formulaError, id);
36175
+ execFunctionGroup(ctx, r, c, ___default['default'].isNil(formulaError) ? result : formulaError, id, false, notInsertFunc);
36176
36176
  if (!hadFormulaField && data && data[r] && data[r][c]) {
36177
36177
  delete data[r][c].f;
36178
36178
  }
@@ -36236,6 +36236,7 @@ function groupValuesRefresh(ctx) {
36236
36236
  }
36237
36237
  function execFunctionGroup(ctx, origin_r, origin_c, value, id, data) {
36238
36238
  var isForce = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
36239
+ var notInsertFunc = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : true;
36239
36240
  if (___default['default'].isNil(data)) {
36240
36241
  data = getFlowdata(ctx);
36241
36242
  }
@@ -36520,13 +36521,14 @@ function execFunctionGroup(ctx, origin_r, origin_c, value, id, data) {
36520
36521
  if (_ret === 0) continue;
36521
36522
  }
36522
36523
  formulaRunList.reverse();
36524
+ console.time('formulaRunList');
36523
36525
  for (var _i14 = 0; _i14 < formulaRunList.length; _i14 += 1) {
36524
36526
  var formulaCell = formulaRunList[_i14];
36525
36527
  if (formulaCell.level === Math.max) {
36526
36528
  continue;
36527
36529
  }
36528
36530
  var calc_funcStr = formulaCell.calc_funcStr;
36529
- var v = execfunction(ctx, calc_funcStr, formulaCell.r, formulaCell.c, formulaCell.id);
36531
+ var v = execfunction(ctx, calc_funcStr, formulaCell.r, formulaCell.c, formulaCell.id, false, notInsertFunc);
36530
36532
  ctx.groupValuesRefreshData.push({
36531
36533
  r: formulaCell.r,
36532
36534
  c: formulaCell.c,
@@ -36540,6 +36542,7 @@ function execFunctionGroup(ctx, origin_r, origin_c, value, id, data) {
36540
36542
  f: v[2]
36541
36543
  };
36542
36544
  }
36545
+ console.timeEnd('formulaRunList');
36543
36546
  ctx.formulaCache.execFunctionExist = undefined;
36544
36547
  }
36545
36548
  function findrangeindex(ctx, v, vp) {
@@ -40505,7 +40508,7 @@ function updateCell(ctx, r, c, $input, value, canvas, sheetId) {
40505
40508
  } else {
40506
40509
  var _d$r3;
40507
40510
  delFunctionGroup(ctx, r, c);
40508
- execFunctionGroup(ctx, r, c, value);
40511
+ execFunctionGroup(ctx, r, c, value, undefined, undefined, false, false);
40509
40512
  curv = ___default['default'].cloneDeep((d === null || d === void 0 ? void 0 : (_d$r3 = d[r]) === null || _d$r3 === void 0 ? void 0 : _d$r3[c]) || {});
40510
40513
  curv.v = value;
40511
40514
  delete curv.f;
@@ -40564,7 +40567,7 @@ function updateCell(ctx, r, c, $input, value, canvas, sheetId) {
40564
40567
  }
40565
40568
  } else {
40566
40569
  delFunctionGroup(ctx, r, c);
40567
- execFunctionGroup(ctx, r, c, value);
40570
+ execFunctionGroup(ctx, r, c, value, undefined, undefined, false, false);
40568
40571
  }
40569
40572
  }
40570
40573
  setCellValue(ctx, r, c, d, value);
@@ -42546,7 +42549,7 @@ function copy(ctx) {
42546
42549
  }
42547
42550
  cpString += "</tr>";
42548
42551
  }
42549
- var result = "<table border=\"1\" style=\"border-collapse:collapse\" data-type=\"leankylin-copy-action-table\">".concat(cpString, "</table>");
42552
+ var result = "<table border=\"1\" style=\"border-collapse:collapse; font-size: 13px\" data-type=\"leankylin-copy-action-table\">".concat(cpString, "</table>");
42550
42553
  clipboard.writeHtml(result);
42551
42554
  }
42552
42555
  function copy2(ctx) {
@@ -47629,6 +47632,7 @@ function runExecFunction(ctx, range, index, data) {
47629
47632
  ctx.formulaCache.execFunctionExist.reverse();
47630
47633
  execFunctionGroup(ctx, null, null, null, null, data);
47631
47634
  ctx.formulaCache.execFunctionGlobalData = null;
47635
+ updateFunctionGroup(ctx);
47632
47636
  }
47633
47637
  function jfrefreshgrid(ctx, data, range) {
47634
47638
  var isRunExecFunction = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
@@ -48904,8 +48908,9 @@ function autoSelectionFormula(ctx, cellInput, fxInput, formula, cache) {
48904
48908
  });
48905
48909
  if (!isfalse) {
48906
48910
  ctx.formulaCache.execFunctionExist.reverse();
48907
- execFunctionGroup(ctx, null, null, null, null, flowdata);
48911
+ execFunctionGroup(ctx, null, null, null, null, flowdata, false, false);
48908
48912
  ctx.formulaCache.execFunctionGlobalData = null;
48913
+ updateFunctionGroup(ctx);
48909
48914
  }
48910
48915
  }
48911
48916
  function cancelPaintModel(ctx) {
@@ -51887,7 +51892,8 @@ function updateDropCell(ctx) {
51887
51892
  cell.m = cell.v.toString();
51888
51893
  } else {
51889
51894
  if (cell.v.toString().indexOf("e") > -1) {
51890
- var len = cell.v.toString().split(".")[1].split("e")[0].length;
51895
+ var _cell$v, _cell$v$toString$spli, _cell$v$toString$spli2, _cell$v$toString$spli3, _cell$v$toString$spli4;
51896
+ var len = (_cell$v = cell.v) === null || _cell$v === void 0 ? void 0 : (_cell$v$toString$spli = _cell$v.toString().split(".")) === null || _cell$v$toString$spli === void 0 ? void 0 : (_cell$v$toString$spli2 = _cell$v$toString$spli[1]) === null || _cell$v$toString$spli2 === void 0 ? void 0 : (_cell$v$toString$spli3 = _cell$v$toString$spli2.split("e")) === null || _cell$v$toString$spli3 === void 0 ? void 0 : (_cell$v$toString$spli4 = _cell$v$toString$spli3[0]) === null || _cell$v$toString$spli4 === void 0 ? void 0 : _cell$v$toString$spli4.length;
51891
51897
  if (len > 5) {
51892
51898
  len = 5;
51893
51899
  }
@@ -55935,6 +55941,23 @@ function getSheetWithLatestCelldata(ctx) {
55935
55941
  });
55936
55942
  }
55937
55943
 
55944
+ var FORMAT_LIST = {
55945
+ bg: 1,
55946
+ ff: 1,
55947
+ fc: 1,
55948
+ bl: 1,
55949
+ it: 1,
55950
+ fs: 1,
55951
+ cl: 1,
55952
+ un: 1,
55953
+ vt: 1,
55954
+ ht: 1,
55955
+ mc: 1,
55956
+ tr: 1,
55957
+ tb: 1,
55958
+ rt: 1,
55959
+ qp: 1
55960
+ };
55938
55961
  function getCellValue$1(ctx, row, column) {
55939
55962
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
55940
55963
  if (!___default['default'].isNumber(row) || !___default['default'].isNumber(column)) {
@@ -55974,23 +55997,7 @@ function setCellValue$1(ctx, row, column, value, cellInput) {
55974
55997
  }
55975
55998
  var sheet = getSheet(ctx, options);
55976
55999
  var data = sheet.data;
55977
- var formatList = {
55978
- bg: 1,
55979
- ff: 1,
55980
- fc: 1,
55981
- bl: 1,
55982
- it: 1,
55983
- fs: 1,
55984
- cl: 1,
55985
- un: 1,
55986
- vt: 1,
55987
- ht: 1,
55988
- mc: 1,
55989
- tr: 1,
55990
- tb: 1,
55991
- rt: 1,
55992
- qp: 1
55993
- };
56000
+ var formatList = FORMAT_LIST;
55994
56001
  if (value == null || value.toString().length === 0) {
55995
56002
  delFunctionGroup(ctx, row, column);
55996
56003
  setCellValue(ctx, row, column, data, value);
@@ -56067,6 +56074,165 @@ function setCellValue$1(ctx, row, column, value, cellInput) {
56067
56074
  }
56068
56075
  }
56069
56076
  }
56077
+ function setCellValueInBatch(ctx, sheet, row, column, value, cellInput, formulaCells) {
56078
+ var data = sheet.data;
56079
+ var sheetId = sheet.id;
56080
+ if (value == null || value.toString().length === 0) {
56081
+ delFunctionGroup(ctx, row, column, sheetId);
56082
+ setCellValue(ctx, row, column, data, value);
56083
+ return;
56084
+ }
56085
+ if (value instanceof Object) {
56086
+ var _data$row2;
56087
+ var curv = {};
56088
+ if (!(data === null || data === void 0 ? void 0 : data[row])) {
56089
+ var needAddRow = row - ((data === null || data === void 0 ? void 0 : data.length) || 0) + 1;
56090
+ data === null || data === void 0 ? void 0 : data.push.apply(data, _toConsumableArray(Array.from({
56091
+ length: needAddRow
56092
+ }).map(function () {
56093
+ return [];
56094
+ })));
56095
+ }
56096
+ if ((data === null || data === void 0 ? void 0 : (_data$row2 = data[row]) === null || _data$row2 === void 0 ? void 0 : _data$row2[column]) == null) {
56097
+ data[row][column] = {};
56098
+ }
56099
+ var cell = data[row][column];
56100
+ if (value.f != null && value.v == null) {
56101
+ curv.f = value.f;
56102
+ if (value.ct != null) {
56103
+ curv.ct = value.ct;
56104
+ }
56105
+ Object.assign(cell, curv);
56106
+ if (___default['default'].isString(value.f)) {
56107
+ formulaCells.push({
56108
+ r: row,
56109
+ c: column,
56110
+ f: value.f,
56111
+ ct: value.ct
56112
+ });
56113
+ } else {
56114
+ updateCell(ctx, row, column, cellInput, curv);
56115
+ }
56116
+ } else {
56117
+ var needupdateFdev = false;
56118
+ var needUpdateM = false;
56119
+ var oldF = cell.f;
56120
+ var nf = value.f;
56121
+ var oldV = cell.v;
56122
+ var nv = value.v;
56123
+ if (value.ct != null) {
56124
+ curv.ct = value.ct;
56125
+ }
56126
+ if (value.f != null) {
56127
+ curv.f = value.f;
56128
+ }
56129
+ if (value.v != null) {
56130
+ curv.v = value.v;
56131
+ } else {
56132
+ curv.v = cell.v;
56133
+ }
56134
+ if (value.m != null) {
56135
+ curv.m = value.m;
56136
+ }
56137
+ if (nf !== undefined && nf !== oldF) {
56138
+ needupdateFdev = true;
56139
+ needUpdateM = true;
56140
+ }
56141
+ if (nv !== undefined && String(nv) !== String(oldV)) {
56142
+ needUpdateM = true;
56143
+ }
56144
+ if (needupdateFdev) {
56145
+ delFunctionGroup(ctx, row, column, sheetId);
56146
+ }
56147
+ if (needUpdateM) {
56148
+ setCellValue(ctx, row, column, data, curv);
56149
+ }
56150
+ }
56151
+ ___default['default'].forEach(value, function (v, attr) {
56152
+ if (attr in FORMAT_LIST) {
56153
+ var foucsStatus = v;
56154
+ if (attr === "ht") {
56155
+ if (foucsStatus === "left") {
56156
+ foucsStatus = "1";
56157
+ } else if (foucsStatus === "center") {
56158
+ foucsStatus = "0";
56159
+ } else if (foucsStatus === "right") {
56160
+ foucsStatus = "2";
56161
+ }
56162
+ } else if (attr === "vt") {
56163
+ if (foucsStatus === "top") {
56164
+ foucsStatus = "1";
56165
+ } else if (foucsStatus === "middle") {
56166
+ foucsStatus = "0";
56167
+ } else if (foucsStatus === "bottom") {
56168
+ foucsStatus = "2";
56169
+ }
56170
+ } else if (attr === "tb") {
56171
+ if (foucsStatus === "overflow") {
56172
+ foucsStatus = "1";
56173
+ } else if (foucsStatus === "clip") {
56174
+ foucsStatus = "0";
56175
+ } else if (foucsStatus === "wrap") {
56176
+ foucsStatus = "2";
56177
+ }
56178
+ } else if (attr === "tr") {
56179
+ if (foucsStatus === "none") {
56180
+ foucsStatus = "0";
56181
+ } else if (foucsStatus === "angleup") {
56182
+ foucsStatus = "1";
56183
+ } else if (foucsStatus === "angledown") {
56184
+ foucsStatus = "2";
56185
+ } else if (foucsStatus === "vertical") {
56186
+ foucsStatus = "3";
56187
+ } else if (foucsStatus === "rotation-up") {
56188
+ foucsStatus = "4";
56189
+ } else if (foucsStatus === "rotation-down") {
56190
+ foucsStatus = "5";
56191
+ }
56192
+ }
56193
+ if (cell && ___default['default'].isPlainObject(cell)) {
56194
+ if (cell.ct != null && Array.isArray(cell.ct.s) && ___default['default'].isPlainObject(cell.ct.s[0])) {
56195
+ cell.ct.s.forEach(function (item) {
56196
+ item[attr] = foucsStatus;
56197
+ });
56198
+ }
56199
+ cell[attr] = foucsStatus;
56200
+ }
56201
+ } else {
56202
+ cell[attr] = v;
56203
+ }
56204
+ });
56205
+ data[row][column] = cell;
56206
+ } else {
56207
+ var text = value.toString();
56208
+ if (text.substr(0, 1) === "=" && text.length > 1) {
56209
+ var _data$row3;
56210
+ if (!(data === null || data === void 0 ? void 0 : data[row])) {
56211
+ var _needAddRow = row - ((data === null || data === void 0 ? void 0 : data.length) || 0) + 1;
56212
+ data === null || data === void 0 ? void 0 : data.push.apply(data, _toConsumableArray(Array.from({
56213
+ length: _needAddRow
56214
+ }).map(function () {
56215
+ return [];
56216
+ })));
56217
+ }
56218
+ if ((data === null || data === void 0 ? void 0 : (_data$row3 = data[row]) === null || _data$row3 === void 0 ? void 0 : _data$row3[column]) == null) {
56219
+ data[row][column] = {};
56220
+ }
56221
+ var _cell = data[row][column];
56222
+ _cell.f = text;
56223
+ formulaCells.push({
56224
+ r: row,
56225
+ c: column,
56226
+ f: text
56227
+ });
56228
+ } else if (text.substr(0, 5) === "<span") {
56229
+ updateCell(ctx, row, column, cellInput, value);
56230
+ } else {
56231
+ delFunctionGroup(ctx, row, column, sheetId);
56232
+ setCellValue(ctx, row, column, data, value);
56233
+ }
56234
+ }
56235
+ }
56070
56236
  function clearCell(ctx, row, column) {
56071
56237
  var _sheet$data, _sheet$data$row;
56072
56238
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
@@ -56387,7 +56553,7 @@ function setSelection(ctx, range, options) {
56387
56553
  function setCellValuesByRange(ctx, data, range, cellInput) {
56388
56554
  var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
56389
56555
  var setMerge = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
56390
- if (data == null) {
56556
+ if (data == null || !Array.isArray(data)) {
56391
56557
  throw INVALID_PARAMS;
56392
56558
  }
56393
56559
  if (range instanceof Array) {
@@ -56396,27 +56562,45 @@ function setCellValuesByRange(ctx, data, range, cellInput) {
56396
56562
  if (!___default['default'].isPlainObject(range)) {
56397
56563
  throw INVALID_PARAMS;
56398
56564
  }
56399
- var rowCount = range.row[1] - range.row[0] + 1;
56400
- var columnCount = range.column[1] - range.column[0] + 1;
56401
- if (data.length !== rowCount || data[0].length !== columnCount) {
56565
+ var rangeRow = range.row;
56566
+ var rangeColumn = range.column;
56567
+ if (!Array.isArray(rangeRow) || !Array.isArray(rangeColumn) || rangeRow.length < 2 || rangeColumn.length < 2 || !___default['default'].isNumber(rangeRow[0]) || !___default['default'].isNumber(rangeRow[1]) || !___default['default'].isNumber(rangeColumn[0]) || !___default['default'].isNumber(rangeColumn[1])) {
56568
+ throw INVALID_PARAMS;
56569
+ }
56570
+ var rowStart = rangeRow[0];
56571
+ var rowEnd = rangeRow[1];
56572
+ var colStart = rangeColumn[0];
56573
+ var colEnd = rangeColumn[1];
56574
+ if (rowStart < 0 || colStart < 0 || rowEnd < rowStart || colEnd < colStart) {
56575
+ throw INVALID_PARAMS;
56576
+ }
56577
+ var rowCount = rowEnd - rowStart + 1;
56578
+ var columnCount = colEnd - colStart + 1;
56579
+ if (!Array.isArray(data[0]) || data.length !== rowCount || data[0].length !== columnCount) {
56402
56580
  throw new Error("data size does not match range");
56403
56581
  }
56404
56582
  var sheet = getSheet(ctx, options);
56583
+ var flowdata = sheet.data;
56584
+ if (!Array.isArray(flowdata)) {
56585
+ throw SHEET_NOT_FOUND;
56586
+ }
56405
56587
  var cfg = sheet.config || {};
56406
56588
  if (cfg.merge == null) {
56407
56589
  cfg.merge = {};
56408
56590
  }
56591
+ var formulaCells = [];
56409
56592
  for (var i = 0; i < rowCount; i += 1) {
56410
56593
  for (var j = 0; j < columnCount; j += 1) {
56411
- var row = range.row[0] + i;
56412
- var column = range.column[0] + j;
56413
- setCellValue$1(ctx, row, column, data[i][j], cellInput, options);
56594
+ var row = rowStart + i;
56595
+ var column = colStart + j;
56596
+ var value = data[i][j];
56597
+ setCellValueInBatch(ctx, sheet, row, column, value, cellInput, formulaCells);
56414
56598
  if (setMerge) {
56415
- var _data$i$j, _data$i$j$mc, _data$i$j2, _data$i$j2$mc, _data$i$j3, _data$i$j3$mc, _data$i$j4, _data$i$j4$mc;
56416
- var r1 = (_data$i$j = data[i][j]) === null || _data$i$j === void 0 ? void 0 : (_data$i$j$mc = _data$i$j.mc) === null || _data$i$j$mc === void 0 ? void 0 : _data$i$j$mc.r;
56417
- var c1 = (_data$i$j2 = data[i][j]) === null || _data$i$j2 === void 0 ? void 0 : (_data$i$j2$mc = _data$i$j2.mc) === null || _data$i$j2$mc === void 0 ? void 0 : _data$i$j2$mc.c;
56418
- var rs = (_data$i$j3 = data[i][j]) === null || _data$i$j3 === void 0 ? void 0 : (_data$i$j3$mc = _data$i$j3.mc) === null || _data$i$j3$mc === void 0 ? void 0 : _data$i$j3$mc.rs;
56419
- var cs = (_data$i$j4 = data[i][j]) === null || _data$i$j4 === void 0 ? void 0 : (_data$i$j4$mc = _data$i$j4.mc) === null || _data$i$j4$mc === void 0 ? void 0 : _data$i$j4$mc.cs;
56599
+ var _value$mc, _value$mc2, _value$mc3, _value$mc4;
56600
+ var r1 = value === null || value === void 0 ? void 0 : (_value$mc = value.mc) === null || _value$mc === void 0 ? void 0 : _value$mc.r;
56601
+ var c1 = value === null || value === void 0 ? void 0 : (_value$mc2 = value.mc) === null || _value$mc2 === void 0 ? void 0 : _value$mc2.c;
56602
+ var rs = value === null || value === void 0 ? void 0 : (_value$mc3 = value.mc) === null || _value$mc3 === void 0 ? void 0 : _value$mc3.rs;
56603
+ var cs = value === null || value === void 0 ? void 0 : (_value$mc4 = value.mc) === null || _value$mc4 === void 0 ? void 0 : _value$mc4.cs;
56420
56604
  if (rs > 1 || cs > 1) {
56421
56605
  cfg.merge["".concat(r1, "_").concat(c1)] = {
56422
56606
  r: r1,
@@ -56431,18 +56615,84 @@ function setCellValuesByRange(ctx, data, range, cellInput) {
56431
56615
  if (setMerge) {
56432
56616
  sheet.config = cfg;
56433
56617
  }
56618
+ if (formulaCells.length > 0) {
56619
+ ctx.formulaCache.execFunctionExist = [];
56620
+ for (var k = 0; k < formulaCells.length; k += 1) {
56621
+ var fc = formulaCells[k];
56622
+ var v = execfunction(ctx, fc.f, fc.r, fc.c, sheet.id, false, true);
56623
+ setCellValue(ctx, fc.r, fc.c, flowdata, {
56624
+ v: v[1],
56625
+ f: v[2]
56626
+ });
56627
+ ctx.formulaCache.execFunctionExist.push({
56628
+ r: fc.r,
56629
+ c: fc.c,
56630
+ i: sheet.id
56631
+ });
56632
+ }
56633
+ ctx.formulaCache.execFunctionExist.reverse();
56634
+ execFunctionGroup(ctx, null, null, null, null, flowdata, false, true);
56635
+ groupValuesRefresh(ctx);
56636
+ updateFunctionGroup(ctx);
56637
+ }
56434
56638
  }
56435
56639
  function setCellValues(ctx, data, cellInput) {
56640
+ var _data$, _data$2;
56436
56641
  if (data == null) {
56437
56642
  throw INVALID_PARAMS;
56438
56643
  }
56439
- for (var j = 0; j < data.length; j += 1) {
56440
- var _data$j = data[j],
56441
- r = _data$j.r,
56442
- c = _data$j.c,
56443
- v = _data$j.v,
56444
- ops = _data$j.ops;
56445
- setCellValue$1(ctx, r, c, v, cellInput, ops);
56644
+ var pickSheet = function pickSheet(ops) {
56645
+ var _ops$index, _ops$id;
56646
+ return [(_ops$index = ops === null || ops === void 0 ? void 0 : ops.index) !== null && _ops$index !== void 0 ? _ops$index : null, (_ops$id = ops === null || ops === void 0 ? void 0 : ops.id) !== null && _ops$id !== void 0 ? _ops$id : null];
56647
+ };
56648
+ var first = pickSheet((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.ops);
56649
+ var canBatch = data.every(function (item) {
56650
+ var _pickSheet = pickSheet(item === null || item === void 0 ? void 0 : item.ops),
56651
+ _pickSheet2 = _slicedToArray(_pickSheet, 2),
56652
+ index = _pickSheet2[0],
56653
+ id = _pickSheet2[1];
56654
+ return index === first[0] && id === first[1];
56655
+ });
56656
+ if (!canBatch) {
56657
+ for (var j = 0; j < data.length; j += 1) {
56658
+ var _data$j = data[j],
56659
+ r = _data$j.r,
56660
+ c = _data$j.c,
56661
+ v = _data$j.v,
56662
+ ops = _data$j.ops;
56663
+ setCellValue$1(ctx, r, c, v, cellInput, ops);
56664
+ }
56665
+ return;
56666
+ }
56667
+ var sheet = getSheet(ctx, ((_data$2 = data[0]) === null || _data$2 === void 0 ? void 0 : _data$2.ops) || {});
56668
+ var flowdata = sheet.data;
56669
+ if (!Array.isArray(flowdata)) {
56670
+ throw SHEET_NOT_FOUND;
56671
+ }
56672
+ var formulaCells = [];
56673
+ for (var _j = 0; _j < data.length; _j += 1) {
56674
+ var _data$_j = data[_j],
56675
+ _r = _data$_j.r,
56676
+ _c = _data$_j.c,
56677
+ _v = _data$_j.v;
56678
+ setCellValueInBatch(ctx, sheet, _r, _c, _v, cellInput, formulaCells);
56679
+ }
56680
+ if (formulaCells.length > 0) {
56681
+ ctx.formulaCache.execFunctionExist = [];
56682
+ for (var k = 0; k < formulaCells.length; k += 1) {
56683
+ var fc = formulaCells[k];
56684
+ var val = execfunction(ctx, fc.f, fc.r, fc.c, sheet.id, false, false);
56685
+ setCellValue(ctx, fc.r, fc.c, flowdata, {
56686
+ v: val[1],
56687
+ f: val[2]
56688
+ });
56689
+ ctx.formulaCache.execFunctionExist.push({
56690
+ r: fc.r,
56691
+ c: fc.c,
56692
+ i: sheet.id
56693
+ });
56694
+ }
56695
+ ctx.formulaCache.execFunctionExist.reverse();
56446
56696
  }
56447
56697
  }
56448
56698
  function setCellFormatByRange(ctx, attr, value, range) {
@@ -56549,6 +56799,7 @@ var index = /*#__PURE__*/Object.freeze({
56549
56799
  celldataToData: celldataToData,
56550
56800
  getCellValue: getCellValue$1,
56551
56801
  setCellValue: setCellValue$1,
56802
+ setCellValueInBatch: setCellValueInBatch,
56552
56803
  clearCell: clearCell,
56553
56804
  setCellFormat: setCellFormat,
56554
56805
  autoFillCell: autoFillCell,
@@ -58953,6 +59204,7 @@ function postPasteCut(ctx, source, target, RowlChange) {
58953
59204
  ctx.luckysheetfile[getSheetIndex(ctx, target.sheetId)].dataVerification = target.curDataVerification;
58954
59205
  ctx.formulaCache.execFunctionExist.reverse();
58955
59206
  execFunctionGroup(ctx, null, null, null, null, target.curData);
59207
+ updateFunctionGroup(ctx);
58956
59208
  ctx.formulaCache.execFunctionGlobalData = null;
58957
59209
  storeSheetParamALL(ctx);
58958
59210
  }
@@ -60447,6 +60699,7 @@ function _handlePasteByLeanklin() {
60447
60699
  }
60448
60700
  return _context2.abrupt("return");
60449
60701
  case 6:
60702
+ console.time('handlePasteByLeanklin');
60450
60703
  rows = selectRange.row;
60451
60704
  columns = selectRange.column;
60452
60705
  _getClipboardData = getClipboardData(ctx, e, copyRich, rows[0], columns[0]), copyData = _getClipboardData.data, borderInfo = _getClipboardData.borderInfo, merge = _getClipboardData.merge;
@@ -60483,14 +60736,17 @@ function _handlePasteByLeanklin() {
60483
60736
  column: column
60484
60737
  };
60485
60738
  if (isAllowEdit(ctx, [range])) {
60486
- _context2.next = 24;
60739
+ _context2.next = 25;
60487
60740
  break;
60488
60741
  }
60489
60742
  return _context2.abrupt("return");
60490
- case 24:
60743
+ case 25:
60744
+ console.time('setCellValuesByRange');
60491
60745
  setCellValuesByRange(ctx, pasteData, range, null);
60746
+ console.timeEnd('setCellValuesByRange');
60492
60747
  ctx.luckysheet_select_save = [range];
60493
- case 26:
60748
+ console.timeEnd('handlePasteByLeanklin');
60749
+ case 30:
60494
60750
  case "end":
60495
60751
  return _context2.stop();
60496
60752
  }
@@ -34,7 +34,7 @@ export declare function delFunctionGroup(ctx: Context, r: number, c: number, id?
34
34
  export declare function insertUpdateFunctionGroup(ctx: Context, r: number, c: number, id?: string): void;
35
35
  export declare function execfunction(ctx: Context, txt: string, r: number, c: number, id?: string, isrefresh?: boolean, notInsertFunc?: boolean): any[];
36
36
  export declare function groupValuesRefresh(ctx: Context): void;
37
- export declare function execFunctionGroup(ctx: Context, origin_r: number, origin_c: number, value: any, id?: string, data?: any, isForce?: boolean): void;
37
+ export declare function execFunctionGroup(ctx: Context, origin_r: number, origin_c: number, value: any, id?: string, data?: any, isForce?: boolean, notInsertFunc?: boolean): void;
38
38
  export declare function createFormulaRangeSelect(ctx: Context, select: {
39
39
  rangeIndex: number;
40
40
  } & Rect): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leankylin-sheet/core",
3
- "version": "5.2.31",
3
+ "version": "5.2.33",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "typings": "dist/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "build": "father-build"
14
14
  },
15
15
  "dependencies": {
16
- "@leankylin-sheet/formula-parser": "5.2.31",
16
+ "@leankylin-sheet/formula-parser": "5.2.33",
17
17
  "dayjs": "^1.11.0",
18
18
  "immer": "^9.0.12",
19
19
  "lodash": "^4.17.21",