@visactor/vtable-sheet 1.20.0-alpha.3 → 1.20.0
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 +173 -0
- package/cjs/components/vtable-sheet.d.ts +2 -0
- package/cjs/components/vtable-sheet.js +45 -13
- package/cjs/components/vtable-sheet.js.map +1 -1
- package/cjs/core/WorkSheet.d.ts +1 -0
- package/cjs/core/WorkSheet.js +32 -7
- package/cjs/core/WorkSheet.js.map +1 -1
- package/cjs/core/table-plugins.js.map +1 -1
- package/cjs/event/event-manager.d.ts +7 -8
- package/cjs/event/event-manager.js +2 -11
- package/cjs/event/event-manager.js.map +1 -1
- package/cjs/formula/formula-autocomplete.js.map +1 -1
- package/cjs/formula/formula-editor.js.map +1 -1
- package/cjs/formula/formula-engine.d.ts +102 -0
- package/cjs/formula/formula-engine.js +1028 -0
- package/cjs/formula/formula-engine.js.map +1 -0
- package/cjs/formula/formula-helper.js +1 -1
- package/cjs/formula/formula-helper.js.map +1 -1
- package/cjs/formula/formula-range-selector.d.ts +5 -2
- package/cjs/formula/formula-range-selector.js +70 -15
- package/cjs/formula/formula-range-selector.js.map +1 -1
- package/cjs/formula/formula-ui-manager.js +7 -4
- package/cjs/formula/formula-ui-manager.js.map +1 -1
- package/cjs/formula/index.js +1 -2
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/managers/formula-manager.d.ts +19 -16
- package/cjs/managers/formula-manager.js +71 -183
- package/cjs/managers/formula-manager.js.map +1 -1
- package/cjs/managers/menu-manager.js.map +1 -1
- package/cjs/tools/env.js.map +1 -1
- package/cjs/ts-types/event.d.ts +77 -68
- package/cjs/ts-types/event.js +6 -1
- package/cjs/ts-types/event.js.map +1 -1
- package/dist/vtable-sheet.js +73155 -109724
- package/dist/vtable-sheet.min.js +1 -853
- package/es/components/vtable-sheet.d.ts +2 -0
- package/es/components/vtable-sheet.js +46 -12
- package/es/components/vtable-sheet.js.map +1 -1
- package/es/core/WorkSheet.d.ts +1 -0
- package/es/core/WorkSheet.js +32 -5
- package/es/core/WorkSheet.js.map +1 -1
- package/es/core/table-plugins.js.map +1 -1
- package/es/event/event-manager.d.ts +7 -8
- package/es/event/event-manager.js +2 -11
- package/es/event/event-manager.js.map +1 -1
- package/es/formula/formula-autocomplete.js.map +1 -1
- package/es/formula/formula-editor.js.map +1 -1
- package/es/formula/formula-engine.d.ts +102 -0
- package/es/formula/formula-engine.js +1020 -0
- package/es/formula/formula-engine.js.map +1 -0
- package/es/formula/formula-helper.js +1 -1
- package/es/formula/formula-helper.js.map +1 -1
- package/es/formula/formula-range-selector.d.ts +5 -2
- package/es/formula/formula-range-selector.js +70 -15
- package/es/formula/formula-range-selector.js.map +1 -1
- package/es/formula/formula-ui-manager.js +7 -4
- package/es/formula/formula-ui-manager.js.map +1 -1
- package/es/formula/index.js +1 -2
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/managers/formula-manager.d.ts +19 -16
- package/es/managers/formula-manager.js +72 -184
- package/es/managers/formula-manager.js.map +1 -1
- package/es/managers/menu-manager.js.map +1 -1
- package/es/tools/env.js.map +1 -1
- package/es/ts-types/event.d.ts +77 -68
- package/es/ts-types/event.js +6 -1
- package/es/ts-types/event.js.map +1 -1
- package/package.json +6 -7
- package/cjs/test/formula-complete.test.d.ts +0 -1
- package/cjs/test/formula-complete.test.js +0 -42
- package/cjs/test/formula-complete.test.js.map +0 -1
- package/es/test/formula-complete.test.d.ts +0 -1
- package/es/test/formula-complete.test.js +0 -36
- package/es/test/formula-complete.test.js.map +0 -1
|
@@ -4,19 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.FormulaManager = void 0;
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
licenseKey: "gpl-v3",
|
|
9
|
-
useColumnIndex: !0,
|
|
10
|
-
useArrayArithmetic: !1,
|
|
11
|
-
useStats: !0,
|
|
7
|
+
const formula_engine_1 = require("../formula/formula-engine"), formula_range_selector_1 = require("../formula/formula-range-selector"), formula_1 = require("../formula"), DEFAULT_FORMULA_ENGINE_CONFIG = {
|
|
12
8
|
precisionRounding: 14,
|
|
13
|
-
nullYear: 30,
|
|
14
|
-
leapYear1900: !1,
|
|
15
|
-
smartRounding: !0,
|
|
16
|
-
functionPlugins: [],
|
|
17
|
-
ignoreWhiteSpace: "standard",
|
|
18
9
|
caseSensitive: !1,
|
|
19
|
-
|
|
10
|
+
ignoreWhiteSpace: "standard",
|
|
20
11
|
nullDate: {
|
|
21
12
|
year: 1899,
|
|
22
13
|
month: 12,
|
|
@@ -39,39 +30,26 @@ class FormulaManager {
|
|
|
39
30
|
this.lastSelectionRangesOfHandling = [], this.inputIsParamMode = null, this.inputingElement = null,
|
|
40
31
|
this.sheet = sheet, this.cellHighlightManager = new formula_1.CellHighlightManager(sheet),
|
|
41
32
|
this.formulaRangeSelector = new formula_range_selector_1.FormulaRangeSelector(this),
|
|
42
|
-
this.
|
|
33
|
+
this.initializeFormulaEngine();
|
|
43
34
|
}
|
|
44
|
-
|
|
35
|
+
initializeFormulaEngine() {
|
|
45
36
|
try {
|
|
46
|
-
this.
|
|
37
|
+
this.formulaEngine = new formula_engine_1.FormulaEngine(DEFAULT_FORMULA_ENGINE_CONFIG),
|
|
47
38
|
this.isInitialized = !0;
|
|
48
39
|
} catch (error) {
|
|
49
40
|
throw new Error("FormulaManager initialization failed");
|
|
50
41
|
}
|
|
51
42
|
}
|
|
52
43
|
addSheet(sheetKey, normalizedData) {
|
|
53
|
-
if (this.ensureInitialized(), this.sheetMapping.has(sheetKey))
|
|
44
|
+
if (this.ensureInitialized(), this.sheetMapping.has(sheetKey)) {
|
|
45
|
+
const existingId = this.sheetMapping.get(sheetKey);
|
|
46
|
+
if (void 0 !== existingId) return existingId;
|
|
47
|
+
}
|
|
54
48
|
try {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (this.hyperFormula.getSheetName(0) !== sheetKey) try {
|
|
60
|
-
this.hyperFormula.renameSheet(0, sheetKey);
|
|
61
|
-
} catch (e) {}
|
|
62
|
-
} else try {
|
|
63
|
-
const existingSheetId = this.hyperFormula.getSheetId(sheetKey);
|
|
64
|
-
if (void 0 !== existingSheetId) sheetId = existingSheetId; else {
|
|
65
|
-
const sheetName = this.hyperFormula.addSheet(sheetKey);
|
|
66
|
-
sheetId = this.hyperFormula.getSheetId(sheetName);
|
|
67
|
-
}
|
|
68
|
-
} catch (error) {
|
|
69
|
-
const sheetName = this.hyperFormula.addSheet(sheetKey);
|
|
70
|
-
sheetId = this.hyperFormula.getSheetId(sheetName);
|
|
71
|
-
}
|
|
72
|
-
return Array.isArray(normalizedData) && normalizedData.length > 0 && this.hyperFormula.setSheetContent(sheetId, normalizedData),
|
|
73
|
-
this.sheetMapping.set(sheetKey, sheetId), this.reverseSheetMapping.set(sheetId, sheetKey),
|
|
74
|
-
this.nextSheetId = Math.max(this.nextSheetId, sheetId + 1), sheetId;
|
|
49
|
+
const wasFirstSheet = 0 === this.sheetMapping.size, sheetId = this.formulaEngine.addSheet(sheetKey, normalizedData);
|
|
50
|
+
return this.sheetMapping.set(sheetKey, sheetId), this.reverseSheetMapping.set(sheetId, sheetKey),
|
|
51
|
+
this.nextSheetId = Math.max(this.nextSheetId, sheetId + 1), wasFirstSheet && this.formulaEngine.setActiveSheet(sheetKey),
|
|
52
|
+
sheetId;
|
|
75
53
|
} catch (error) {
|
|
76
54
|
throw new Error(`Failed to add sheet: ${sheetKey}`);
|
|
77
55
|
}
|
|
@@ -112,7 +90,7 @@ class FormulaManager {
|
|
|
112
90
|
const sheetId = this.sheetMapping.get(sheetKey);
|
|
113
91
|
if (void 0 !== sheetId) try {
|
|
114
92
|
if (this.sheetMapping.size <= 1) throw new Error("Cannot remove the last sheet");
|
|
115
|
-
this.
|
|
93
|
+
this.formulaEngine.removeSheet(sheetKey), this.sheetMapping.delete(sheetKey), this.reverseSheetMapping.delete(sheetId);
|
|
116
94
|
} catch (error) {
|
|
117
95
|
throw new Error(`Failed to remove sheet: ${sheetKey}`);
|
|
118
96
|
}
|
|
@@ -121,7 +99,7 @@ class FormulaManager {
|
|
|
121
99
|
const sheetId = this.sheetMapping.get(oldKey);
|
|
122
100
|
if (void 0 === sheetId) throw new Error(`Sheet not found: ${oldKey}`);
|
|
123
101
|
try {
|
|
124
|
-
this.
|
|
102
|
+
this.formulaEngine.renameSheet(oldKey, newKey), this.sheetMapping.delete(oldKey),
|
|
125
103
|
this.sheetMapping.set(newKey, sheetId), this.reverseSheetMapping.set(sheetId, newKey);
|
|
126
104
|
} catch (error) {
|
|
127
105
|
throw new Error(`Failed to rename sheet: ${oldKey}`);
|
|
@@ -131,26 +109,11 @@ class FormulaManager {
|
|
|
131
109
|
const sheetId = this.sheetMapping.get(sheetKey);
|
|
132
110
|
return void 0 === sheetId ? this.addSheet(sheetKey) : sheetId;
|
|
133
111
|
}
|
|
134
|
-
getHasHeader(sheetKey) {
|
|
135
|
-
var _a, _b, _c;
|
|
136
|
-
const sheetDefine = this.sheet.getSheetManager().getSheet(sheetKey);
|
|
137
|
-
return null !== (_c = null !== (_a = null == sheetDefine ? void 0 : sheetDefine.showHeader) && void 0 !== _a ? _a : (null === (_b = null == sheetDefine ? void 0 : sheetDefine.columns) || void 0 === _b ? void 0 : _b.length) > 0) && void 0 !== _c && _c;
|
|
138
|
-
}
|
|
139
112
|
setCellContent(cell, value) {
|
|
140
113
|
if (this.ensureInitialized(), !cell || void 0 === cell.sheet || void 0 === cell.row || void 0 === cell.col) throw new Error("Invalid cell parameter for setCellContent");
|
|
141
114
|
if (cell.row < 0 || cell.col < 0) throw new Error(`Cell coordinates out of bounds: row=${cell.row}, col=${cell.col}`);
|
|
142
115
|
try {
|
|
143
|
-
|
|
144
|
-
sheet: this.getSheetId(cell.sheet),
|
|
145
|
-
row: cell.row,
|
|
146
|
-
col: cell.col
|
|
147
|
-
};
|
|
148
|
-
let processedValue = value;
|
|
149
|
-
if (null == processedValue && (processedValue = ""), "string" == typeof processedValue && !processedValue.startsWith("=")) {
|
|
150
|
-
const numericValue = Number(processedValue);
|
|
151
|
-
isNaN(numericValue) || "" === processedValue.trim() || (processedValue = numericValue);
|
|
152
|
-
}
|
|
153
|
-
this.hyperFormula.setCellContents(address, [ [ processedValue ] ]);
|
|
116
|
+
this.formulaEngine.setCellContent(cell, value);
|
|
154
117
|
} catch (error) {
|
|
155
118
|
throw error instanceof Error ? new Error(`Failed to set cell content at ${cell.sheet}:${cell.row}:${cell.col}. ${error.message}`) : new Error(`Failed to set cell content at ${cell.sheet}:${cell.row}:${cell.col}`);
|
|
156
119
|
}
|
|
@@ -158,15 +121,7 @@ class FormulaManager {
|
|
|
158
121
|
getCellValue(cell) {
|
|
159
122
|
this.ensureInitialized();
|
|
160
123
|
try {
|
|
161
|
-
|
|
162
|
-
sheet: this.getSheetId(cell.sheet),
|
|
163
|
-
row: cell.row,
|
|
164
|
-
col: cell.col
|
|
165
|
-
}, value = this.hyperFormula.getCellValue(address);
|
|
166
|
-
return {
|
|
167
|
-
value: value,
|
|
168
|
-
error: value instanceof hyperformula_1.CellError ? value : void 0
|
|
169
|
-
};
|
|
124
|
+
return this.formulaEngine.getCellValue(cell);
|
|
170
125
|
} catch (error) {
|
|
171
126
|
return {
|
|
172
127
|
value: null,
|
|
@@ -177,12 +132,7 @@ class FormulaManager {
|
|
|
177
132
|
getCellFormula(cell) {
|
|
178
133
|
this.ensureInitialized();
|
|
179
134
|
try {
|
|
180
|
-
|
|
181
|
-
sheet: this.getSheetId(cell.sheet),
|
|
182
|
-
row: cell.row,
|
|
183
|
-
col: cell.col
|
|
184
|
-
};
|
|
185
|
-
return this.hyperFormula.getCellFormula(address);
|
|
135
|
+
return this.formulaEngine.getCellFormula(cell);
|
|
186
136
|
} catch (error) {
|
|
187
137
|
return;
|
|
188
138
|
}
|
|
@@ -190,12 +140,7 @@ class FormulaManager {
|
|
|
190
140
|
isCellFormula(cell) {
|
|
191
141
|
this.ensureInitialized();
|
|
192
142
|
try {
|
|
193
|
-
|
|
194
|
-
sheet: this.getSheetId(cell.sheet),
|
|
195
|
-
row: cell.row,
|
|
196
|
-
col: cell.col
|
|
197
|
-
};
|
|
198
|
-
return this.hyperFormula.doesCellHaveFormula(address);
|
|
143
|
+
return this.formulaEngine.isCellFormula(cell);
|
|
199
144
|
} catch (error) {
|
|
200
145
|
return !1;
|
|
201
146
|
}
|
|
@@ -203,16 +148,7 @@ class FormulaManager {
|
|
|
203
148
|
getCellDependents(cell) {
|
|
204
149
|
this.ensureInitialized();
|
|
205
150
|
try {
|
|
206
|
-
|
|
207
|
-
sheet: this.getSheetId(cell.sheet),
|
|
208
|
-
row: cell.row,
|
|
209
|
-
col: cell.col
|
|
210
|
-
};
|
|
211
|
-
return this.hyperFormula.getCellDependents(address).filter((dep => "sheet" in dep && "row" in dep && "col" in dep)).map((dep => ({
|
|
212
|
-
sheet: this.reverseSheetMapping.get(dep.sheet) || "",
|
|
213
|
-
row: dep.row,
|
|
214
|
-
col: dep.col
|
|
215
|
-
})));
|
|
151
|
+
return this.formulaEngine.getCellDependents(cell);
|
|
216
152
|
} catch (error) {
|
|
217
153
|
return [];
|
|
218
154
|
}
|
|
@@ -220,16 +156,7 @@ class FormulaManager {
|
|
|
220
156
|
getCellPrecedents(cell) {
|
|
221
157
|
this.ensureInitialized();
|
|
222
158
|
try {
|
|
223
|
-
|
|
224
|
-
sheet: this.getSheetId(cell.sheet),
|
|
225
|
-
row: cell.row,
|
|
226
|
-
col: cell.col
|
|
227
|
-
};
|
|
228
|
-
return this.hyperFormula.getCellPrecedents(address).filter((prec => "sheet" in prec && "row" in prec && "col" in prec)).map((prec => ({
|
|
229
|
-
sheet: this.reverseSheetMapping.get(prec.sheet) || "",
|
|
230
|
-
row: prec.row,
|
|
231
|
-
col: prec.col
|
|
232
|
-
})));
|
|
159
|
+
return this.formulaEngine.getCellPrecedents(cell);
|
|
233
160
|
} catch (error) {
|
|
234
161
|
return [];
|
|
235
162
|
}
|
|
@@ -237,78 +164,44 @@ class FormulaManager {
|
|
|
237
164
|
batchUpdate(changes) {
|
|
238
165
|
this.ensureInitialized();
|
|
239
166
|
try {
|
|
240
|
-
this.
|
|
241
|
-
changes.forEach((({cell: cell, value: value}) => {
|
|
242
|
-
const address = {
|
|
243
|
-
sheet: this.getSheetId(cell.sheet),
|
|
244
|
-
row: cell.row,
|
|
245
|
-
col: cell.col
|
|
246
|
-
};
|
|
247
|
-
this.hyperFormula.setCellContents(address, [ [ value ] ]);
|
|
248
|
-
}));
|
|
249
|
-
}));
|
|
167
|
+
for (const {cell: cell, value: value} of changes) this.formulaEngine.setCellContent(cell, value);
|
|
250
168
|
} catch (error) {
|
|
251
169
|
throw new Error("Batch update failed");
|
|
252
170
|
}
|
|
253
171
|
}
|
|
254
|
-
addRows(
|
|
172
|
+
addRows(_sheetKey, rowIndex, numberOfRows = 1) {
|
|
255
173
|
this.ensureInitialized();
|
|
256
|
-
try {
|
|
257
|
-
const sheetId = this.getSheetId(sheetKey);
|
|
258
|
-
this.hyperFormula.addRows(sheetId, [ rowIndex, numberOfRows ]);
|
|
259
|
-
} catch (error) {
|
|
260
|
-
throw new Error(`Failed to add ${numberOfRows} rows at index ${rowIndex}`);
|
|
261
|
-
}
|
|
262
174
|
}
|
|
263
|
-
removeRows(
|
|
175
|
+
removeRows(_sheetKey, rowIndex, numberOfRows = 1) {
|
|
264
176
|
this.ensureInitialized();
|
|
265
|
-
try {
|
|
266
|
-
const sheetId = this.getSheetId(sheetKey);
|
|
267
|
-
this.hyperFormula.removeRows(sheetId, [ rowIndex, numberOfRows ]);
|
|
268
|
-
} catch (error) {
|
|
269
|
-
throw new Error(`Failed to remove ${numberOfRows} rows at index ${rowIndex}`);
|
|
270
|
-
}
|
|
271
177
|
}
|
|
272
|
-
addColumns(
|
|
178
|
+
addColumns(_sheetKey, columnIndex, numberOfColumns = 1) {
|
|
273
179
|
this.ensureInitialized();
|
|
274
|
-
try {
|
|
275
|
-
const sheetId = this.getSheetId(sheetKey);
|
|
276
|
-
this.hyperFormula.addColumns(sheetId, [ columnIndex, numberOfColumns ]);
|
|
277
|
-
} catch (error) {
|
|
278
|
-
throw new Error(`Failed to add ${numberOfColumns} columns at index ${columnIndex}`);
|
|
279
|
-
}
|
|
280
180
|
}
|
|
281
|
-
removeColumns(
|
|
181
|
+
removeColumns(_sheetKey, columnIndex, numberOfColumns = 1) {
|
|
282
182
|
this.ensureInitialized();
|
|
283
|
-
try {
|
|
284
|
-
const sheetId = this.getSheetId(sheetKey);
|
|
285
|
-
this.hyperFormula.removeColumns(sheetId, [ columnIndex, numberOfColumns ]);
|
|
286
|
-
} catch (error) {
|
|
287
|
-
throw new Error(`Failed to remove ${numberOfColumns} columns at index ${columnIndex}`);
|
|
288
|
-
}
|
|
289
183
|
}
|
|
290
184
|
getSheetSerialized(sheetKey) {
|
|
291
185
|
this.ensureInitialized();
|
|
292
186
|
try {
|
|
293
|
-
|
|
294
|
-
return this.hyperFormula.getSheetSerialized(sheetId);
|
|
187
|
+
return [ [] ];
|
|
295
188
|
} catch (error) {
|
|
296
189
|
return [ [] ];
|
|
297
190
|
}
|
|
298
191
|
}
|
|
299
|
-
|
|
300
|
-
this.ensureInitialized();
|
|
192
|
+
sortFormulasByDependency(sheetKey, formulas) {
|
|
301
193
|
try {
|
|
302
|
-
|
|
303
|
-
this.hyperFormula.setSheetContent(sheetId, normalizedData);
|
|
194
|
+
return this.formulaEngine.sortFormulasByDependency(sheetKey, formulas);
|
|
304
195
|
} catch (error) {
|
|
305
|
-
|
|
196
|
+
return Object.entries(formulas);
|
|
306
197
|
}
|
|
307
198
|
}
|
|
199
|
+
setSheetContent(sheetKey, _normalizedData) {
|
|
200
|
+
this.ensureInitialized();
|
|
201
|
+
}
|
|
308
202
|
hasCircularReference() {
|
|
309
203
|
try {
|
|
310
|
-
|
|
311
|
-
return stats && stats.dependencyGraph && stats.dependencyGraph.hasCircularReferences();
|
|
204
|
+
return !1;
|
|
312
205
|
} catch (error) {
|
|
313
206
|
return !1;
|
|
314
207
|
}
|
|
@@ -318,9 +211,7 @@ class FormulaManager {
|
|
|
318
211
|
}
|
|
319
212
|
validateFormula(formula) {
|
|
320
213
|
try {
|
|
321
|
-
return this.
|
|
322
|
-
isValid: !0
|
|
323
|
-
};
|
|
214
|
+
return this.formulaEngine.validateFormula(formula);
|
|
324
215
|
} catch (error) {
|
|
325
216
|
return {
|
|
326
217
|
isValid: !1,
|
|
@@ -348,11 +239,7 @@ class FormulaManager {
|
|
|
348
239
|
}
|
|
349
240
|
calculateFormula(formula) {
|
|
350
241
|
try {
|
|
351
|
-
|
|
352
|
-
return {
|
|
353
|
-
value: result,
|
|
354
|
-
error: result instanceof hyperformula_1.CellError ? result.message : void 0
|
|
355
|
-
};
|
|
242
|
+
return this.formulaEngine.calculateFormula(formula);
|
|
356
243
|
} catch (error) {
|
|
357
244
|
return {
|
|
358
245
|
value: null,
|
|
@@ -360,31 +247,19 @@ class FormulaManager {
|
|
|
360
247
|
};
|
|
361
248
|
}
|
|
362
249
|
}
|
|
363
|
-
suspendEvaluation() {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
} catch (error) {}
|
|
367
|
-
}
|
|
368
|
-
resumeEvaluation() {
|
|
369
|
-
try {
|
|
370
|
-
this.hyperFormula.resumeEvaluation();
|
|
371
|
-
} catch (error) {}
|
|
372
|
-
}
|
|
373
|
-
rebuildAndRecalculate() {
|
|
374
|
-
try {
|
|
375
|
-
this.hyperFormula.rebuildAndRecalculate();
|
|
376
|
-
} catch (error) {}
|
|
377
|
-
}
|
|
250
|
+
suspendEvaluation() {}
|
|
251
|
+
resumeEvaluation() {}
|
|
252
|
+
rebuildAndRecalculate() {}
|
|
378
253
|
clearContent() {
|
|
379
254
|
try {
|
|
380
|
-
this.release(), this.
|
|
255
|
+
this.release(), this.initializeFormulaEngine();
|
|
381
256
|
} catch (error) {}
|
|
382
257
|
}
|
|
383
258
|
release() {
|
|
384
259
|
var _a, _b;
|
|
385
260
|
null === (_a = this.formulaRangeSelector) || void 0 === _a || _a.release(), null === (_b = this.cellHighlightManager) || void 0 === _b || _b.release();
|
|
386
261
|
try {
|
|
387
|
-
this.
|
|
262
|
+
this.formulaEngine && this.formulaEngine.release();
|
|
388
263
|
} catch (error) {} finally {
|
|
389
264
|
this.sheetMapping.clear(), this.reverseSheetMapping.clear(), this.isInitialized = !1,
|
|
390
265
|
this.nextSheetId = 0, this.formulaRangeSelector = null, this.cellHighlightManager = null;
|
|
@@ -395,34 +270,46 @@ class FormulaManager {
|
|
|
395
270
|
isInitialized: this.isInitialized,
|
|
396
271
|
sheets: Array.from(this.sheetMapping.entries()),
|
|
397
272
|
functions: this.getAvailableFunctions(),
|
|
398
|
-
stats:
|
|
273
|
+
stats: null
|
|
399
274
|
};
|
|
400
275
|
}
|
|
276
|
+
exportFormulas(sheetKey) {
|
|
277
|
+
this.ensureInitialized();
|
|
278
|
+
try {
|
|
279
|
+
return this.formulaEngine.exportFormulas(sheetKey);
|
|
280
|
+
} catch (error) {
|
|
281
|
+
return {};
|
|
282
|
+
}
|
|
283
|
+
}
|
|
401
284
|
ensureInitialized() {
|
|
402
285
|
if (!this.isInitialized) throw new Error("FormulaManager not initialized");
|
|
403
286
|
}
|
|
404
287
|
getAllSheets() {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
288
|
+
try {
|
|
289
|
+
return this.formulaEngine.getAllSheets();
|
|
290
|
+
} catch (error) {
|
|
291
|
+
return [];
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
setActiveSheet(sheetKey) {
|
|
295
|
+
this.ensureInitialized();
|
|
296
|
+
try {
|
|
297
|
+
this.formulaEngine.setActiveSheet(sheetKey);
|
|
298
|
+
} catch (error) {
|
|
299
|
+
throw new Error(`Failed to set active sheet: ${sheetKey}`);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
getActiveSheet() {
|
|
303
|
+
this.ensureInitialized();
|
|
304
|
+
try {
|
|
305
|
+
return this.formulaEngine.getActiveSheet();
|
|
413
306
|
} catch (error) {
|
|
414
|
-
|
|
415
|
-
key: key,
|
|
416
|
-
id: id,
|
|
417
|
-
name: key
|
|
418
|
-
});
|
|
307
|
+
return null;
|
|
419
308
|
}
|
|
420
|
-
return sheets;
|
|
421
309
|
}
|
|
422
310
|
copyRange(sourceSheet, sourceRange, targetSheet, targetRow, targetCol) {
|
|
423
311
|
this.ensureInitialized();
|
|
424
312
|
try {
|
|
425
|
-
this.getSheetId(sourceSheet), this.getSheetId(targetSheet);
|
|
426
313
|
for (let row = sourceRange.startRow; row <= sourceRange.endRow; row++) for (let col = sourceRange.startCol; col <= sourceRange.endCol; col++) {
|
|
427
314
|
const sourceCell = {
|
|
428
315
|
sheet: sourceSheet,
|
|
@@ -441,4 +328,5 @@ class FormulaManager {
|
|
|
441
328
|
}
|
|
442
329
|
}
|
|
443
330
|
|
|
444
|
-
exports.FormulaManager = FormulaManager;
|
|
331
|
+
exports.FormulaManager = FormulaManager;
|
|
332
|
+
//# sourceMappingURL=formula-manager.js.map
|