@fileverse-dev/fortune-core 1.2.85 → 1.2.86
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/es/api/sheet.d.ts +1 -1
- package/es/api/sheet.js +18 -58
- package/lib/api/sheet.d.ts +1 -1
- package/lib/api/sheet.js +17 -57
- package/package.json +1 -1
package/es/api/sheet.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export declare function initSheetData(draftCtx: Context, index: number, newData:
|
|
|
7
7
|
export declare function hideSheet(ctx: Context, sheetId: string): void;
|
|
8
8
|
export declare function showSheet(ctx: Context, sheetId: string): void;
|
|
9
9
|
export declare function copySheet(ctx: Context, sheetId: string): void;
|
|
10
|
-
export declare function calculateSheetFromula(ctx: Context, id: string
|
|
10
|
+
export declare function calculateSheetFromula(ctx: Context, id: string): void;
|
package/es/api/sheet.js
CHANGED
|
@@ -2,44 +2,7 @@ import _ from "lodash";
|
|
|
2
2
|
import { v4 as uuidv4 } from "uuid";
|
|
3
3
|
import { dataToCelldata, getSheet } from "./common";
|
|
4
4
|
import { getSheetIndex } from "../utils";
|
|
5
|
-
import { api, locale } from "..";
|
|
6
|
-
function isCellReferenced(formulaString, cell) {
|
|
7
|
-
function colToNumber(col) {
|
|
8
|
-
var num = 0;
|
|
9
|
-
for (var i = 0; i < col.length; i++) {
|
|
10
|
-
num = num * 26 + (col.charCodeAt(i) - 64);
|
|
11
|
-
}
|
|
12
|
-
return num;
|
|
13
|
-
}
|
|
14
|
-
function parseCell(cellRef) {
|
|
15
|
-
var match = cellRef.match(/^([A-Z]+)(\d+)$/);
|
|
16
|
-
if (!match) return null;
|
|
17
|
-
return {
|
|
18
|
-
col: colToNumber(match[1]),
|
|
19
|
-
row: Number(match[2])
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
var target = parseCell(cell.toUpperCase());
|
|
23
|
-
if (!target) return false;
|
|
24
|
-
var formula = formulaString.toUpperCase();
|
|
25
|
-
var rangeRegex = /([A-Z]+\d+):([A-Z]+\d+)/g;
|
|
26
|
-
var match;
|
|
27
|
-
while ((match = rangeRegex.exec(formula)) !== null) {
|
|
28
|
-
var start = parseCell(match[1]);
|
|
29
|
-
var end = parseCell(match[2]);
|
|
30
|
-
if (target.col >= Math.min(start.col, end.col) && target.col <= Math.max(start.col, end.col) && target.row >= Math.min(start.row, end.row) && target.row <= Math.max(start.row, end.row)) {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
var cleanedFormula = formula.replace(rangeRegex, "");
|
|
35
|
-
var cellRegex = /([A-Z]+\d+)/g;
|
|
36
|
-
while ((match = cellRegex.exec(cleanedFormula)) !== null) {
|
|
37
|
-
if (match[1] === cell.toUpperCase()) {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
5
|
+
import { api, execfunction, getFlowdata, insertUpdateFunctionGroup, locale, spillSortResult } from "..";
|
|
43
6
|
export function getAllSheets(ctx) {
|
|
44
7
|
return ctx.luckysheetfile;
|
|
45
8
|
}
|
|
@@ -148,30 +111,27 @@ export function copySheet(ctx, sheetId) {
|
|
|
148
111
|
sheetOrderList[ctx.luckysheetfile[ctx.luckysheetfile.length - 1].id] = order;
|
|
149
112
|
api.setSheetOrder(ctx, sheetOrderList);
|
|
150
113
|
}
|
|
151
|
-
export function calculateSheetFromula(ctx, id
|
|
152
|
-
var _a, _b, _c
|
|
114
|
+
export function calculateSheetFromula(ctx, id) {
|
|
115
|
+
var _a, _b, _c;
|
|
153
116
|
var index = getSheetIndex(ctx, id);
|
|
154
117
|
if (!ctx.luckysheetfile[index].data) return;
|
|
155
|
-
var
|
|
156
|
-
var
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (refCell && ((_b = ctx.luckysheetfile[index].data[r][c]) === null || _b === void 0 ? void 0 : _b.f) && !((_c = ctx.luckysheetfile[index].data[r][c]) === null || _c === void 0 ? void 0 : _c.isDataBlockFormula)) {
|
|
160
|
-
isRef = refCell.some(function (cell) {
|
|
161
|
-
var _a;
|
|
162
|
-
return isCellReferenced((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f, cell);
|
|
163
|
-
});
|
|
118
|
+
for (var r = 0; r < ctx.luckysheetfile[index].data.length; r += 1) {
|
|
119
|
+
for (var c = 0; c < ctx.luckysheetfile[index].data[r].length; c += 1) {
|
|
120
|
+
if (!((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f) || ((_b = ctx.luckysheetfile[index].data[r][c]) === null || _b === void 0 ? void 0 : _b.isDataBlockFormula)) {
|
|
121
|
+
continue;
|
|
164
122
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
123
|
+
var result = execfunction(ctx, (_c = ctx.luckysheetfile[index].data[r][c]) === null || _c === void 0 ? void 0 : _c.f, r, c, id);
|
|
124
|
+
var isValueArray = Array.isArray(result[1]);
|
|
125
|
+
if (isValueArray) {
|
|
126
|
+
var value = {
|
|
127
|
+
f: result[2],
|
|
128
|
+
v: result[1]
|
|
129
|
+
};
|
|
130
|
+
spillSortResult(ctx, r, c, value, getFlowdata(ctx));
|
|
131
|
+
} else {
|
|
132
|
+
api.setCellValue(ctx, r, c, result[1], null);
|
|
168
133
|
}
|
|
169
|
-
|
|
170
|
-
for (var c = 0; c < ctx.luckysheetfile[index].data[r].length; c += 1) {
|
|
171
|
-
_loop_2(c);
|
|
134
|
+
insertUpdateFunctionGroup(ctx, r, c, id);
|
|
172
135
|
}
|
|
173
|
-
};
|
|
174
|
-
for (var r = 0; r < ctx.luckysheetfile[index].data.length; r += 1) {
|
|
175
|
-
_loop_1(r);
|
|
176
136
|
}
|
|
177
137
|
}
|
package/lib/api/sheet.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export declare function initSheetData(draftCtx: Context, index: number, newData:
|
|
|
7
7
|
export declare function hideSheet(ctx: Context, sheetId: string): void;
|
|
8
8
|
export declare function showSheet(ctx: Context, sheetId: string): void;
|
|
9
9
|
export declare function copySheet(ctx: Context, sheetId: string): void;
|
|
10
|
-
export declare function calculateSheetFromula(ctx: Context, id: string
|
|
10
|
+
export declare function calculateSheetFromula(ctx: Context, id: string): void;
|
package/lib/api/sheet.js
CHANGED
|
@@ -21,43 +21,6 @@ var _common = require("./common");
|
|
|
21
21
|
var _utils = require("../utils");
|
|
22
22
|
var _2 = require("..");
|
|
23
23
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
|
-
function isCellReferenced(formulaString, cell) {
|
|
25
|
-
function colToNumber(col) {
|
|
26
|
-
var num = 0;
|
|
27
|
-
for (var i = 0; i < col.length; i++) {
|
|
28
|
-
num = num * 26 + (col.charCodeAt(i) - 64);
|
|
29
|
-
}
|
|
30
|
-
return num;
|
|
31
|
-
}
|
|
32
|
-
function parseCell(cellRef) {
|
|
33
|
-
var match = cellRef.match(/^([A-Z]+)(\d+)$/);
|
|
34
|
-
if (!match) return null;
|
|
35
|
-
return {
|
|
36
|
-
col: colToNumber(match[1]),
|
|
37
|
-
row: Number(match[2])
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
var target = parseCell(cell.toUpperCase());
|
|
41
|
-
if (!target) return false;
|
|
42
|
-
var formula = formulaString.toUpperCase();
|
|
43
|
-
var rangeRegex = /([A-Z]+\d+):([A-Z]+\d+)/g;
|
|
44
|
-
var match;
|
|
45
|
-
while ((match = rangeRegex.exec(formula)) !== null) {
|
|
46
|
-
var start = parseCell(match[1]);
|
|
47
|
-
var end = parseCell(match[2]);
|
|
48
|
-
if (target.col >= Math.min(start.col, end.col) && target.col <= Math.max(start.col, end.col) && target.row >= Math.min(start.row, end.row) && target.row <= Math.max(start.row, end.row)) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
var cleanedFormula = formula.replace(rangeRegex, "");
|
|
53
|
-
var cellRegex = /([A-Z]+\d+)/g;
|
|
54
|
-
while ((match = cellRegex.exec(cleanedFormula)) !== null) {
|
|
55
|
-
if (match[1] === cell.toUpperCase()) {
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
24
|
function getAllSheets(ctx) {
|
|
62
25
|
return ctx.luckysheetfile;
|
|
63
26
|
}
|
|
@@ -165,30 +128,27 @@ function copySheet(ctx, sheetId) {
|
|
|
165
128
|
sheetOrderList[ctx.luckysheetfile[ctx.luckysheetfile.length - 1].id] = order;
|
|
166
129
|
_2.api.setSheetOrder(ctx, sheetOrderList);
|
|
167
130
|
}
|
|
168
|
-
function calculateSheetFromula(ctx, id
|
|
169
|
-
var _a, _b, _c
|
|
131
|
+
function calculateSheetFromula(ctx, id) {
|
|
132
|
+
var _a, _b, _c;
|
|
170
133
|
var index = (0, _utils.getSheetIndex)(ctx, id);
|
|
171
134
|
if (!ctx.luckysheetfile[index].data) return;
|
|
172
|
-
var
|
|
173
|
-
var
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (refCell && ((_b = ctx.luckysheetfile[index].data[r][c]) === null || _b === void 0 ? void 0 : _b.f) && !((_c = ctx.luckysheetfile[index].data[r][c]) === null || _c === void 0 ? void 0 : _c.isDataBlockFormula)) {
|
|
177
|
-
isRef = refCell.some(function (cell) {
|
|
178
|
-
var _a;
|
|
179
|
-
return isCellReferenced((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f, cell);
|
|
180
|
-
});
|
|
135
|
+
for (var r = 0; r < ctx.luckysheetfile[index].data.length; r += 1) {
|
|
136
|
+
for (var c = 0; c < ctx.luckysheetfile[index].data[r].length; c += 1) {
|
|
137
|
+
if (!((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f) || ((_b = ctx.luckysheetfile[index].data[r][c]) === null || _b === void 0 ? void 0 : _b.isDataBlockFormula)) {
|
|
138
|
+
continue;
|
|
181
139
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
140
|
+
var result = (0, _2.execfunction)(ctx, (_c = ctx.luckysheetfile[index].data[r][c]) === null || _c === void 0 ? void 0 : _c.f, r, c, id);
|
|
141
|
+
var isValueArray = Array.isArray(result[1]);
|
|
142
|
+
if (isValueArray) {
|
|
143
|
+
var value = {
|
|
144
|
+
f: result[2],
|
|
145
|
+
v: result[1]
|
|
146
|
+
};
|
|
147
|
+
(0, _2.spillSortResult)(ctx, r, c, value, (0, _2.getFlowdata)(ctx));
|
|
148
|
+
} else {
|
|
149
|
+
_2.api.setCellValue(ctx, r, c, result[1], null);
|
|
185
150
|
}
|
|
186
|
-
|
|
187
|
-
for (var c = 0; c < ctx.luckysheetfile[index].data[r].length; c += 1) {
|
|
188
|
-
_loop_2(c);
|
|
151
|
+
(0, _2.insertUpdateFunctionGroup)(ctx, r, c, id);
|
|
189
152
|
}
|
|
190
|
-
};
|
|
191
|
-
for (var r = 0; r < ctx.luckysheetfile[index].data.length; r += 1) {
|
|
192
|
-
_loop_1(r);
|
|
193
153
|
}
|
|
194
154
|
}
|