@fileverse-dev/fortune-core 1.2.86-maitra-xl → 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 +0 -1
- package/es/api/sheet.js +0 -75
- package/lib/api/sheet.d.ts +0 -1
- package/lib/api/sheet.js +0 -76
- package/package.json +1 -1
package/es/api/sheet.d.ts
CHANGED
|
@@ -8,4 +8,3 @@ 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
10
|
export declare function calculateSheetFromula(ctx: Context, id: string): void;
|
|
11
|
-
export declare function calculateReferencedCellSheetFromula(ctx: Context, id: string, refCell?: string[]): void;
|
package/es/api/sheet.js
CHANGED
|
@@ -3,43 +3,6 @@ import { v4 as uuidv4 } from "uuid";
|
|
|
3
3
|
import { dataToCelldata, getSheet } from "./common";
|
|
4
4
|
import { getSheetIndex } from "../utils";
|
|
5
5
|
import { api, execfunction, getFlowdata, insertUpdateFunctionGroup, locale, spillSortResult } 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
|
-
}
|
|
43
6
|
export function getAllSheets(ctx) {
|
|
44
7
|
return ctx.luckysheetfile;
|
|
45
8
|
}
|
|
@@ -171,42 +134,4 @@ export function calculateSheetFromula(ctx, id) {
|
|
|
171
134
|
insertUpdateFunctionGroup(ctx, r, c, id);
|
|
172
135
|
}
|
|
173
136
|
}
|
|
174
|
-
}
|
|
175
|
-
export function calculateReferencedCellSheetFromula(ctx, id, refCell) {
|
|
176
|
-
var _a, _b, _c, _d, _e, _f;
|
|
177
|
-
var index = getSheetIndex(ctx, id);
|
|
178
|
-
if (!ctx.luckysheetfile[index].data) return;
|
|
179
|
-
var _loop_1 = function _loop_1(r) {
|
|
180
|
-
var _loop_2 = function _loop_2(c) {
|
|
181
|
-
console.log(refCell, (_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f);
|
|
182
|
-
var isRef = false;
|
|
183
|
-
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)) {
|
|
184
|
-
isRef = refCell.some(function (cell) {
|
|
185
|
-
var _a;
|
|
186
|
-
return isCellReferenced((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f, cell);
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
if (isRef && !((_d = ctx.luckysheetfile[index].data[r][c]) === null || _d === void 0 ? void 0 : _d.f) || ((_e = ctx.luckysheetfile[index].data[r][c]) === null || _e === void 0 ? void 0 : _e.isDataBlockFormula)) {
|
|
190
|
-
return "continue";
|
|
191
|
-
}
|
|
192
|
-
var result = execfunction(ctx, (_f = ctx.luckysheetfile[index].data[r][c]) === null || _f === void 0 ? void 0 : _f.f, r, c, id);
|
|
193
|
-
var isValueArray = Array.isArray(result[1]);
|
|
194
|
-
if (isValueArray) {
|
|
195
|
-
var value = {
|
|
196
|
-
f: result[2],
|
|
197
|
-
v: result[1]
|
|
198
|
-
};
|
|
199
|
-
spillSortResult(ctx, r, c, value, getFlowdata(ctx));
|
|
200
|
-
} else {
|
|
201
|
-
api.setCellValue(ctx, r, c, result[1], null);
|
|
202
|
-
}
|
|
203
|
-
insertUpdateFunctionGroup(ctx, r, c, id);
|
|
204
|
-
};
|
|
205
|
-
for (var c = 0; c < ctx.luckysheetfile[index].data[r].length; c += 1) {
|
|
206
|
-
_loop_2(c);
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
for (var r = 0; r < ctx.luckysheetfile[index].data.length; r += 1) {
|
|
210
|
-
_loop_1(r);
|
|
211
|
-
}
|
|
212
137
|
}
|
package/lib/api/sheet.d.ts
CHANGED
|
@@ -8,4 +8,3 @@ 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
10
|
export declare function calculateSheetFromula(ctx: Context, id: string): void;
|
|
11
|
-
export declare function calculateReferencedCellSheetFromula(ctx: Context, id: string, refCell?: string[]): void;
|
package/lib/api/sheet.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.calculateReferencedCellSheetFromula = calculateReferencedCellSheetFromula;
|
|
7
6
|
exports.calculateSheetFromula = calculateSheetFromula;
|
|
8
7
|
exports.copySheet = copySheet;
|
|
9
8
|
exports.getAllSheets = getAllSheets;
|
|
@@ -22,43 +21,6 @@ var _common = require("./common");
|
|
|
22
21
|
var _utils = require("../utils");
|
|
23
22
|
var _2 = require("..");
|
|
24
23
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
25
|
-
function isCellReferenced(formulaString, cell) {
|
|
26
|
-
function colToNumber(col) {
|
|
27
|
-
var num = 0;
|
|
28
|
-
for (var i = 0; i < col.length; i++) {
|
|
29
|
-
num = num * 26 + (col.charCodeAt(i) - 64);
|
|
30
|
-
}
|
|
31
|
-
return num;
|
|
32
|
-
}
|
|
33
|
-
function parseCell(cellRef) {
|
|
34
|
-
var match = cellRef.match(/^([A-Z]+)(\d+)$/);
|
|
35
|
-
if (!match) return null;
|
|
36
|
-
return {
|
|
37
|
-
col: colToNumber(match[1]),
|
|
38
|
-
row: Number(match[2])
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
var target = parseCell(cell.toUpperCase());
|
|
42
|
-
if (!target) return false;
|
|
43
|
-
var formula = formulaString.toUpperCase();
|
|
44
|
-
var rangeRegex = /([A-Z]+\d+):([A-Z]+\d+)/g;
|
|
45
|
-
var match;
|
|
46
|
-
while ((match = rangeRegex.exec(formula)) !== null) {
|
|
47
|
-
var start = parseCell(match[1]);
|
|
48
|
-
var end = parseCell(match[2]);
|
|
49
|
-
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)) {
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
var cleanedFormula = formula.replace(rangeRegex, "");
|
|
54
|
-
var cellRegex = /([A-Z]+\d+)/g;
|
|
55
|
-
while ((match = cellRegex.exec(cleanedFormula)) !== null) {
|
|
56
|
-
if (match[1] === cell.toUpperCase()) {
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
24
|
function getAllSheets(ctx) {
|
|
63
25
|
return ctx.luckysheetfile;
|
|
64
26
|
}
|
|
@@ -189,42 +151,4 @@ function calculateSheetFromula(ctx, id) {
|
|
|
189
151
|
(0, _2.insertUpdateFunctionGroup)(ctx, r, c, id);
|
|
190
152
|
}
|
|
191
153
|
}
|
|
192
|
-
}
|
|
193
|
-
function calculateReferencedCellSheetFromula(ctx, id, refCell) {
|
|
194
|
-
var _a, _b, _c, _d, _e, _f;
|
|
195
|
-
var index = (0, _utils.getSheetIndex)(ctx, id);
|
|
196
|
-
if (!ctx.luckysheetfile[index].data) return;
|
|
197
|
-
var _loop_1 = function _loop_1(r) {
|
|
198
|
-
var _loop_2 = function _loop_2(c) {
|
|
199
|
-
console.log(refCell, (_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f);
|
|
200
|
-
var isRef = false;
|
|
201
|
-
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)) {
|
|
202
|
-
isRef = refCell.some(function (cell) {
|
|
203
|
-
var _a;
|
|
204
|
-
return isCellReferenced((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f, cell);
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
if (isRef && !((_d = ctx.luckysheetfile[index].data[r][c]) === null || _d === void 0 ? void 0 : _d.f) || ((_e = ctx.luckysheetfile[index].data[r][c]) === null || _e === void 0 ? void 0 : _e.isDataBlockFormula)) {
|
|
208
|
-
return "continue";
|
|
209
|
-
}
|
|
210
|
-
var result = (0, _2.execfunction)(ctx, (_f = ctx.luckysheetfile[index].data[r][c]) === null || _f === void 0 ? void 0 : _f.f, r, c, id);
|
|
211
|
-
var isValueArray = Array.isArray(result[1]);
|
|
212
|
-
if (isValueArray) {
|
|
213
|
-
var value = {
|
|
214
|
-
f: result[2],
|
|
215
|
-
v: result[1]
|
|
216
|
-
};
|
|
217
|
-
(0, _2.spillSortResult)(ctx, r, c, value, (0, _2.getFlowdata)(ctx));
|
|
218
|
-
} else {
|
|
219
|
-
_2.api.setCellValue(ctx, r, c, result[1], null);
|
|
220
|
-
}
|
|
221
|
-
(0, _2.insertUpdateFunctionGroup)(ctx, r, c, id);
|
|
222
|
-
};
|
|
223
|
-
for (var c = 0; c < ctx.luckysheetfile[index].data[r].length; c += 1) {
|
|
224
|
-
_loop_2(c);
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
for (var r = 0; r < ctx.luckysheetfile[index].data.length; r += 1) {
|
|
228
|
-
_loop_1(r);
|
|
229
|
-
}
|
|
230
154
|
}
|