@leankylin-sheet/core 4.0.60 → 4.0.62
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.
- package/README.md +19 -19
- package/dist/api/sheet.d.ts +5 -0
- package/dist/index.esm.js +92 -7
- package/dist/index.js +92 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
# @leankylin-sheet/core
|
|
2
|
-
|
|
3
|
-
LeankylinSheet is a drop-in javascript spreadsheet library that provides rich features like Excel and Google Sheets
|
|
4
|
-
|
|
5
|
-
See our repo [leankylin-sheet](http://114.55.85.79:19999/leankylin-front/leankylin-sheet) for more information.
|
|
6
|
-
|
|
7
|
-
## Install
|
|
8
|
-
|
|
9
|
-
Using npm:
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
$ npm install --save @leankylin-sheet/core
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
or using yarn:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
$ yarn add @leankylin-sheet/core
|
|
19
|
-
```
|
|
1
|
+
# @leankylin-sheet/core
|
|
2
|
+
|
|
3
|
+
LeankylinSheet is a drop-in javascript spreadsheet library that provides rich features like Excel and Google Sheets
|
|
4
|
+
|
|
5
|
+
See our repo [leankylin-sheet](http://114.55.85.79:19999/leankylin-front/leankylin-sheet) for more information.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Using npm:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
$ npm install --save @leankylin-sheet/core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
or using yarn:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
$ yarn add @leankylin-sheet/core
|
|
19
|
+
```
|
package/dist/api/sheet.d.ts
CHANGED
|
@@ -9,3 +9,8 @@ export declare function hideSheet(ctx: Context, sheetId: string): void;
|
|
|
9
9
|
export declare function showSheet(ctx: Context, sheetId: string): void;
|
|
10
10
|
export declare function copySheet(ctx: Context, sheetId: string, hooks: Hooks): void;
|
|
11
11
|
export declare function calculateSheetFromula(ctx: Context, id: string): void;
|
|
12
|
+
export declare function calculateSheetByCells(ctx: Context, cells: {
|
|
13
|
+
r: number;
|
|
14
|
+
c: number;
|
|
15
|
+
id: string;
|
|
16
|
+
}[]): void;
|
package/dist/index.esm.js
CHANGED
|
@@ -33798,13 +33798,13 @@ var make_ssf = function make_ssf(SSF) {
|
|
|
33798
33798
|
return general_fmt_num_base;
|
|
33799
33799
|
}();
|
|
33800
33800
|
SSF._general_num = general_fmt_num;
|
|
33801
|
-
/*
|
|
33802
|
-
"General" rules:
|
|
33803
|
-
- text is passed through ("@")
|
|
33804
|
-
- booleans are rendered as TRUE/FALSE
|
|
33805
|
-
- "up to 11 characters" displayed for numbers
|
|
33806
|
-
- Default date format (code 14) used for Dates
|
|
33807
|
-
TODO: technically the display depends on the width of the cell
|
|
33801
|
+
/*
|
|
33802
|
+
"General" rules:
|
|
33803
|
+
- text is passed through ("@")
|
|
33804
|
+
- booleans are rendered as TRUE/FALSE
|
|
33805
|
+
- "up to 11 characters" displayed for numbers
|
|
33806
|
+
- Default date format (code 14) used for Dates
|
|
33807
|
+
TODO: technically the display depends on the width of the cell
|
|
33808
33808
|
*/
|
|
33809
33809
|
function general_fmt(v, opts) {
|
|
33810
33810
|
switch (_typeof(v)) {
|
|
@@ -46576,6 +46576,90 @@ function calculateSheetFromula(ctx, id) {
|
|
|
46576
46576
|
ctx.luckysheetfile = luckysheetfile;
|
|
46577
46577
|
console.timeEnd("calcTime:".concat(id));
|
|
46578
46578
|
}
|
|
46579
|
+
function parseCellReferences(expression) {
|
|
46580
|
+
if (typeof expression !== "string" || expression.trim() === "") {
|
|
46581
|
+
return [];
|
|
46582
|
+
}
|
|
46583
|
+
var cellRegex = /([A-Za-z0-9_]+!)?[A-Za-z]+\d+/g;
|
|
46584
|
+
var matches = expression.match(cellRegex) || [];
|
|
46585
|
+
var uniqueCells = matches.map(function (cell) {
|
|
46586
|
+
return cell.trim().toUpperCase();
|
|
46587
|
+
});
|
|
46588
|
+
return uniqueCells;
|
|
46589
|
+
}
|
|
46590
|
+
function calculateSheetByCells(ctx, cells) {
|
|
46591
|
+
console.time("calculateSheetByCellsTime");
|
|
46592
|
+
var fileList = ctx.luckysheetfile;
|
|
46593
|
+
var sheetIdNameMap = {};
|
|
46594
|
+
for (var ffIndex = 0; ffIndex < fileList.length; ffIndex++) {
|
|
46595
|
+
var _f$name;
|
|
46596
|
+
var f = fileList[ffIndex];
|
|
46597
|
+
sheetIdNameMap[f.id] = (_f$name = f.name) === null || _f$name === void 0 ? void 0 : _f$name.toLocaleUpperCase();
|
|
46598
|
+
}
|
|
46599
|
+
var needUpdateCell = [];
|
|
46600
|
+
var updatedMap = {};
|
|
46601
|
+
for (var index$1 = 0; index$1 < cells.length; index$1++) {
|
|
46602
|
+
var _cells$index = cells[index$1],
|
|
46603
|
+
r = _cells$index.r,
|
|
46604
|
+
c = _cells$index.c,
|
|
46605
|
+
id = _cells$index.id;
|
|
46606
|
+
updatedMap["".concat(sheetIdNameMap[id], "!").concat(indexToColumnChar(c) + (r + 1))] = true;
|
|
46607
|
+
}
|
|
46608
|
+
var _loop = function _loop() {
|
|
46609
|
+
var file = fileList[fIndex];
|
|
46610
|
+
var sheetId = file.id;
|
|
46611
|
+
var _file$calcChain = file.calcChain,
|
|
46612
|
+
calcChain = _file$calcChain === void 0 ? [] : _file$calcChain;
|
|
46613
|
+
for (var _index = 0; _index < calcChain.length; _index++) {
|
|
46614
|
+
var _parseCellReferences;
|
|
46615
|
+
var _calcChain$_index = calcChain[_index],
|
|
46616
|
+
_r2 = _calcChain$_index.r,
|
|
46617
|
+
_c2 = _calcChain$_index.c;
|
|
46618
|
+
var cell = file.data[_r2][_c2];
|
|
46619
|
+
if (!(cell === null || cell === void 0 ? void 0 : cell.f)) {
|
|
46620
|
+
continue;
|
|
46621
|
+
}
|
|
46622
|
+
var devCell = (_parseCellReferences = parseCellReferences(cell.f)) === null || _parseCellReferences === void 0 ? void 0 : _parseCellReferences.map(function (item) {
|
|
46623
|
+
return item.includes("!") ? item : "".concat(sheetIdNameMap[sheetId], "!").concat(item);
|
|
46624
|
+
});
|
|
46625
|
+
var n = devCell === null || devCell === void 0 ? void 0 : devCell.some(function (item) {
|
|
46626
|
+
return updatedMap["".concat(item)];
|
|
46627
|
+
});
|
|
46628
|
+
if (n) {
|
|
46629
|
+
needUpdateCell.push({
|
|
46630
|
+
r: _r2,
|
|
46631
|
+
c: _c2,
|
|
46632
|
+
id: sheetId,
|
|
46633
|
+
f: cell.f,
|
|
46634
|
+
v: cell.v
|
|
46635
|
+
});
|
|
46636
|
+
}
|
|
46637
|
+
}
|
|
46638
|
+
};
|
|
46639
|
+
for (var fIndex = 0; fIndex < fileList.length; fIndex++) {
|
|
46640
|
+
_loop();
|
|
46641
|
+
}
|
|
46642
|
+
needUpdateCell = uniqBy(needUpdateCell, function (item) {
|
|
46643
|
+
return "".concat(item.r, "_").concat(item.c, "_").concat(item.id);
|
|
46644
|
+
});
|
|
46645
|
+
for (var nIndex = 0; nIndex < needUpdateCell.length; nIndex++) {
|
|
46646
|
+
var _needUpdateCell$nInde = needUpdateCell[nIndex],
|
|
46647
|
+
_r = _needUpdateCell$nInde.r,
|
|
46648
|
+
_c = _needUpdateCell$nInde.c,
|
|
46649
|
+
_id = _needUpdateCell$nInde.id,
|
|
46650
|
+
_f = _needUpdateCell$nInde.f,
|
|
46651
|
+
v = _needUpdateCell$nInde.v;
|
|
46652
|
+
var result = execfunction(ctx, _f, _r, _c, _id, undefined, true);
|
|
46653
|
+
var newV = result[1];
|
|
46654
|
+
if (newV === v) {
|
|
46655
|
+
continue;
|
|
46656
|
+
}
|
|
46657
|
+
setCellValue$1(ctx, _r, _c, result[1], null, {
|
|
46658
|
+
id: _id
|
|
46659
|
+
});
|
|
46660
|
+
}
|
|
46661
|
+
console.timeEnd("calculateSheetByCellsTime");
|
|
46662
|
+
}
|
|
46579
46663
|
|
|
46580
46664
|
function storeSheetParam(ctx) {
|
|
46581
46665
|
var index = getSheetIndex(ctx, ctx.currentSheetId);
|
|
@@ -56233,6 +56317,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
56233
56317
|
showSheet: showSheet,
|
|
56234
56318
|
copySheet: copySheet,
|
|
56235
56319
|
calculateSheetFromula: calculateSheetFromula,
|
|
56320
|
+
calculateSheetByCells: calculateSheetByCells,
|
|
56236
56321
|
addSheet: addSheet$1,
|
|
56237
56322
|
deleteSheet: deleteSheet$1,
|
|
56238
56323
|
updateSheet: updateSheet$1,
|
package/dist/index.js
CHANGED
|
@@ -33808,13 +33808,13 @@ var make_ssf = function make_ssf(SSF) {
|
|
|
33808
33808
|
return general_fmt_num_base;
|
|
33809
33809
|
}();
|
|
33810
33810
|
SSF._general_num = general_fmt_num;
|
|
33811
|
-
/*
|
|
33812
|
-
"General" rules:
|
|
33813
|
-
- text is passed through ("@")
|
|
33814
|
-
- booleans are rendered as TRUE/FALSE
|
|
33815
|
-
- "up to 11 characters" displayed for numbers
|
|
33816
|
-
- Default date format (code 14) used for Dates
|
|
33817
|
-
TODO: technically the display depends on the width of the cell
|
|
33811
|
+
/*
|
|
33812
|
+
"General" rules:
|
|
33813
|
+
- text is passed through ("@")
|
|
33814
|
+
- booleans are rendered as TRUE/FALSE
|
|
33815
|
+
- "up to 11 characters" displayed for numbers
|
|
33816
|
+
- Default date format (code 14) used for Dates
|
|
33817
|
+
TODO: technically the display depends on the width of the cell
|
|
33818
33818
|
*/
|
|
33819
33819
|
function general_fmt(v, opts) {
|
|
33820
33820
|
switch (_typeof(v)) {
|
|
@@ -46586,6 +46586,90 @@ function calculateSheetFromula(ctx, id) {
|
|
|
46586
46586
|
ctx.luckysheetfile = luckysheetfile;
|
|
46587
46587
|
console.timeEnd("calcTime:".concat(id));
|
|
46588
46588
|
}
|
|
46589
|
+
function parseCellReferences(expression) {
|
|
46590
|
+
if (typeof expression !== "string" || expression.trim() === "") {
|
|
46591
|
+
return [];
|
|
46592
|
+
}
|
|
46593
|
+
var cellRegex = /([A-Za-z0-9_]+!)?[A-Za-z]+\d+/g;
|
|
46594
|
+
var matches = expression.match(cellRegex) || [];
|
|
46595
|
+
var uniqueCells = matches.map(function (cell) {
|
|
46596
|
+
return cell.trim().toUpperCase();
|
|
46597
|
+
});
|
|
46598
|
+
return uniqueCells;
|
|
46599
|
+
}
|
|
46600
|
+
function calculateSheetByCells(ctx, cells) {
|
|
46601
|
+
console.time("calculateSheetByCellsTime");
|
|
46602
|
+
var fileList = ctx.luckysheetfile;
|
|
46603
|
+
var sheetIdNameMap = {};
|
|
46604
|
+
for (var ffIndex = 0; ffIndex < fileList.length; ffIndex++) {
|
|
46605
|
+
var _f$name;
|
|
46606
|
+
var f = fileList[ffIndex];
|
|
46607
|
+
sheetIdNameMap[f.id] = (_f$name = f.name) === null || _f$name === void 0 ? void 0 : _f$name.toLocaleUpperCase();
|
|
46608
|
+
}
|
|
46609
|
+
var needUpdateCell = [];
|
|
46610
|
+
var updatedMap = {};
|
|
46611
|
+
for (var index$1 = 0; index$1 < cells.length; index$1++) {
|
|
46612
|
+
var _cells$index = cells[index$1],
|
|
46613
|
+
r = _cells$index.r,
|
|
46614
|
+
c = _cells$index.c,
|
|
46615
|
+
id = _cells$index.id;
|
|
46616
|
+
updatedMap["".concat(sheetIdNameMap[id], "!").concat(indexToColumnChar(c) + (r + 1))] = true;
|
|
46617
|
+
}
|
|
46618
|
+
var _loop = function _loop() {
|
|
46619
|
+
var file = fileList[fIndex];
|
|
46620
|
+
var sheetId = file.id;
|
|
46621
|
+
var _file$calcChain = file.calcChain,
|
|
46622
|
+
calcChain = _file$calcChain === void 0 ? [] : _file$calcChain;
|
|
46623
|
+
for (var _index = 0; _index < calcChain.length; _index++) {
|
|
46624
|
+
var _parseCellReferences;
|
|
46625
|
+
var _calcChain$_index = calcChain[_index],
|
|
46626
|
+
_r2 = _calcChain$_index.r,
|
|
46627
|
+
_c2 = _calcChain$_index.c;
|
|
46628
|
+
var cell = file.data[_r2][_c2];
|
|
46629
|
+
if (!(cell === null || cell === void 0 ? void 0 : cell.f)) {
|
|
46630
|
+
continue;
|
|
46631
|
+
}
|
|
46632
|
+
var devCell = (_parseCellReferences = parseCellReferences(cell.f)) === null || _parseCellReferences === void 0 ? void 0 : _parseCellReferences.map(function (item) {
|
|
46633
|
+
return item.includes("!") ? item : "".concat(sheetIdNameMap[sheetId], "!").concat(item);
|
|
46634
|
+
});
|
|
46635
|
+
var n = devCell === null || devCell === void 0 ? void 0 : devCell.some(function (item) {
|
|
46636
|
+
return updatedMap["".concat(item)];
|
|
46637
|
+
});
|
|
46638
|
+
if (n) {
|
|
46639
|
+
needUpdateCell.push({
|
|
46640
|
+
r: _r2,
|
|
46641
|
+
c: _c2,
|
|
46642
|
+
id: sheetId,
|
|
46643
|
+
f: cell.f,
|
|
46644
|
+
v: cell.v
|
|
46645
|
+
});
|
|
46646
|
+
}
|
|
46647
|
+
}
|
|
46648
|
+
};
|
|
46649
|
+
for (var fIndex = 0; fIndex < fileList.length; fIndex++) {
|
|
46650
|
+
_loop();
|
|
46651
|
+
}
|
|
46652
|
+
needUpdateCell = _.uniqBy(needUpdateCell, function (item) {
|
|
46653
|
+
return "".concat(item.r, "_").concat(item.c, "_").concat(item.id);
|
|
46654
|
+
});
|
|
46655
|
+
for (var nIndex = 0; nIndex < needUpdateCell.length; nIndex++) {
|
|
46656
|
+
var _needUpdateCell$nInde = needUpdateCell[nIndex],
|
|
46657
|
+
_r = _needUpdateCell$nInde.r,
|
|
46658
|
+
_c = _needUpdateCell$nInde.c,
|
|
46659
|
+
_id = _needUpdateCell$nInde.id,
|
|
46660
|
+
_f = _needUpdateCell$nInde.f,
|
|
46661
|
+
v = _needUpdateCell$nInde.v;
|
|
46662
|
+
var result = execfunction(ctx, _f, _r, _c, _id, undefined, true);
|
|
46663
|
+
var newV = result[1];
|
|
46664
|
+
if (newV === v) {
|
|
46665
|
+
continue;
|
|
46666
|
+
}
|
|
46667
|
+
setCellValue$1(ctx, _r, _c, result[1], null, {
|
|
46668
|
+
id: _id
|
|
46669
|
+
});
|
|
46670
|
+
}
|
|
46671
|
+
console.timeEnd("calculateSheetByCellsTime");
|
|
46672
|
+
}
|
|
46589
46673
|
|
|
46590
46674
|
function storeSheetParam(ctx) {
|
|
46591
46675
|
var index = getSheetIndex(ctx, ctx.currentSheetId);
|
|
@@ -56243,6 +56327,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
56243
56327
|
showSheet: showSheet,
|
|
56244
56328
|
copySheet: copySheet,
|
|
56245
56329
|
calculateSheetFromula: calculateSheetFromula,
|
|
56330
|
+
calculateSheetByCells: calculateSheetByCells,
|
|
56246
56331
|
addSheet: addSheet$1,
|
|
56247
56332
|
deleteSheet: deleteSheet$1,
|
|
56248
56333
|
updateSheet: updateSheet$1,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leankylin-sheet/core",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.62",
|
|
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": "4.0.
|
|
16
|
+
"@leankylin-sheet/formula-parser": "4.0.62",
|
|
17
17
|
"dayjs": "^1.11.0",
|
|
18
18
|
"immer": "^9.0.12",
|
|
19
19
|
"lodash": "^4.17.21",
|