@univerjs/engine-formula 1.0.0-rc.0 → 1.0.1
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/lib/cjs/{en-US-x6yRGjN6.js → en-US-DrAfIiBE.js} +0 -1
- package/lib/cjs/facade.js +6 -2
- package/lib/cjs/index.js +1195 -792
- package/lib/cjs/locale/ar-SA.js +0 -1
- package/lib/cjs/locale/ca-ES.js +0 -1
- package/lib/cjs/locale/de-DE.js +0 -1
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/es-ES.js +0 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +0 -1
- package/lib/cjs/locale/id-ID.js +0 -1
- package/lib/cjs/locale/it-IT.js +0 -1
- package/lib/cjs/locale/ja-JP.js +0 -1
- package/lib/cjs/locale/ko-KR.js +0 -1
- package/lib/cjs/locale/pl-PL.js +0 -1
- package/lib/cjs/locale/pt-BR.js +0 -1
- package/lib/cjs/locale/ru-RU.js +0 -1
- package/lib/cjs/locale/sk-SK.js +0 -1
- package/lib/cjs/locale/vi-VN.js +0 -1
- package/lib/cjs/locale/zh-CN.js +0 -1
- package/lib/cjs/locale/zh-HK.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/cjs/{zh-TW-vwS1qqtd.js → zh-TW-CvMudVQy.js} +0 -1
- package/lib/es/facade.js +6 -2
- package/lib/es/index.js +1194 -791
- package/lib/facade.js +6 -2
- package/lib/index.js +1194 -791
- package/lib/types/basics/common.d.ts +3 -1
- package/lib/types/basics/inverted-index-cache.d.ts +1 -0
- package/lib/types/basics/regex.d.ts +7 -7
- package/lib/types/basics/runtime.d.ts +11 -0
- package/lib/types/engine/ast-node/prefix-node.d.ts +4 -1
- package/lib/types/engine/ast-node/reference-node.d.ts +1 -1
- package/lib/types/engine/dependency/formula-dependency.d.ts +1 -1
- package/lib/types/engine/reference-object/table-reference-object.d.ts +1 -0
- package/lib/types/engine/utils/compare.d.ts +2 -1
- package/lib/types/engine/utils/object-compare.d.ts +1 -0
- package/lib/types/facade/f-formula.d.ts +4 -0
- package/lib/types/facade/f-univer.d.ts +9 -0
- package/lib/types/services/current-data.service.d.ts +1 -0
- package/lib/types/services/runtime.service.d.ts +3 -0
- package/lib/types/services/sheet-row-filtered.service.d.ts +5 -3
- package/lib/types/services/unit-reference-resolver.service.d.ts +3 -1
- package/lib/umd/index.js +4 -4
- package/package.json +6 -6
package/lib/cjs/index.js
CHANGED
|
@@ -20,7 +20,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
20
20
|
}
|
|
21
21
|
return to;
|
|
22
22
|
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
24
24
|
value: mod,
|
|
25
25
|
enumerable: true
|
|
26
26
|
}) : target, mod));
|
|
@@ -180,7 +180,185 @@ let FunctionType = /* @__PURE__ */ function(FunctionType) {
|
|
|
180
180
|
}({});
|
|
181
181
|
|
|
182
182
|
//#endregion
|
|
183
|
-
//#region
|
|
183
|
+
//#region src/basics/token.ts
|
|
184
|
+
/**
|
|
185
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
186
|
+
*
|
|
187
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
188
|
+
* you may not use this file except in compliance with the License.
|
|
189
|
+
* You may obtain a copy of the License at
|
|
190
|
+
*
|
|
191
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
192
|
+
*
|
|
193
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
194
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
195
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
196
|
+
* See the License for the specific language governing permissions and
|
|
197
|
+
* limitations under the License.
|
|
198
|
+
*/
|
|
199
|
+
let operatorToken = /* @__PURE__ */ function(operatorToken) {
|
|
200
|
+
operatorToken["PLUS"] = "+";
|
|
201
|
+
operatorToken["MINUS"] = "-";
|
|
202
|
+
operatorToken["MULTIPLY"] = "*";
|
|
203
|
+
operatorToken["DIVIDED"] = "/";
|
|
204
|
+
operatorToken["CONCATENATE"] = "&";
|
|
205
|
+
operatorToken["POWER"] = "^";
|
|
206
|
+
operatorToken["EQUALS"] = "=";
|
|
207
|
+
operatorToken["NOT_EQUAL"] = "<>";
|
|
208
|
+
operatorToken["GREATER_THAN"] = ">";
|
|
209
|
+
operatorToken["GREATER_THAN_OR_EQUAL"] = ">=";
|
|
210
|
+
operatorToken["LESS_THAN"] = "<";
|
|
211
|
+
operatorToken["LESS_THAN_OR_EQUAL"] = "<=";
|
|
212
|
+
return operatorToken;
|
|
213
|
+
}({});
|
|
214
|
+
let compareToken = /* @__PURE__ */ function(compareToken) {
|
|
215
|
+
compareToken["EQUALS"] = "=";
|
|
216
|
+
compareToken["NOT_EQUAL"] = "<>";
|
|
217
|
+
compareToken["GREATER_THAN"] = ">";
|
|
218
|
+
compareToken["GREATER_THAN_OR_EQUAL"] = ">=";
|
|
219
|
+
compareToken["LESS_THAN"] = "<";
|
|
220
|
+
compareToken["LESS_THAN_OR_EQUAL"] = "<=";
|
|
221
|
+
return compareToken;
|
|
222
|
+
}({});
|
|
223
|
+
const OPERATOR_TOKEN_PRIORITY = /* @__PURE__ */ new Map([
|
|
224
|
+
["<>", 4],
|
|
225
|
+
["<", 4],
|
|
226
|
+
[">=", 4],
|
|
227
|
+
["=", 4],
|
|
228
|
+
[">", 4],
|
|
229
|
+
["<=", 4],
|
|
230
|
+
["&", 3],
|
|
231
|
+
["+", 2],
|
|
232
|
+
["-", 2],
|
|
233
|
+
["/", 1],
|
|
234
|
+
["*", 1],
|
|
235
|
+
["^", 0]
|
|
236
|
+
]);
|
|
237
|
+
const OPERATOR_TOKEN_SET = new Set(OPERATOR_TOKEN_PRIORITY.keys());
|
|
238
|
+
const OPERATOR_TOKEN_COMPARE_SET = /* @__PURE__ */ new Set([
|
|
239
|
+
"=",
|
|
240
|
+
"<>",
|
|
241
|
+
">",
|
|
242
|
+
">=",
|
|
243
|
+
"<",
|
|
244
|
+
"<="
|
|
245
|
+
]);
|
|
246
|
+
let matchToken = /* @__PURE__ */ function(matchToken) {
|
|
247
|
+
matchToken["OPEN_BRACKET"] = "(";
|
|
248
|
+
matchToken["CLOSE_BRACKET"] = ")";
|
|
249
|
+
matchToken["COMMA"] = ",";
|
|
250
|
+
matchToken["SINGLE_QUOTATION"] = "'";
|
|
251
|
+
matchToken["DOUBLE_QUOTATION"] = "\"";
|
|
252
|
+
matchToken["OPEN_BRACES"] = "{";
|
|
253
|
+
matchToken["CLOSE_BRACES"] = "}";
|
|
254
|
+
matchToken["COLON"] = ":";
|
|
255
|
+
matchToken["OPEN_SQUARE_BRACKET"] = "[";
|
|
256
|
+
matchToken["CLOSE_SQUARE_BRACKET"] = "]";
|
|
257
|
+
return matchToken;
|
|
258
|
+
}({});
|
|
259
|
+
let suffixToken = /* @__PURE__ */ function(suffixToken) {
|
|
260
|
+
suffixToken["PERCENTAGE"] = "%";
|
|
261
|
+
suffixToken["POUND"] = "#";
|
|
262
|
+
return suffixToken;
|
|
263
|
+
}({});
|
|
264
|
+
const SUFFIX_TOKEN_SET = /* @__PURE__ */ new Set(["%", "#"]);
|
|
265
|
+
let prefixToken = /* @__PURE__ */ function(prefixToken) {
|
|
266
|
+
prefixToken["AT"] = "@";
|
|
267
|
+
prefixToken["MINUS"] = "-";
|
|
268
|
+
prefixToken["PLUS"] = "+";
|
|
269
|
+
return prefixToken;
|
|
270
|
+
}({});
|
|
271
|
+
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region src/engine/utils/compare.ts
|
|
274
|
+
function getCompare() {
|
|
275
|
+
if (Intl && Intl.Collator) return new Intl.Collator(void 0, { numeric: false }).compare;
|
|
276
|
+
return (a, b) => {
|
|
277
|
+
return a.localeCompare(b);
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function isWildcard(str) {
|
|
281
|
+
return str.indexOf("*") > -1 || str.indexOf("?") > -1;
|
|
282
|
+
}
|
|
283
|
+
const TEXT_LIGATURES = {
|
|
284
|
+
ß: "ss",
|
|
285
|
+
æ: "ae",
|
|
286
|
+
œ: "oe",
|
|
287
|
+
ff: "ff",
|
|
288
|
+
fi: "fi",
|
|
289
|
+
fl: "fl",
|
|
290
|
+
ffi: "ffi",
|
|
291
|
+
ffl: "ffl",
|
|
292
|
+
ſt: "st",
|
|
293
|
+
st: "st"
|
|
294
|
+
};
|
|
295
|
+
function normalizeTextForComparison(value) {
|
|
296
|
+
const lower = value.toLowerCase();
|
|
297
|
+
return /[\u0080-\uFFFF]/.test(lower) ? lower.normalize("NFC").replace(/[ßæœff-st]/g, (character) => TEXT_LIGATURES[character]) : lower;
|
|
298
|
+
}
|
|
299
|
+
function isMatchWildcard(currentValue, value) {
|
|
300
|
+
const pattern = escapeRegExpForWildcard(value).replace(/~?[*?]/g, (match) => {
|
|
301
|
+
if (match.startsWith("~")) return `\\${match.substring(1)}`;
|
|
302
|
+
if (match === "*") return ".*";
|
|
303
|
+
if (match === "?") return ".";
|
|
304
|
+
return match;
|
|
305
|
+
});
|
|
306
|
+
return new RegExp(`^${pattern}$`, "s").test(currentValue);
|
|
307
|
+
}
|
|
308
|
+
function replaceWildcard(value) {
|
|
309
|
+
return value.replace(/~?[*?]/g, (match) => {
|
|
310
|
+
if (match.startsWith("~")) return match.substring(1);
|
|
311
|
+
return " ";
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
function compareWithWildcard(currentValue, value, operator, isCaseSensitive = true) {
|
|
315
|
+
let currentText = currentValue;
|
|
316
|
+
let pattern = value;
|
|
317
|
+
if (!isCaseSensitive) {
|
|
318
|
+
const fold = (text) => {
|
|
319
|
+
if (!/[\u0080-\uFFFF]/.test(text)) return text.toLowerCase();
|
|
320
|
+
return text.replace(/[\s\S]/g, (character) => {
|
|
321
|
+
const lower = character.toLowerCase();
|
|
322
|
+
return lower.length === 1 ? lower : character;
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
currentText = fold(currentText);
|
|
326
|
+
pattern = fold(pattern);
|
|
327
|
+
}
|
|
328
|
+
let result = false;
|
|
329
|
+
switch (operator) {
|
|
330
|
+
case "=":
|
|
331
|
+
result = isMatchWildcard(currentText, pattern);
|
|
332
|
+
break;
|
|
333
|
+
case "<>":
|
|
334
|
+
result = !isMatchWildcard(currentText, pattern);
|
|
335
|
+
break;
|
|
336
|
+
case ">":
|
|
337
|
+
case ">=":
|
|
338
|
+
result = isMatchWildcard(currentText, pattern) || currentText > replaceWildcard(pattern);
|
|
339
|
+
break;
|
|
340
|
+
case "<":
|
|
341
|
+
case "<=": result = currentText < replaceWildcard(pattern);
|
|
342
|
+
}
|
|
343
|
+
return result;
|
|
344
|
+
}
|
|
345
|
+
function escapeRegExpForWildcard(str) {
|
|
346
|
+
return str.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
347
|
+
}
|
|
348
|
+
function getMatchModeValue(matchModeValue) {
|
|
349
|
+
switch (matchModeValue) {
|
|
350
|
+
case 1: return 2;
|
|
351
|
+
case 0: return 0;
|
|
352
|
+
case -1: return 1;
|
|
353
|
+
default: return 0;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
function getSearchModeValue(searchModeValue) {
|
|
357
|
+
return searchModeValue === -2 ? 1 : 0;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
//#endregion
|
|
361
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
184
362
|
function _typeof(o) {
|
|
185
363
|
"@babel/helpers - typeof";
|
|
186
364
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -191,7 +369,7 @@ function _typeof(o) {
|
|
|
191
369
|
}
|
|
192
370
|
|
|
193
371
|
//#endregion
|
|
194
|
-
//#region \0@oxc-project+runtime@0.
|
|
372
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
195
373
|
function toPrimitive(t, r) {
|
|
196
374
|
if ("object" != _typeof(t) || !t) return t;
|
|
197
375
|
var e = t[Symbol.toPrimitive];
|
|
@@ -204,14 +382,14 @@ function toPrimitive(t, r) {
|
|
|
204
382
|
}
|
|
205
383
|
|
|
206
384
|
//#endregion
|
|
207
|
-
//#region \0@oxc-project+runtime@0.
|
|
385
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
208
386
|
function toPropertyKey(t) {
|
|
209
387
|
var i = toPrimitive(t, "string");
|
|
210
388
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
211
389
|
}
|
|
212
390
|
|
|
213
391
|
//#endregion
|
|
214
|
-
//#region \0@oxc-project+runtime@0.
|
|
392
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
215
393
|
function _defineProperty(e, r, t) {
|
|
216
394
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
217
395
|
value: t,
|
|
@@ -229,8 +407,8 @@ function normalizeValue(value) {
|
|
|
229
407
|
if (normalizedValueMap.has(value)) return normalizedValueMap.get(value);
|
|
230
408
|
let _value;
|
|
231
409
|
if (value === null || value === void 0 || value === "") _value = DEFAULT_EMPTY_CELL_KEY;
|
|
232
|
-
else if ((0, _univerjs_core.isRealNum)(value) && Number(value).toString() === value.toString()) _value = Number(value) === 0 ? 0 : Number(value);
|
|
233
|
-
else if (typeof value === "string") _value = value
|
|
410
|
+
else if ((0, _univerjs_core.isRealNum)(value) && Number.isFinite(Number(value)) && Number(value).toString() === value.toString()) _value = Number(value) === 0 ? 0 : Number(value);
|
|
411
|
+
else if (typeof value === "string") _value = normalizeTextForComparison(value);
|
|
234
412
|
else _value = value;
|
|
235
413
|
normalizedValueMap.set(value, _value);
|
|
236
414
|
return _value;
|
|
@@ -238,9 +416,11 @@ function normalizeValue(value) {
|
|
|
238
416
|
var InvertedIndexCache = class {
|
|
239
417
|
constructor() {
|
|
240
418
|
_defineProperty(this, "_cache", /* @__PURE__ */ new Map());
|
|
419
|
+
_defineProperty(this, "_rowValues", /* @__PURE__ */ new WeakMap());
|
|
241
420
|
_defineProperty(this, "_continueBuildingCache", /* @__PURE__ */ new Map());
|
|
242
421
|
}
|
|
243
422
|
set(unitId, sheetId, column, value, row, isForceUpdate = false) {
|
|
423
|
+
var _rowIndex$values;
|
|
244
424
|
if (!this.shouldContinueBuildingCache(unitId, sheetId, column, row) && !isForceUpdate) return;
|
|
245
425
|
let unitMap = this._cache.get(unitId);
|
|
246
426
|
if (unitMap == null) {
|
|
@@ -257,10 +437,28 @@ var InvertedIndexCache = class {
|
|
|
257
437
|
columnMap = /* @__PURE__ */ new Map();
|
|
258
438
|
sheetMap.set(column, columnMap);
|
|
259
439
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
440
|
+
let rowIndex = this._rowValues.get(columnMap);
|
|
441
|
+
if (rowIndex == null) {
|
|
442
|
+
rowIndex = { lastRow: -1 };
|
|
443
|
+
this._rowValues.set(columnMap, rowIndex);
|
|
444
|
+
}
|
|
445
|
+
if (!rowIndex.values && (isForceUpdate || row <= rowIndex.lastRow)) {
|
|
446
|
+
if (columnMap.size <= 32) {
|
|
447
|
+
for (const [key, rows] of columnMap) if (rows.delete(row)) {
|
|
448
|
+
if (rows.size === 0) columnMap.delete(key);
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
451
|
+
} else {
|
|
452
|
+
rowIndex.values = /* @__PURE__ */ new Map();
|
|
453
|
+
for (const [key, rows] of columnMap) for (const indexedRow of rows) rowIndex.values.set(indexedRow, key);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
if (rowIndex.values) {
|
|
457
|
+
const oldValue = rowIndex.values.get(row);
|
|
458
|
+
if (oldValue !== void 0) {
|
|
459
|
+
const oldRows = columnMap.get(oldValue);
|
|
460
|
+
oldRows.delete(row);
|
|
461
|
+
if (oldRows.size === 0) columnMap.delete(oldValue);
|
|
264
462
|
}
|
|
265
463
|
}
|
|
266
464
|
const _value = normalizeValue(value);
|
|
@@ -270,6 +468,8 @@ var InvertedIndexCache = class {
|
|
|
270
468
|
columnMap.set(_value, cellList);
|
|
271
469
|
}
|
|
272
470
|
cellList.add(row);
|
|
471
|
+
(_rowIndex$values = rowIndex.values) === null || _rowIndex$values === void 0 || _rowIndex$values.set(row, _value);
|
|
472
|
+
rowIndex.lastRow = Math.max(rowIndex.lastRow, row);
|
|
273
473
|
}
|
|
274
474
|
getCellValuePositions(unitId, sheetId, column) {
|
|
275
475
|
var _this$_cache$get;
|
|
@@ -394,96 +594,6 @@ var InvertedIndexCache = class {
|
|
|
394
594
|
};
|
|
395
595
|
const CELL_INVERTED_INDEX_CACHE = new InvertedIndexCache();
|
|
396
596
|
|
|
397
|
-
//#endregion
|
|
398
|
-
//#region src/basics/token.ts
|
|
399
|
-
/**
|
|
400
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
401
|
-
*
|
|
402
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
403
|
-
* you may not use this file except in compliance with the License.
|
|
404
|
-
* You may obtain a copy of the License at
|
|
405
|
-
*
|
|
406
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
407
|
-
*
|
|
408
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
409
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
410
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
411
|
-
* See the License for the specific language governing permissions and
|
|
412
|
-
* limitations under the License.
|
|
413
|
-
*/
|
|
414
|
-
let operatorToken = /* @__PURE__ */ function(operatorToken) {
|
|
415
|
-
operatorToken["PLUS"] = "+";
|
|
416
|
-
operatorToken["MINUS"] = "-";
|
|
417
|
-
operatorToken["MULTIPLY"] = "*";
|
|
418
|
-
operatorToken["DIVIDED"] = "/";
|
|
419
|
-
operatorToken["CONCATENATE"] = "&";
|
|
420
|
-
operatorToken["POWER"] = "^";
|
|
421
|
-
operatorToken["EQUALS"] = "=";
|
|
422
|
-
operatorToken["NOT_EQUAL"] = "<>";
|
|
423
|
-
operatorToken["GREATER_THAN"] = ">";
|
|
424
|
-
operatorToken["GREATER_THAN_OR_EQUAL"] = ">=";
|
|
425
|
-
operatorToken["LESS_THAN"] = "<";
|
|
426
|
-
operatorToken["LESS_THAN_OR_EQUAL"] = "<=";
|
|
427
|
-
return operatorToken;
|
|
428
|
-
}({});
|
|
429
|
-
let compareToken = /* @__PURE__ */ function(compareToken) {
|
|
430
|
-
compareToken["EQUALS"] = "=";
|
|
431
|
-
compareToken["NOT_EQUAL"] = "<>";
|
|
432
|
-
compareToken["GREATER_THAN"] = ">";
|
|
433
|
-
compareToken["GREATER_THAN_OR_EQUAL"] = ">=";
|
|
434
|
-
compareToken["LESS_THAN"] = "<";
|
|
435
|
-
compareToken["LESS_THAN_OR_EQUAL"] = "<=";
|
|
436
|
-
return compareToken;
|
|
437
|
-
}({});
|
|
438
|
-
const OPERATOR_TOKEN_PRIORITY = /* @__PURE__ */ new Map([
|
|
439
|
-
["<>", 4],
|
|
440
|
-
["<", 4],
|
|
441
|
-
[">=", 4],
|
|
442
|
-
["=", 4],
|
|
443
|
-
[">", 4],
|
|
444
|
-
["<=", 4],
|
|
445
|
-
["&", 3],
|
|
446
|
-
["+", 2],
|
|
447
|
-
["-", 2],
|
|
448
|
-
["/", 1],
|
|
449
|
-
["*", 1],
|
|
450
|
-
["^", 0]
|
|
451
|
-
]);
|
|
452
|
-
const OPERATOR_TOKEN_SET = new Set(OPERATOR_TOKEN_PRIORITY.keys());
|
|
453
|
-
const OPERATOR_TOKEN_COMPARE_SET = /* @__PURE__ */ new Set([
|
|
454
|
-
"=",
|
|
455
|
-
"<>",
|
|
456
|
-
">",
|
|
457
|
-
">=",
|
|
458
|
-
"<",
|
|
459
|
-
"<="
|
|
460
|
-
]);
|
|
461
|
-
let matchToken = /* @__PURE__ */ function(matchToken) {
|
|
462
|
-
matchToken["OPEN_BRACKET"] = "(";
|
|
463
|
-
matchToken["CLOSE_BRACKET"] = ")";
|
|
464
|
-
matchToken["COMMA"] = ",";
|
|
465
|
-
matchToken["SINGLE_QUOTATION"] = "'";
|
|
466
|
-
matchToken["DOUBLE_QUOTATION"] = "\"";
|
|
467
|
-
matchToken["OPEN_BRACES"] = "{";
|
|
468
|
-
matchToken["CLOSE_BRACES"] = "}";
|
|
469
|
-
matchToken["COLON"] = ":";
|
|
470
|
-
matchToken["OPEN_SQUARE_BRACKET"] = "[";
|
|
471
|
-
matchToken["CLOSE_SQUARE_BRACKET"] = "]";
|
|
472
|
-
return matchToken;
|
|
473
|
-
}({});
|
|
474
|
-
let suffixToken = /* @__PURE__ */ function(suffixToken) {
|
|
475
|
-
suffixToken["PERCENTAGE"] = "%";
|
|
476
|
-
suffixToken["POUND"] = "#";
|
|
477
|
-
return suffixToken;
|
|
478
|
-
}({});
|
|
479
|
-
const SUFFIX_TOKEN_SET = /* @__PURE__ */ new Set(["%", "#"]);
|
|
480
|
-
let prefixToken = /* @__PURE__ */ function(prefixToken) {
|
|
481
|
-
prefixToken["AT"] = "@";
|
|
482
|
-
prefixToken["MINUS"] = "-";
|
|
483
|
-
prefixToken["PLUS"] = "+";
|
|
484
|
-
return prefixToken;
|
|
485
|
-
}({});
|
|
486
|
-
|
|
487
597
|
//#endregion
|
|
488
598
|
//#region src/basics/match-token.ts
|
|
489
599
|
/**
|
|
@@ -582,7 +692,7 @@ const ABSOLUTE_SYMBOL = "$";
|
|
|
582
692
|
const RANGE_SYMBOL = "\\s*?:\\s*?";
|
|
583
693
|
const COLUMN_REGEX = "[A-Za-z]+";
|
|
584
694
|
const ROW_REGEX = "[1-9][0-9]*";
|
|
585
|
-
const UNIT_NAME_SHEET_NAME_REGEX = `'?(${UNIT_NAME_REGEX})?(${SHEET_NAME_REGEX})?'?`;
|
|
695
|
+
const UNIT_NAME_SHEET_NAME_REGEX = `(?:'(?:[^'\\[]|'')*[\\\\/]|'?)(${UNIT_NAME_REGEX})?(${SHEET_NAME_REGEX})?'?`;
|
|
586
696
|
const SIMPLE_SINGLE_RANGE_REGEX = `\\${"$"}?${COLUMN_REGEX}\\${"$"}?${ROW_REGEX}`;
|
|
587
697
|
const REFERENCE_MULTIPLE_RANGE_REGEX = `^(${"@"})?${UNIT_NAME_SHEET_NAME_REGEX}${SIMPLE_SINGLE_RANGE_REGEX}${RANGE_SYMBOL}${SIMPLE_SINGLE_RANGE_REGEX}$`;
|
|
588
698
|
const REFERENCE_MULTIPLE_RANGE_REGEX_PRECOMPILING = new RegExp(REFERENCE_MULTIPLE_RANGE_REGEX);
|
|
@@ -665,11 +775,11 @@ function isReferenceString(refString) {
|
|
|
665
775
|
//#endregion
|
|
666
776
|
//#region src/basics/runtime.ts
|
|
667
777
|
function convertUnitDataToRuntime(unitData) {
|
|
668
|
-
const arrayFormulaCellData =
|
|
778
|
+
const arrayFormulaCellData = Object.create(null);
|
|
669
779
|
Object.keys(unitData).forEach((unitId) => {
|
|
670
780
|
const sheetData = unitData[unitId];
|
|
671
781
|
if (sheetData == null) return true;
|
|
672
|
-
if (arrayFormulaCellData[unitId] == null) arrayFormulaCellData[unitId] =
|
|
782
|
+
if (arrayFormulaCellData[unitId] == null) arrayFormulaCellData[unitId] = Object.create(null);
|
|
673
783
|
Object.keys(sheetData).forEach((sheetId) => {
|
|
674
784
|
const cellData = sheetData[sheetId];
|
|
675
785
|
arrayFormulaCellData[unitId][sheetId] = new _univerjs_core.ObjectMatrix(cellData);
|
|
@@ -678,16 +788,16 @@ function convertUnitDataToRuntime(unitData) {
|
|
|
678
788
|
return arrayFormulaCellData;
|
|
679
789
|
}
|
|
680
790
|
function convertRuntimeToUnitData(unitData) {
|
|
681
|
-
const unitPrimitiveData =
|
|
682
|
-
for (const unitId
|
|
791
|
+
const unitPrimitiveData = Object.create(null);
|
|
792
|
+
for (const unitId of Object.keys(unitData)) {
|
|
683
793
|
const sheetData = unitData[unitId];
|
|
684
794
|
if (sheetData == null) continue;
|
|
685
|
-
if (unitPrimitiveData[unitId] == null) unitPrimitiveData[unitId] =
|
|
686
|
-
for (const sheetId
|
|
795
|
+
if (unitPrimitiveData[unitId] == null) unitPrimitiveData[unitId] = Object.create(null);
|
|
796
|
+
for (const sheetId of Object.keys(sheetData)) {
|
|
687
797
|
const cellData = sheetData[sheetId];
|
|
688
|
-
const primitiveData =
|
|
798
|
+
const primitiveData = Object.create(null);
|
|
689
799
|
cellData.forValue((row, column, value) => {
|
|
690
|
-
if (primitiveData[row] === void 0) primitiveData[row] =
|
|
800
|
+
if (primitiveData[row] === void 0) primitiveData[row] = Object.create(null);
|
|
691
801
|
primitiveData[row][column] = value;
|
|
692
802
|
});
|
|
693
803
|
unitPrimitiveData[unitId][sheetId] = primitiveData;
|
|
@@ -695,6 +805,12 @@ function convertRuntimeToUnitData(unitData) {
|
|
|
695
805
|
}
|
|
696
806
|
return unitPrimitiveData;
|
|
697
807
|
}
|
|
808
|
+
/** Copy the unit and sheet dictionaries without retaining inherited identifier keys. */
|
|
809
|
+
function copyUnitData(data) {
|
|
810
|
+
const result = Object.create(null);
|
|
811
|
+
for (const unitId of Object.keys(data)) if (data[unitId] != null) result[unitId] = Object.assign(Object.create(null), data[unitId]);
|
|
812
|
+
return result;
|
|
813
|
+
}
|
|
698
814
|
|
|
699
815
|
//#endregion
|
|
700
816
|
//#region src/basics/token-type.ts
|
|
@@ -860,6 +976,8 @@ function handleRefStringInfo(refString) {
|
|
|
860
976
|
if (unitIdMatch != null) {
|
|
861
977
|
unitQualifier = unitIdMatch[0].trim();
|
|
862
978
|
unitQualifier = unquoteSheetName(unitQualifier.slice(1, unitQualifier.length - 1));
|
|
979
|
+
const pathPrefix = refString.slice(0, unitIdMatch.index);
|
|
980
|
+
if (pathPrefix.startsWith("'") && /[\\/]$/.test(pathPrefix)) refString = `'${refString.slice(unitIdMatch.index)}`;
|
|
863
981
|
refString = refString.replace(UNIT_NAME_REGEX_PRECOMPILING, "");
|
|
864
982
|
}
|
|
865
983
|
const sheetNameIndex = refString.indexOf("!");
|
|
@@ -1098,7 +1216,7 @@ function splitTableStructuredRef(ref) {
|
|
|
1098
1216
|
}
|
|
1099
1217
|
|
|
1100
1218
|
//#endregion
|
|
1101
|
-
//#region \0@oxc-project+runtime@0.
|
|
1219
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
1102
1220
|
function __decorateParam(paramIndex, decorator) {
|
|
1103
1221
|
return function(target, key) {
|
|
1104
1222
|
decorator(target, key, paramIndex);
|
|
@@ -1106,7 +1224,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
1106
1224
|
}
|
|
1107
1225
|
|
|
1108
1226
|
//#endregion
|
|
1109
|
-
//#region \0@oxc-project+runtime@0.
|
|
1227
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
1110
1228
|
function __decorate(decorators, target, key, desc) {
|
|
1111
1229
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1112
1230
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1120,8 +1238,8 @@ let DefinedNamesService = class DefinedNamesService extends _univerjs_core.Dispo
|
|
|
1120
1238
|
constructor(_univerInstanceService) {
|
|
1121
1239
|
super();
|
|
1122
1240
|
this._univerInstanceService = _univerInstanceService;
|
|
1123
|
-
_defineProperty(this, "_definedNameMap",
|
|
1124
|
-
_defineProperty(this, "_nameCacheMap",
|
|
1241
|
+
_defineProperty(this, "_definedNameMap", Object.create(null));
|
|
1242
|
+
_defineProperty(this, "_nameCacheMap", Object.create(null));
|
|
1125
1243
|
_defineProperty(this, "_definedNamesIsEmpty", true);
|
|
1126
1244
|
_defineProperty(this, "_update$", new rxjs.Subject());
|
|
1127
1245
|
_defineProperty(this, "update$", this._update$.asObservable());
|
|
@@ -1142,8 +1260,8 @@ let DefinedNamesService = class DefinedNamesService extends _univerjs_core.Dispo
|
|
|
1142
1260
|
}
|
|
1143
1261
|
dispose() {
|
|
1144
1262
|
super.dispose();
|
|
1145
|
-
this._definedNameMap =
|
|
1146
|
-
this._nameCacheMap =
|
|
1263
|
+
this._definedNameMap = Object.create(null);
|
|
1264
|
+
this._nameCacheMap = Object.create(null);
|
|
1147
1265
|
this._update$.complete();
|
|
1148
1266
|
this._currentRange$.complete();
|
|
1149
1267
|
this._focusRange$.complete();
|
|
@@ -1172,7 +1290,7 @@ let DefinedNamesService = class DefinedNamesService extends _univerjs_core.Dispo
|
|
|
1172
1290
|
return serializeRange(this._currentRange.range);
|
|
1173
1291
|
}
|
|
1174
1292
|
registerDefinedNames(unitId, params) {
|
|
1175
|
-
this._definedNameMap[unitId] = params;
|
|
1293
|
+
this._definedNameMap[unitId] = Object.assign(Object.create(null), params);
|
|
1176
1294
|
this._updateCache(unitId);
|
|
1177
1295
|
const definedNames = Object.values(params);
|
|
1178
1296
|
this._update({
|
|
@@ -1183,7 +1301,7 @@ let DefinedNamesService = class DefinedNamesService extends _univerjs_core.Dispo
|
|
|
1183
1301
|
if (definedNames.length > 0) this._definedNamesIsEmpty = false;
|
|
1184
1302
|
}
|
|
1185
1303
|
registerDefinedName(unitId, param) {
|
|
1186
|
-
if (this._definedNameMap[unitId] === void 0) this._definedNameMap[unitId] =
|
|
1304
|
+
if (this._definedNameMap[unitId] === void 0) this._definedNameMap[unitId] = Object.create(null);
|
|
1187
1305
|
this._definedNameMap[unitId][param.id] = param;
|
|
1188
1306
|
this._updateCache(unitId);
|
|
1189
1307
|
this._update({
|
|
@@ -1285,7 +1403,7 @@ let DefinedNamesService = class DefinedNamesService extends _univerjs_core.Dispo
|
|
|
1285
1403
|
delete this._nameCacheMap[unitId];
|
|
1286
1404
|
return;
|
|
1287
1405
|
}
|
|
1288
|
-
this._nameCacheMap[unitId] =
|
|
1406
|
+
this._nameCacheMap[unitId] = Object.create(null);
|
|
1289
1407
|
for (const item of Object.values(nameMap)) {
|
|
1290
1408
|
const normalizedName = item.name.toLowerCase();
|
|
1291
1409
|
if (item.localSheetId === "AllDefaultWorkbook" || item.localSheetId == null || this._nameCacheMap[unitId][normalizedName] == null) this._nameCacheMap[unitId][normalizedName] = item;
|
|
@@ -2749,8 +2867,10 @@ var LexerTreeBuilder = class extends _univerjs_core.Disposable {
|
|
|
2749
2867
|
*/
|
|
2750
2868
|
while (parent) {
|
|
2751
2869
|
const token = parent.getToken();
|
|
2752
|
-
if (token !== "P_1" && token !== ":" && parent.getStartIndex() !== -1 && token.toUpperCase() !== "LAMBDA")
|
|
2753
|
-
|
|
2870
|
+
if (token !== "P_1" && token !== ":" && parent.getStartIndex() !== -1 && token.toUpperCase() !== "LAMBDA") {
|
|
2871
|
+
if (lastBracketCount === 0) bracketCount += 1;
|
|
2872
|
+
else lastBracketCount--;
|
|
2873
|
+
}
|
|
2754
2874
|
parent = parent.getParent();
|
|
2755
2875
|
}
|
|
2756
2876
|
return bracketCount;
|
|
@@ -2777,12 +2897,13 @@ var LexerTreeBuilder = class extends _univerjs_core.Disposable {
|
|
|
2777
2897
|
const sequenceGrid = deserializeRangeWithSheetWithCache(token);
|
|
2778
2898
|
if (sequenceGrid == null) continue;
|
|
2779
2899
|
const { range, sheetName, unitId } = sequenceGrid;
|
|
2900
|
+
const newRange = {
|
|
2901
|
+
...range,
|
|
2902
|
+
startAbsoluteRefType,
|
|
2903
|
+
endAbsoluteRefType
|
|
2904
|
+
};
|
|
2780
2905
|
const newToken = serializeRangeToRefString({
|
|
2781
|
-
range:
|
|
2782
|
-
...range,
|
|
2783
|
-
startAbsoluteRefType,
|
|
2784
|
-
endAbsoluteRefType
|
|
2785
|
-
},
|
|
2906
|
+
range: newRange,
|
|
2786
2907
|
unitId,
|
|
2787
2908
|
sheetName: sheetName || currentSheetName
|
|
2788
2909
|
});
|
|
@@ -2811,6 +2932,13 @@ var LexerTreeBuilder = class extends _univerjs_core.Disposable {
|
|
|
2811
2932
|
const newSequenceNodes = [];
|
|
2812
2933
|
for (let i = 0, len = sequenceNodes.length; i < len; i++) {
|
|
2813
2934
|
const node = sequenceNodes[i];
|
|
2935
|
+
if (typeof node !== "string" && node.nodeType === 2) {
|
|
2936
|
+
newSequenceNodes.push({
|
|
2937
|
+
...node,
|
|
2938
|
+
token: `"${node.token.slice(1, -1).replace(/"/g, "\"\"")}"`
|
|
2939
|
+
});
|
|
2940
|
+
continue;
|
|
2941
|
+
}
|
|
2814
2942
|
if (typeof node === "string" || node.nodeType !== 4) {
|
|
2815
2943
|
newSequenceNodes.push(node);
|
|
2816
2944
|
continue;
|
|
@@ -3541,35 +3669,36 @@ var LexerTreeBuilder = class extends _univerjs_core.Disposable {
|
|
|
3541
3669
|
}
|
|
3542
3670
|
this._resetSegment();
|
|
3543
3671
|
continue;
|
|
3544
|
-
} else if (currentString === "(" && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose())
|
|
3545
|
-
if (this.
|
|
3546
|
-
this.
|
|
3672
|
+
} else if (currentString === "(" && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose()) {
|
|
3673
|
+
if (this._segmentCount() > 0 || this.isLambdaOpen()) {
|
|
3674
|
+
if (this.isLambdaClose()) {
|
|
3675
|
+
this._newAndPushCurrentLexerNode(this._segment, cur);
|
|
3676
|
+
this._resetSegment();
|
|
3677
|
+
}
|
|
3678
|
+
this._openBracket(1);
|
|
3679
|
+
this._closeLambda();
|
|
3680
|
+
const nextCurrentString = formulaChars[cur + 1];
|
|
3681
|
+
if (nextCurrentString && nextCurrentString === ")") {
|
|
3682
|
+
if (!this._setParentCurrentLexerNode() && cur !== charsCount - 1) return "#VALUE!";
|
|
3683
|
+
/**
|
|
3684
|
+
* https://github.com/dream-num/univer/issues/1769
|
|
3685
|
+
* Formula example: =IF(TODAY()>1,"TRUE", "FALSE")
|
|
3686
|
+
* Copy or auto-fill at complex formula get error formula offset
|
|
3687
|
+
*/
|
|
3688
|
+
this._addSequenceArray(sequenceArray, currentString, cur);
|
|
3689
|
+
cur++;
|
|
3690
|
+
this._addSequenceArray(sequenceArray, nextCurrentString, cur);
|
|
3691
|
+
cur++;
|
|
3692
|
+
this._closeBracket();
|
|
3693
|
+
continue;
|
|
3694
|
+
} else if (nextCurrentString) this._newAndPushCurrentLexerNode("P_1", cur);
|
|
3695
|
+
} else {
|
|
3696
|
+
this._pushNodeToChildren(currentString);
|
|
3697
|
+
this._openBracket(0);
|
|
3698
|
+
this._openBracketNormalIndex();
|
|
3547
3699
|
this._resetSegment();
|
|
3548
3700
|
}
|
|
3549
|
-
|
|
3550
|
-
this._closeLambda();
|
|
3551
|
-
const nextCurrentString = formulaChars[cur + 1];
|
|
3552
|
-
if (nextCurrentString && nextCurrentString === ")") {
|
|
3553
|
-
if (!this._setParentCurrentLexerNode() && cur !== charsCount - 1) return "#VALUE!";
|
|
3554
|
-
/**
|
|
3555
|
-
* https://github.com/dream-num/univer/issues/1769
|
|
3556
|
-
* Formula example: =IF(TODAY()>1,"TRUE", "FALSE")
|
|
3557
|
-
* Copy or auto-fill at complex formula get error formula offset
|
|
3558
|
-
*/
|
|
3559
|
-
this._addSequenceArray(sequenceArray, currentString, cur);
|
|
3560
|
-
cur++;
|
|
3561
|
-
this._addSequenceArray(sequenceArray, nextCurrentString, cur);
|
|
3562
|
-
cur++;
|
|
3563
|
-
this._closeBracket();
|
|
3564
|
-
continue;
|
|
3565
|
-
} else if (nextCurrentString) this._newAndPushCurrentLexerNode("P_1", cur);
|
|
3566
|
-
} else {
|
|
3567
|
-
this._pushNodeToChildren(currentString);
|
|
3568
|
-
this._openBracket(0);
|
|
3569
|
-
this._openBracketNormalIndex();
|
|
3570
|
-
this._resetSegment();
|
|
3571
|
-
}
|
|
3572
|
-
else if (currentString === ")" && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose()) {
|
|
3701
|
+
} else if (currentString === ")" && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose()) {
|
|
3573
3702
|
if (this._formulaErrorLastTokenCheck(formulaChars, cur - 1)) this._formalErrorOccurred();
|
|
3574
3703
|
this._pushNodeToChildren(this._segment);
|
|
3575
3704
|
this._resetSegment();
|
|
@@ -3760,17 +3889,19 @@ var LexerTreeBuilder = class extends _univerjs_core.Disposable {
|
|
|
3760
3889
|
this._resetSegment();
|
|
3761
3890
|
cur++;
|
|
3762
3891
|
continue;
|
|
3763
|
-
} else if (this._unexpectedEndingToken(prevString))
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3892
|
+
} else if (this._unexpectedEndingToken(prevString)) {
|
|
3893
|
+
if (nextString === "+") {
|
|
3894
|
+
this._pushSegment("-");
|
|
3895
|
+
this._addSequenceArray(sequenceArray, currentString, cur);
|
|
3896
|
+
this._addSequenceArray(sequenceArray, "+", cur + 1);
|
|
3897
|
+
cur += 2;
|
|
3898
|
+
continue;
|
|
3899
|
+
} else {
|
|
3900
|
+
this._pushSegment("-");
|
|
3901
|
+
this._addSequenceArray(sequenceArray, currentString, cur);
|
|
3902
|
+
cur++;
|
|
3903
|
+
continue;
|
|
3904
|
+
}
|
|
3774
3905
|
}
|
|
3775
3906
|
} else if (this._segment.length > 0 && this._isScientificNotation(formulaChars, cur, currentString)) {
|
|
3776
3907
|
this._pushSegment(currentString);
|
|
@@ -4040,7 +4171,8 @@ var LexerTreeBuilder = class extends _univerjs_core.Disposable {
|
|
|
4040
4171
|
if (curNodeType === 8) {
|
|
4041
4172
|
const refNode = itemChildren[0];
|
|
4042
4173
|
if (refNode instanceof LexerNode) {
|
|
4043
|
-
|
|
4174
|
+
const refString = refNode.getToken().trim();
|
|
4175
|
+
if (isReferenceString(refString)) continue;
|
|
4044
4176
|
item = refNode;
|
|
4045
4177
|
}
|
|
4046
4178
|
}
|
|
@@ -4073,7 +4205,8 @@ var LexerTreeBuilder = class extends _univerjs_core.Disposable {
|
|
|
4073
4205
|
}
|
|
4074
4206
|
_getTableNameFromStructuredRef(token, getTable) {
|
|
4075
4207
|
const { tableName } = splitTableStructuredRef(token);
|
|
4076
|
-
|
|
4208
|
+
const isExplicitStructuredReference = token.includes("[") && (regexTestReferenceTableAllColumn(token) || regexTestReferenceTableSingleColumn(token) || regexTestReferenceTableMultipleColumn(token) || regexTestReferenceTableTitleOnlyAnyHash(token));
|
|
4209
|
+
if (getTable(this._currentUnitId, tableName) || isExplicitStructuredReference) return tableName;
|
|
4077
4210
|
return null;
|
|
4078
4211
|
}
|
|
4079
4212
|
_handleLambdaForExprTree(firstChild, newNode, hasFunction, getDefinedNameName, getTable) {
|
|
@@ -4198,17 +4331,17 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4198
4331
|
super();
|
|
4199
4332
|
this._univerInstanceService = _univerInstanceService;
|
|
4200
4333
|
this._lexerTreeBuilder = _lexerTreeBuilder;
|
|
4201
|
-
_defineProperty(this, "_formulaIdMapData",
|
|
4202
|
-
_defineProperty(this, "_arrayFormulaRange",
|
|
4203
|
-
_defineProperty(this, "_arrayFormulaCellData",
|
|
4204
|
-
_defineProperty(this, "_unitImageFormulaData",
|
|
4334
|
+
_defineProperty(this, "_formulaIdMapData", Object.create(null));
|
|
4335
|
+
_defineProperty(this, "_arrayFormulaRange", Object.create(null));
|
|
4336
|
+
_defineProperty(this, "_arrayFormulaCellData", Object.create(null));
|
|
4337
|
+
_defineProperty(this, "_unitImageFormulaData", Object.create(null));
|
|
4205
4338
|
}
|
|
4206
4339
|
dispose() {
|
|
4207
4340
|
super.dispose();
|
|
4208
|
-
this._formulaIdMapData =
|
|
4209
|
-
this._arrayFormulaRange =
|
|
4210
|
-
this._arrayFormulaCellData =
|
|
4211
|
-
this._unitImageFormulaData =
|
|
4341
|
+
this._formulaIdMapData = Object.create(null);
|
|
4342
|
+
this._arrayFormulaRange = Object.create(null);
|
|
4343
|
+
this._arrayFormulaCellData = Object.create(null);
|
|
4344
|
+
this._unitImageFormulaData = Object.create(null);
|
|
4212
4345
|
}
|
|
4213
4346
|
clearPreviousArrayFormulaCellData(clearArrayFormulaCellData) {
|
|
4214
4347
|
Object.keys(clearArrayFormulaCellData).forEach((unitId) => {
|
|
@@ -4240,8 +4373,8 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4240
4373
|
Object.keys(unitData).forEach((unitId) => {
|
|
4241
4374
|
const sheetData = unitData[unitId];
|
|
4242
4375
|
if (sheetData == null) return true;
|
|
4243
|
-
if (this._arrayFormulaRange[unitId] == null) this._arrayFormulaRange[unitId] =
|
|
4244
|
-
if (this._arrayFormulaCellData[unitId] == null) this._arrayFormulaCellData[unitId] =
|
|
4376
|
+
if (this._arrayFormulaRange[unitId] == null) this._arrayFormulaRange[unitId] = Object.create(null);
|
|
4377
|
+
if (this._arrayFormulaCellData[unitId] == null) this._arrayFormulaCellData[unitId] = Object.create(null);
|
|
4245
4378
|
Object.keys(sheetData).forEach((sheetId) => {
|
|
4246
4379
|
var _this$_arrayFormulaRa2, _this$_arrayFormulaCe3;
|
|
4247
4380
|
const cellMatrixData = sheetData[sheetId];
|
|
@@ -4265,12 +4398,12 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4265
4398
|
});
|
|
4266
4399
|
}
|
|
4267
4400
|
getFormulaData() {
|
|
4268
|
-
const formulaData =
|
|
4401
|
+
const formulaData = Object.create(null);
|
|
4269
4402
|
const allSheets = this._univerInstanceService.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
4270
4403
|
for (let i = 0; i < allSheets.length; i++) {
|
|
4271
4404
|
const workbook = allSheets[i];
|
|
4272
4405
|
const unitId = workbook.getUnitId();
|
|
4273
|
-
formulaData[unitId] =
|
|
4406
|
+
formulaData[unitId] = Object.create(null);
|
|
4274
4407
|
const worksheets = workbook.getSheets();
|
|
4275
4408
|
for (let j = 0; j < worksheets.length; j++) {
|
|
4276
4409
|
const worksheet = worksheets[j];
|
|
@@ -4285,12 +4418,12 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4285
4418
|
const base = allBases[i];
|
|
4286
4419
|
const snapshot = base.getSnapshot();
|
|
4287
4420
|
const unitId = base.getUnitId();
|
|
4288
|
-
formulaData[unitId] =
|
|
4421
|
+
formulaData[unitId] = Object.create(null);
|
|
4289
4422
|
const tables = Object.values(snapshot.tables);
|
|
4290
4423
|
const formulaTableNames = (0, _univerjs_core.createBaseFormulaTableNameMap)(snapshot);
|
|
4291
4424
|
for (let j = 0; j < tables.length; j++) {
|
|
4292
4425
|
const table = tables[j];
|
|
4293
|
-
const tableFormulaData =
|
|
4426
|
+
const tableFormulaData = Object.create(null);
|
|
4294
4427
|
const normalizedFormulaByFieldId = /* @__PURE__ */ new Map();
|
|
4295
4428
|
const recordOrder = table.recordOrder;
|
|
4296
4429
|
if (!recordOrder) {
|
|
@@ -4312,7 +4445,7 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4312
4445
|
normalizedFormula = normalizeBaseFormulaForEngine(formula, table, snapshot, formulaTableNames);
|
|
4313
4446
|
normalizedFormulaByFieldId.set(field.id, normalizedFormula);
|
|
4314
4447
|
}
|
|
4315
|
-
tableFormulaData[row] ??=
|
|
4448
|
+
tableFormulaData[row] ??= Object.create(null);
|
|
4316
4449
|
tableFormulaData[row][col] = {
|
|
4317
4450
|
f: normalizedFormula,
|
|
4318
4451
|
si: field.id
|
|
@@ -4326,7 +4459,7 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4326
4459
|
}
|
|
4327
4460
|
initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix) {
|
|
4328
4461
|
const result = buildSheetFormulaData(formulaData, unitId, sheetId, cellMatrix);
|
|
4329
|
-
if (!this._formulaIdMapData[unitId]) this._formulaIdMapData[unitId] =
|
|
4462
|
+
if (!this._formulaIdMapData[unitId]) this._formulaIdMapData[unitId] = Object.create(null);
|
|
4330
4463
|
this._formulaIdMapData[unitId][sheetId] = result.formulaIdMap;
|
|
4331
4464
|
return result.formulaData;
|
|
4332
4465
|
}
|
|
@@ -4341,10 +4474,10 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4341
4474
|
if (Object.keys(unitFormulaIdMap).length === 0) delete this._formulaIdMapData[unitId];
|
|
4342
4475
|
}
|
|
4343
4476
|
getSheetFormulaData(unitId, sheetId) {
|
|
4344
|
-
const formulaData =
|
|
4477
|
+
const formulaData = Object.create(null);
|
|
4345
4478
|
const workbook = this._univerInstanceService.getUnit(unitId);
|
|
4346
4479
|
if (workbook == null) return {};
|
|
4347
|
-
formulaData[unitId] =
|
|
4480
|
+
formulaData[unitId] = Object.create(null);
|
|
4348
4481
|
const worksheet = workbook.getSheetBySheetId(sheetId);
|
|
4349
4482
|
if (worksheet == null) return {};
|
|
4350
4483
|
const cellMatrix = worksheet.getCellMatrix();
|
|
@@ -4356,25 +4489,25 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4356
4489
|
return this._arrayFormulaRange;
|
|
4357
4490
|
}
|
|
4358
4491
|
setArrayFormulaRange(value) {
|
|
4359
|
-
this._arrayFormulaRange = value;
|
|
4492
|
+
this._arrayFormulaRange = copyUnitData(value);
|
|
4360
4493
|
}
|
|
4361
4494
|
getArrayFormulaCellData() {
|
|
4362
4495
|
return this._arrayFormulaCellData;
|
|
4363
4496
|
}
|
|
4364
4497
|
setArrayFormulaCellData(value) {
|
|
4365
|
-
this._arrayFormulaCellData = value;
|
|
4498
|
+
this._arrayFormulaCellData = copyUnitData(value);
|
|
4366
4499
|
}
|
|
4367
4500
|
getUnitImageFormulaData() {
|
|
4368
4501
|
return this._unitImageFormulaData;
|
|
4369
4502
|
}
|
|
4370
4503
|
setUnitImageFormulaData(value) {
|
|
4371
|
-
this._unitImageFormulaData = value;
|
|
4504
|
+
this._unitImageFormulaData = copyUnitData(value);
|
|
4372
4505
|
}
|
|
4373
4506
|
mergeArrayFormulaRange(formulaData) {
|
|
4374
4507
|
Object.keys(formulaData).forEach((unitId) => {
|
|
4375
4508
|
const sheetData = formulaData[unitId];
|
|
4376
4509
|
if (sheetData == null) return true;
|
|
4377
|
-
if (!this._arrayFormulaRange[unitId]) this._arrayFormulaRange[unitId] =
|
|
4510
|
+
if (!this._arrayFormulaRange[unitId]) this._arrayFormulaRange[unitId] = Object.create(null);
|
|
4378
4511
|
Object.keys(sheetData).forEach((sheetId) => {
|
|
4379
4512
|
var _this$_arrayFormulaRa3;
|
|
4380
4513
|
const arrayFormula = new _univerjs_core.ObjectMatrix(sheetData[sheetId]);
|
|
@@ -4392,7 +4525,7 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4392
4525
|
const unitId = unitIds[i];
|
|
4393
4526
|
const sheetData = formulaData[unitId];
|
|
4394
4527
|
if (!sheetData) continue;
|
|
4395
|
-
if (!this._unitImageFormulaData[unitId]) this._unitImageFormulaData[unitId] =
|
|
4528
|
+
if (!this._unitImageFormulaData[unitId]) this._unitImageFormulaData[unitId] = Object.create(null);
|
|
4396
4529
|
const sheetIds = Object.keys(sheetData);
|
|
4397
4530
|
for (let j = 0; j < sheetIds.length; j++) {
|
|
4398
4531
|
const sheetId = sheetIds[j];
|
|
@@ -4417,10 +4550,10 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4417
4550
|
}
|
|
4418
4551
|
getCalculateData() {
|
|
4419
4552
|
const unitAllSheet = this._univerInstanceService.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
4420
|
-
const allUnitData =
|
|
4421
|
-
const unitStylesData =
|
|
4422
|
-
const unitSheetNameMap =
|
|
4423
|
-
const unitNameMap =
|
|
4553
|
+
const allUnitData = Object.create(null);
|
|
4554
|
+
const unitStylesData = Object.create(null);
|
|
4555
|
+
const unitSheetNameMap = Object.create(null);
|
|
4556
|
+
const unitNameMap = Object.create(null);
|
|
4424
4557
|
for (const workbook of unitAllSheet) {
|
|
4425
4558
|
const unitId = workbook.getUnitId();
|
|
4426
4559
|
unitNameMap[unitId] = {
|
|
@@ -4428,8 +4561,8 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4428
4561
|
unitType: _univerjs_core.UniverInstanceType.UNIVER_SHEET
|
|
4429
4562
|
};
|
|
4430
4563
|
const sheets = workbook.getSheets();
|
|
4431
|
-
const sheetData =
|
|
4432
|
-
const sheetNameMap =
|
|
4564
|
+
const sheetData = Object.create(null);
|
|
4565
|
+
const sheetNameMap = Object.create(null);
|
|
4433
4566
|
for (const sheet of sheets) {
|
|
4434
4567
|
const sheetId = sheet.getSheetId();
|
|
4435
4568
|
const sheetConfig = sheet.getConfig();
|
|
@@ -4456,8 +4589,8 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4456
4589
|
name: snapshot.name,
|
|
4457
4590
|
unitType: _univerjs_core.UniverInstanceType.UNIVER_BASE
|
|
4458
4591
|
};
|
|
4459
|
-
const baseData =
|
|
4460
|
-
const tableNameMap =
|
|
4592
|
+
const baseData = Object.create(null);
|
|
4593
|
+
const tableNameMap = Object.create(null);
|
|
4461
4594
|
const formulaTableNames = (0, _univerjs_core.createBaseFormulaTableNameMap)(snapshot);
|
|
4462
4595
|
for (const table of Object.values(snapshot.tables)) {
|
|
4463
4596
|
var _table$recordOrder;
|
|
@@ -4488,18 +4621,21 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4488
4621
|
*/
|
|
4489
4622
|
getHiddenRowsFiltered() {
|
|
4490
4623
|
const unitAllSheet = this._univerInstanceService.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
4491
|
-
const rowData =
|
|
4624
|
+
const rowData = Object.create(null);
|
|
4492
4625
|
for (const workbook of unitAllSheet) {
|
|
4493
4626
|
const unitId = workbook.getUnitId();
|
|
4494
4627
|
const sheets = workbook.getSheets();
|
|
4495
|
-
rowData[unitId] =
|
|
4628
|
+
rowData[unitId] = Object.create(null);
|
|
4496
4629
|
for (const sheet of sheets) {
|
|
4497
4630
|
const sheetId = sheet.getSheetId();
|
|
4498
|
-
rowData[unitId][sheetId] =
|
|
4631
|
+
rowData[unitId][sheetId] = Object.create(null);
|
|
4499
4632
|
const startRow = 0;
|
|
4500
4633
|
const endRow = sheet.getRowCount() - 1;
|
|
4501
|
-
const sheetRowData =
|
|
4502
|
-
for (let i = startRow; i <= endRow; i++) if (!sheet.getRowVisible(i)) sheetRowData[i] = {
|
|
4634
|
+
const sheetRowData = Object.create(null);
|
|
4635
|
+
for (let i = startRow; i <= endRow; i++) if (!sheet.getRowVisible(i)) sheetRowData[i] = {
|
|
4636
|
+
hd: _univerjs_core.BooleanNumber.TRUE,
|
|
4637
|
+
...sheet.getRowFiltered(i) ? { filtered: true } : {}
|
|
4638
|
+
};
|
|
4503
4639
|
rowData[unitId][sheetId] = sheetRowData;
|
|
4504
4640
|
}
|
|
4505
4641
|
}
|
|
@@ -4526,7 +4662,7 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4526
4662
|
}
|
|
4527
4663
|
});
|
|
4528
4664
|
if (affectedFormulaIds.size === 0) return newSheetFormulaDataMatrix.getMatrix();
|
|
4529
|
-
const formulaIdMap =
|
|
4665
|
+
const formulaIdMap = Object.create(null);
|
|
4530
4666
|
const sharedFormulaCellMatrix = new _univerjs_core.ObjectMatrix();
|
|
4531
4667
|
worksheetCellMatrix === null || worksheetCellMatrix === void 0 || worksheetCellMatrix.forValue((r, c, cell) => {
|
|
4532
4668
|
const formulaId = cell === null || cell === void 0 ? void 0 : cell.si;
|
|
@@ -4543,7 +4679,8 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4543
4679
|
const sheetFormulaDataMatrix = new _univerjs_core.ObjectMatrix(((_formulaData$unitId = formulaData[unitId]) === null || _formulaData$unitId === void 0 ? void 0 : _formulaData$unitId[sheetId]) ?? {});
|
|
4544
4680
|
cellMatrix.forValue((r, c, cell) => {
|
|
4545
4681
|
var _worksheetCellMatrix$;
|
|
4546
|
-
|
|
4682
|
+
const currentFormulaId = worksheetCellMatrix === null || worksheetCellMatrix === void 0 || (_worksheetCellMatrix$ = worksheetCellMatrix.getValue(r, c)) === null || _worksheetCellMatrix$ === void 0 ? void 0 : _worksheetCellMatrix$.si;
|
|
4683
|
+
if (!(0, _univerjs_core.isFormulaId)(currentFormulaId) && !(0, _univerjs_core.isFormulaId)(cell === null || cell === void 0 ? void 0 : cell.si)) return;
|
|
4547
4684
|
updateFormulaDataByCellValue(sheetFormulaDataMatrix, newSheetFormulaDataMatrix, formulaIdMap, deleteFormulaIdMap, r, c, cell);
|
|
4548
4685
|
});
|
|
4549
4686
|
this._rebindSharedFormulaData(sheetFormulaDataMatrix, newSheetFormulaDataMatrix, formulaIdMap, deleteFormulaIdMap);
|
|
@@ -4691,7 +4828,7 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4691
4828
|
if (!sheet) continue;
|
|
4692
4829
|
const sheetInstance = workbookInstance.getSheetBySheetId(sheetId);
|
|
4693
4830
|
if (!sheetInstance) continue;
|
|
4694
|
-
const columnRanges =
|
|
4831
|
+
const columnRanges = Object.create(null);
|
|
4695
4832
|
for (const rowStr of Object.keys(sheet)) {
|
|
4696
4833
|
const row = Number(rowStr);
|
|
4697
4834
|
for (const columnStr in sheet[row]) {
|
|
@@ -4749,8 +4886,8 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4749
4886
|
const { range } = deserializeRangeWithSheet(ref);
|
|
4750
4887
|
if (!Number.isFinite(range.startRow) || !Number.isFinite(range.startColumn) || !Number.isFinite(range.endRow) || !Number.isFinite(range.endColumn)) return true;
|
|
4751
4888
|
if (range.startRow === row && range.endRow === row && range.startColumn === column && range.endColumn === column && !isArrayConstantFormula(formula)) return true;
|
|
4752
|
-
if (!this._arrayFormulaRange[unitId]) this._arrayFormulaRange[unitId] =
|
|
4753
|
-
if (!this._arrayFormulaCellData[unitId]) this._arrayFormulaCellData[unitId] =
|
|
4889
|
+
if (!this._arrayFormulaRange[unitId]) this._arrayFormulaRange[unitId] = Object.create(null);
|
|
4890
|
+
if (!this._arrayFormulaCellData[unitId]) this._arrayFormulaCellData[unitId] = Object.create(null);
|
|
4754
4891
|
arrayFormulaRangeMatrix ??= new _univerjs_core.ObjectMatrix((_this$_arrayFormulaRa7 = this._arrayFormulaRange[unitId]) === null || _this$_arrayFormulaRa7 === void 0 ? void 0 : _this$_arrayFormulaRa7[sheetId]);
|
|
4755
4892
|
arrayFormulaCellDataMatrix ??= new _univerjs_core.ObjectMatrix((_this$_arrayFormulaCe5 = this._arrayFormulaCellData[unitId]) === null || _this$_arrayFormulaCe5 === void 0 ? void 0 : _this$_arrayFormulaCe5[sheetId]);
|
|
4756
4893
|
if (arrayFormulaRangeMatrix.getValue(row, column) == null) arrayFormulaRangeMatrix.setValue(row, column, range);
|
|
@@ -4766,10 +4903,16 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
4766
4903
|
};
|
|
4767
4904
|
FormulaDataModel = __decorate([__decorateParam(0, _univerjs_core.IUniverInstanceService), __decorateParam(1, (0, _univerjs_core.Inject)(LexerTreeBuilder))], FormulaDataModel);
|
|
4768
4905
|
function buildSheetFormulaData(formulaData, unitId, sheetId, cellMatrix) {
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4906
|
+
const unitData = Object.assign(Object.create(null), Object.prototype.hasOwnProperty.call(formulaData, unitId) ? formulaData[unitId] : void 0);
|
|
4907
|
+
Object.defineProperty(formulaData, unitId, {
|
|
4908
|
+
value: unitData,
|
|
4909
|
+
writable: true,
|
|
4910
|
+
configurable: true,
|
|
4911
|
+
enumerable: true
|
|
4912
|
+
});
|
|
4913
|
+
if (!unitData[sheetId]) unitData[sheetId] = Object.create(null);
|
|
4914
|
+
const formulaIdMap = Object.create(null);
|
|
4915
|
+
const sheetFormulaDataMatrix = new _univerjs_core.ObjectMatrix(unitData[sheetId]);
|
|
4773
4916
|
cellMatrix.forValue((r, c, cell) => {
|
|
4774
4917
|
const formulaString = (cell === null || cell === void 0 ? void 0 : cell.f) || "";
|
|
4775
4918
|
const formulaId = (cell === null || cell === void 0 ? void 0 : cell.si) || "";
|
|
@@ -5009,32 +5152,22 @@ function resolveBaseFormulaTable(tableName, currentTable, snapshot, formulaTable
|
|
|
5009
5152
|
|
|
5010
5153
|
//#endregion
|
|
5011
5154
|
//#region src/services/sheet-row-filtered.service.ts
|
|
5012
|
-
/**
|
|
5013
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
5014
|
-
*
|
|
5015
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5016
|
-
* you may not use this file except in compliance with the License.
|
|
5017
|
-
* You may obtain a copy of the License at
|
|
5018
|
-
*
|
|
5019
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
5020
|
-
*
|
|
5021
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
5022
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
5023
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5024
|
-
* See the License for the specific language governing permissions and
|
|
5025
|
-
* limitations under the License.
|
|
5026
|
-
*/
|
|
5027
5155
|
var SheetRowFilteredService = class extends _univerjs_core.Disposable {
|
|
5028
5156
|
constructor(..._args) {
|
|
5029
5157
|
super(..._args);
|
|
5030
|
-
_defineProperty(this, "
|
|
5158
|
+
_defineProperty(this, "_getRowFilteredCallbacks", /* @__PURE__ */ new Set());
|
|
5031
5159
|
}
|
|
5032
5160
|
register(callback) {
|
|
5033
|
-
this.
|
|
5161
|
+
this._getRowFilteredCallbacks.add(callback);
|
|
5162
|
+
return (0, _univerjs_core.toDisposable)(() => this._getRowFilteredCallbacks.delete(callback));
|
|
5034
5163
|
}
|
|
5035
5164
|
getRowFiltered(unitId, subUnitId, row) {
|
|
5036
|
-
|
|
5037
|
-
return
|
|
5165
|
+
for (const callback of this._getRowFilteredCallbacks) if (callback(unitId, subUnitId, row)) return true;
|
|
5166
|
+
return false;
|
|
5167
|
+
}
|
|
5168
|
+
dispose() {
|
|
5169
|
+
this._getRowFilteredCallbacks.clear();
|
|
5170
|
+
super.dispose();
|
|
5038
5171
|
}
|
|
5039
5172
|
};
|
|
5040
5173
|
const ISheetRowFilteredService = (0, _univerjs_core.createIdentifier)("univer.formula.sheet-row-filtered.service");
|
|
@@ -5048,47 +5181,49 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends _uni
|
|
|
5048
5181
|
this._localeService = _localeService;
|
|
5049
5182
|
this._formulaDataModel = _formulaDataModel;
|
|
5050
5183
|
this._sheetRowFilteredService = _sheetRowFilteredService;
|
|
5051
|
-
_defineProperty(this, "_unitData",
|
|
5052
|
-
_defineProperty(this, "_unitStylesData",
|
|
5053
|
-
_defineProperty(this, "_arrayFormulaCellData",
|
|
5054
|
-
_defineProperty(this, "_arrayFormulaRange",
|
|
5055
|
-
_defineProperty(this, "_formulaData",
|
|
5056
|
-
_defineProperty(this, "_sheetNameMap",
|
|
5057
|
-
_defineProperty(this, "_unitNameMap",
|
|
5058
|
-
_defineProperty(this, "_externalReferences",
|
|
5184
|
+
_defineProperty(this, "_unitData", Object.create(null));
|
|
5185
|
+
_defineProperty(this, "_unitStylesData", Object.create(null));
|
|
5186
|
+
_defineProperty(this, "_arrayFormulaCellData", Object.create(null));
|
|
5187
|
+
_defineProperty(this, "_arrayFormulaRange", Object.create(null));
|
|
5188
|
+
_defineProperty(this, "_formulaData", Object.create(null));
|
|
5189
|
+
_defineProperty(this, "_sheetNameMap", Object.create(null));
|
|
5190
|
+
_defineProperty(this, "_unitNameMap", Object.create(null));
|
|
5191
|
+
_defineProperty(this, "_externalReferences", Object.create(null));
|
|
5192
|
+
_defineProperty(this, "_calculationRowData", Object.create(null));
|
|
5059
5193
|
_defineProperty(this, "_calculationGeneration", 0);
|
|
5060
5194
|
_defineProperty(this, "_forceCalculate", false);
|
|
5061
|
-
_defineProperty(this, "_clearDependencyTreeCache",
|
|
5195
|
+
_defineProperty(this, "_clearDependencyTreeCache", Object.create(null));
|
|
5062
5196
|
_defineProperty(this, "_dirtyRanges", []);
|
|
5063
|
-
_defineProperty(this, "_dirtyNameMap",
|
|
5064
|
-
_defineProperty(this, "_dirtyDefinedNameMap",
|
|
5065
|
-
_defineProperty(this, "_dirtySuperTableMap",
|
|
5066
|
-
_defineProperty(this, "_dirtyUnitFeatureMap",
|
|
5067
|
-
_defineProperty(this, "_dirtyUnitOtherFormulaMap",
|
|
5197
|
+
_defineProperty(this, "_dirtyNameMap", Object.create(null));
|
|
5198
|
+
_defineProperty(this, "_dirtyDefinedNameMap", Object.create(null));
|
|
5199
|
+
_defineProperty(this, "_dirtySuperTableMap", Object.create(null));
|
|
5200
|
+
_defineProperty(this, "_dirtyUnitFeatureMap", Object.create(null));
|
|
5201
|
+
_defineProperty(this, "_dirtyUnitOtherFormulaMap", Object.create(null));
|
|
5068
5202
|
_defineProperty(this, "_excludedCell", void 0);
|
|
5069
|
-
_defineProperty(this, "_sheetIdToNameMap",
|
|
5203
|
+
_defineProperty(this, "_sheetIdToNameMap", Object.create(null));
|
|
5070
5204
|
_defineProperty(this, "_executeUnitId", "");
|
|
5071
5205
|
_defineProperty(this, "_executeSubUnitId", "");
|
|
5072
5206
|
}
|
|
5073
5207
|
dispose() {
|
|
5074
5208
|
super.dispose();
|
|
5075
|
-
this._unitData =
|
|
5076
|
-
this._unitStylesData =
|
|
5077
|
-
this._arrayFormulaCellData =
|
|
5078
|
-
this._arrayFormulaRange =
|
|
5079
|
-
this._formulaData =
|
|
5080
|
-
this._sheetNameMap =
|
|
5081
|
-
this._unitNameMap =
|
|
5082
|
-
this._externalReferences =
|
|
5083
|
-
this.
|
|
5209
|
+
this._unitData = Object.create(null);
|
|
5210
|
+
this._unitStylesData = Object.create(null);
|
|
5211
|
+
this._arrayFormulaCellData = Object.create(null);
|
|
5212
|
+
this._arrayFormulaRange = Object.create(null);
|
|
5213
|
+
this._formulaData = Object.create(null);
|
|
5214
|
+
this._sheetNameMap = Object.create(null);
|
|
5215
|
+
this._unitNameMap = Object.create(null);
|
|
5216
|
+
this._externalReferences = Object.create(null);
|
|
5217
|
+
this._calculationRowData = Object.create(null);
|
|
5218
|
+
this._clearDependencyTreeCache = Object.create(null);
|
|
5084
5219
|
this._dirtyRanges = [];
|
|
5085
|
-
this._dirtyNameMap =
|
|
5086
|
-
this._dirtyDefinedNameMap =
|
|
5087
|
-
this._dirtySuperTableMap =
|
|
5088
|
-
this._dirtyUnitFeatureMap =
|
|
5089
|
-
this._dirtyUnitOtherFormulaMap =
|
|
5090
|
-
this._excludedCell =
|
|
5091
|
-
this._sheetIdToNameMap =
|
|
5220
|
+
this._dirtyNameMap = Object.create(null);
|
|
5221
|
+
this._dirtyDefinedNameMap = Object.create(null);
|
|
5222
|
+
this._dirtySuperTableMap = Object.create(null);
|
|
5223
|
+
this._dirtyUnitFeatureMap = Object.create(null);
|
|
5224
|
+
this._dirtyUnitOtherFormulaMap = Object.create(null);
|
|
5225
|
+
this._excludedCell = Object.create(null);
|
|
5226
|
+
this._sheetIdToNameMap = Object.create(null);
|
|
5092
5227
|
}
|
|
5093
5228
|
getExecuteUnitId() {
|
|
5094
5229
|
return this._executeUnitId;
|
|
@@ -5158,7 +5293,7 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends _uni
|
|
|
5158
5293
|
return this._sheetIdToNameMap[unitId][sheetId] || "";
|
|
5159
5294
|
}
|
|
5160
5295
|
setSheetNameMap(sheetIdToNameMap) {
|
|
5161
|
-
this._sheetIdToNameMap = sheetIdToNameMap;
|
|
5296
|
+
this._sheetIdToNameMap = copyUnitData(sheetIdToNameMap);
|
|
5162
5297
|
}
|
|
5163
5298
|
getClearDependencyTreeCache() {
|
|
5164
5299
|
return this._clearDependencyTreeCache;
|
|
@@ -5203,21 +5338,25 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends _uni
|
|
|
5203
5338
|
}
|
|
5204
5339
|
getFilteredOutRows(unitId, sheetId, startRow, endRow) {
|
|
5205
5340
|
const filteredOutRows = [];
|
|
5206
|
-
for (let r = startRow; r <= endRow; r++)
|
|
5341
|
+
for (let r = startRow; r <= endRow; r++) {
|
|
5342
|
+
var _this$_calculationRow;
|
|
5343
|
+
if (((_this$_calculationRow = this._calculationRowData[unitId]) === null || _this$_calculationRow === void 0 || (_this$_calculationRow = _this$_calculationRow[sheetId]) === null || _this$_calculationRow === void 0 || (_this$_calculationRow = _this$_calculationRow[r]) === null || _this$_calculationRow === void 0 ? void 0 : _this$_calculationRow.filtered) || this._sheetRowFilteredService.getRowFiltered(unitId, sheetId, r)) filteredOutRows.push(r);
|
|
5344
|
+
}
|
|
5207
5345
|
return filteredOutRows;
|
|
5208
5346
|
}
|
|
5209
5347
|
load(config) {
|
|
5210
5348
|
this._calculationGeneration++;
|
|
5349
|
+
this._calculationRowData = Object.create(null);
|
|
5211
5350
|
if (config.allUnitData && config.unitSheetNameMap && config.unitStylesData) {
|
|
5212
|
-
this._unitData = config.allUnitData;
|
|
5351
|
+
this._unitData = copyUnitData(config.allUnitData);
|
|
5213
5352
|
this._unitStylesData = config.unitStylesData;
|
|
5214
|
-
this._sheetNameMap = config.unitSheetNameMap;
|
|
5353
|
+
this._sheetNameMap = copyUnitData(config.unitSheetNameMap);
|
|
5215
5354
|
this._unitNameMap = config.unitNameMap || {};
|
|
5216
5355
|
} else {
|
|
5217
5356
|
const { allUnitData, unitNameMap, unitSheetNameMap, unitStylesData } = this._loadSheetData();
|
|
5218
|
-
this._unitData = allUnitData;
|
|
5357
|
+
this._unitData = copyUnitData(allUnitData);
|
|
5219
5358
|
this._unitStylesData = unitStylesData;
|
|
5220
|
-
this._sheetNameMap = unitSheetNameMap;
|
|
5359
|
+
this._sheetNameMap = copyUnitData(unitSheetNameMap);
|
|
5221
5360
|
this._unitNameMap = unitNameMap;
|
|
5222
5361
|
}
|
|
5223
5362
|
if (config.rowData) this._applyUnitRowData(config.rowData);
|
|
@@ -5238,9 +5377,9 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends _uni
|
|
|
5238
5377
|
}
|
|
5239
5378
|
loadDataLite(rowData) {
|
|
5240
5379
|
const { allUnitData, unitNameMap, unitSheetNameMap, unitStylesData } = this._loadSheetData();
|
|
5241
|
-
this._unitData = allUnitData;
|
|
5380
|
+
this._unitData = copyUnitData(allUnitData);
|
|
5242
5381
|
this._unitStylesData = unitStylesData;
|
|
5243
|
-
this._sheetNameMap = unitSheetNameMap;
|
|
5382
|
+
this._sheetNameMap = copyUnitData(unitSheetNameMap);
|
|
5244
5383
|
this._unitNameMap = unitNameMap;
|
|
5245
5384
|
this._formulaData = this._formulaDataModel.getFormulaData();
|
|
5246
5385
|
this._arrayFormulaCellData = convertUnitDataToRuntime(this._formulaDataModel.getArrayFormulaCellData());
|
|
@@ -5266,16 +5405,16 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends _uni
|
|
|
5266
5405
|
/**
|
|
5267
5406
|
* Mark dirty for expansion of array formulas, need to clear the worksheet's dirty flag.
|
|
5268
5407
|
*/
|
|
5269
|
-
this._dirtyNameMap =
|
|
5408
|
+
this._dirtyNameMap = Object.create(null);
|
|
5270
5409
|
}
|
|
5271
5410
|
registerUnitData(unitData) {
|
|
5272
|
-
this._unitData = unitData;
|
|
5411
|
+
this._unitData = copyUnitData(unitData);
|
|
5273
5412
|
}
|
|
5274
5413
|
registerFormulaData(formulaData) {
|
|
5275
5414
|
this._formulaData = formulaData;
|
|
5276
5415
|
}
|
|
5277
5416
|
registerSheetNameMap(sheetNameMap) {
|
|
5278
|
-
this._sheetNameMap = sheetNameMap;
|
|
5417
|
+
this._sheetNameMap = copyUnitData(sheetNameMap);
|
|
5279
5418
|
}
|
|
5280
5419
|
registerUnitNameMap(unitNameMap) {
|
|
5281
5420
|
this._unitNameMap = unitNameMap;
|
|
@@ -5283,14 +5422,14 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends _uni
|
|
|
5283
5422
|
_mergeNameMap(unitSheetNameMap, dirtyNameMap) {
|
|
5284
5423
|
Object.keys(dirtyNameMap).forEach((unitId) => {
|
|
5285
5424
|
if (dirtyNameMap[unitId]) Object.keys(dirtyNameMap[unitId]).forEach((sheetId) => {
|
|
5286
|
-
if (unitSheetNameMap[unitId] == null) unitSheetNameMap[unitId] =
|
|
5425
|
+
if (unitSheetNameMap[unitId] == null) unitSheetNameMap[unitId] = Object.create(null);
|
|
5287
5426
|
unitSheetNameMap[unitId][dirtyNameMap[unitId][sheetId]] = sheetId;
|
|
5288
5427
|
});
|
|
5289
5428
|
});
|
|
5290
|
-
this._sheetIdToNameMap =
|
|
5429
|
+
this._sheetIdToNameMap = Object.create(null);
|
|
5291
5430
|
Object.keys(unitSheetNameMap).forEach((unitId) => {
|
|
5292
5431
|
Object.keys(unitSheetNameMap[unitId]).forEach((sheetName) => {
|
|
5293
|
-
if (this._sheetIdToNameMap[unitId] == null) this._sheetIdToNameMap[unitId] =
|
|
5432
|
+
if (this._sheetIdToNameMap[unitId] == null) this._sheetIdToNameMap[unitId] = Object.create(null);
|
|
5294
5433
|
this._sheetIdToNameMap[unitId][unitSheetNameMap[unitId][sheetName]] = sheetName;
|
|
5295
5434
|
});
|
|
5296
5435
|
});
|
|
@@ -5309,11 +5448,12 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends _uni
|
|
|
5309
5448
|
* @param rowData
|
|
5310
5449
|
*/
|
|
5311
5450
|
_applyUnitRowData(rowData) {
|
|
5312
|
-
|
|
5451
|
+
this._calculationRowData = rowData;
|
|
5452
|
+
for (const unitId of Object.keys(rowData)) {
|
|
5313
5453
|
if (rowData[unitId] == null) continue;
|
|
5314
|
-
for (const sheetId
|
|
5454
|
+
for (const sheetId of Object.keys(rowData[unitId])) {
|
|
5315
5455
|
if (rowData[unitId][sheetId] == null) continue;
|
|
5316
|
-
if (this._unitData[unitId] == null) this._unitData[unitId] =
|
|
5456
|
+
if (this._unitData[unitId] == null) this._unitData[unitId] = Object.create(null);
|
|
5317
5457
|
if (this._unitData[unitId][sheetId] == null) this._unitData[unitId][sheetId] = {
|
|
5318
5458
|
cellData: new _univerjs_core.ObjectMatrix({}),
|
|
5319
5459
|
rowCount: 0,
|
|
@@ -5597,9 +5737,10 @@ var BaseValueObject = class extends ObjectClassType {
|
|
|
5597
5737
|
}
|
|
5598
5738
|
concatenate(value, concatenateType = 0) {
|
|
5599
5739
|
let currentValue = formatValueForFormulaText(this.getValue());
|
|
5600
|
-
if (typeof value === "string")
|
|
5601
|
-
|
|
5602
|
-
|
|
5740
|
+
if (typeof value === "string") {
|
|
5741
|
+
if (concatenateType === 0) currentValue = value + currentValue;
|
|
5742
|
+
else currentValue += value;
|
|
5743
|
+
} else if (typeof value === "number") {
|
|
5603
5744
|
const numberString = formatNumberForFormulaText(value);
|
|
5604
5745
|
if (concatenateType === 0) currentValue = numberString + currentValue;
|
|
5605
5746
|
else currentValue += numberString;
|
|
@@ -6193,68 +6334,6 @@ function getRuntimeFeatureCell(row, column, sheetId, unitId, runtimeFeatureCellD
|
|
|
6193
6334
|
}
|
|
6194
6335
|
}
|
|
6195
6336
|
|
|
6196
|
-
//#endregion
|
|
6197
|
-
//#region src/engine/utils/compare.ts
|
|
6198
|
-
function getCompare() {
|
|
6199
|
-
if (Intl && Intl.Collator) return new Intl.Collator(void 0, { numeric: false }).compare;
|
|
6200
|
-
return (a, b) => {
|
|
6201
|
-
return a.localeCompare(b);
|
|
6202
|
-
};
|
|
6203
|
-
}
|
|
6204
|
-
function isWildcard(str) {
|
|
6205
|
-
return str.indexOf("*") > -1 || str.indexOf("?") > -1;
|
|
6206
|
-
}
|
|
6207
|
-
function isMatchWildcard(currentValue, value) {
|
|
6208
|
-
const pattern = escapeRegExpForWildcard(value).replace(/~?[*?]/g, (match) => {
|
|
6209
|
-
if (match.startsWith("~")) return `\\${match.substring(1)}`;
|
|
6210
|
-
if (match === "*") return ".*";
|
|
6211
|
-
if (match === "?") return ".";
|
|
6212
|
-
return match;
|
|
6213
|
-
});
|
|
6214
|
-
return new RegExp(`^${pattern}$`).test(currentValue);
|
|
6215
|
-
}
|
|
6216
|
-
function replaceWildcard(value) {
|
|
6217
|
-
return value.replace(/~?[*?]/g, (match) => {
|
|
6218
|
-
if (match.startsWith("~")) return match.substring(1);
|
|
6219
|
-
return " ";
|
|
6220
|
-
});
|
|
6221
|
-
}
|
|
6222
|
-
function compareWithWildcard(currentValue, value, operator) {
|
|
6223
|
-
let result = false;
|
|
6224
|
-
switch (operator) {
|
|
6225
|
-
case "=":
|
|
6226
|
-
result = isMatchWildcard(currentValue, value);
|
|
6227
|
-
break;
|
|
6228
|
-
case "<>":
|
|
6229
|
-
result = !isMatchWildcard(currentValue, value);
|
|
6230
|
-
break;
|
|
6231
|
-
case ">":
|
|
6232
|
-
case ">=":
|
|
6233
|
-
result = isMatchWildcard(currentValue, value) || currentValue > replaceWildcard(value);
|
|
6234
|
-
break;
|
|
6235
|
-
case "<":
|
|
6236
|
-
case "<=":
|
|
6237
|
-
result = currentValue < replaceWildcard(value);
|
|
6238
|
-
break;
|
|
6239
|
-
default: break;
|
|
6240
|
-
}
|
|
6241
|
-
return result;
|
|
6242
|
-
}
|
|
6243
|
-
function escapeRegExpForWildcard(str) {
|
|
6244
|
-
return str.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
6245
|
-
}
|
|
6246
|
-
function getMatchModeValue(matchModeValue) {
|
|
6247
|
-
switch (matchModeValue) {
|
|
6248
|
-
case 1: return 2;
|
|
6249
|
-
case 0: return 0;
|
|
6250
|
-
case -1: return 1;
|
|
6251
|
-
default: return 0;
|
|
6252
|
-
}
|
|
6253
|
-
}
|
|
6254
|
-
function getSearchModeValue(searchModeValue) {
|
|
6255
|
-
return searchModeValue === -2 ? 1 : 0;
|
|
6256
|
-
}
|
|
6257
|
-
|
|
6258
6337
|
//#endregion
|
|
6259
6338
|
//#region src/engine/utils/numfmt-kit.ts
|
|
6260
6339
|
/**
|
|
@@ -6377,9 +6456,7 @@ function reverseCompareOperator(operator) {
|
|
|
6377
6456
|
case "<=":
|
|
6378
6457
|
result = ">=";
|
|
6379
6458
|
break;
|
|
6380
|
-
case "<>":
|
|
6381
|
-
result = "<>";
|
|
6382
|
-
break;
|
|
6459
|
+
case "<>": result = "<>";
|
|
6383
6460
|
}
|
|
6384
6461
|
return result;
|
|
6385
6462
|
}
|
|
@@ -6597,6 +6674,39 @@ function getFractionalPart(num) {
|
|
|
6597
6674
|
* See the License for the specific language governing permissions and
|
|
6598
6675
|
* limitations under the License.
|
|
6599
6676
|
*/
|
|
6677
|
+
function parseCompactEnglishMonthYear(rawValue, dateSystem) {
|
|
6678
|
+
const match = rawValue.trim().match(/^([A-Za-z]{3,9})(\d{4})$/);
|
|
6679
|
+
if (!match) return null;
|
|
6680
|
+
const month = {
|
|
6681
|
+
jan: 0,
|
|
6682
|
+
january: 0,
|
|
6683
|
+
feb: 1,
|
|
6684
|
+
february: 1,
|
|
6685
|
+
mar: 2,
|
|
6686
|
+
march: 2,
|
|
6687
|
+
apr: 3,
|
|
6688
|
+
april: 3,
|
|
6689
|
+
may: 4,
|
|
6690
|
+
jun: 5,
|
|
6691
|
+
june: 5,
|
|
6692
|
+
jul: 6,
|
|
6693
|
+
july: 6,
|
|
6694
|
+
aug: 7,
|
|
6695
|
+
august: 7,
|
|
6696
|
+
sep: 8,
|
|
6697
|
+
sept: 8,
|
|
6698
|
+
september: 8,
|
|
6699
|
+
oct: 9,
|
|
6700
|
+
october: 9,
|
|
6701
|
+
nov: 10,
|
|
6702
|
+
november: 10,
|
|
6703
|
+
dec: 11,
|
|
6704
|
+
december: 11
|
|
6705
|
+
}[match[1].toLowerCase()];
|
|
6706
|
+
const year = Number(match[2]);
|
|
6707
|
+
if (month === void 0 || year < 1900 || year > 9999) return null;
|
|
6708
|
+
return (0, _univerjs_core.excelDateSerial)(new Date(Date.UTC(year, month, 1)), dateSystem);
|
|
6709
|
+
}
|
|
6600
6710
|
var NullValueObject = class NullValueObject extends BaseValueObject {
|
|
6601
6711
|
static create() {
|
|
6602
6712
|
this._instance = this._instance || new NullValueObject();
|
|
@@ -7315,9 +7425,7 @@ var NumberValueObject = class NumberValueObject extends BaseValueObject {
|
|
|
7315
7425
|
case "<=":
|
|
7316
7426
|
result = currentValue <= value;
|
|
7317
7427
|
break;
|
|
7318
|
-
case "<>":
|
|
7319
|
-
result = currentValue !== value;
|
|
7320
|
-
break;
|
|
7428
|
+
case "<>": result = currentValue !== value;
|
|
7321
7429
|
}
|
|
7322
7430
|
return result;
|
|
7323
7431
|
}
|
|
@@ -7402,12 +7510,12 @@ var StringValueObject = class StringValueObject extends BaseValueObject {
|
|
|
7402
7510
|
let currentValue = this.getValue();
|
|
7403
7511
|
let result = false;
|
|
7404
7512
|
if (typeof value === "string") {
|
|
7513
|
+
if (isWildcard(value)) return this._checkWildcard(value, operator, isCaseSensitive);
|
|
7405
7514
|
let _value = value;
|
|
7406
7515
|
if (!isCaseSensitive) {
|
|
7407
|
-
currentValue = currentValue
|
|
7408
|
-
_value = _value
|
|
7516
|
+
currentValue = normalizeTextForComparison(currentValue);
|
|
7517
|
+
_value = normalizeTextForComparison(_value);
|
|
7409
7518
|
}
|
|
7410
|
-
if (isWildcard(_value)) return this._checkWildcard(_value, operator);
|
|
7411
7519
|
result = this._compareString(currentValue, _value, operator);
|
|
7412
7520
|
} else if (typeof value === "number") result = this._compareNumber(operator);
|
|
7413
7521
|
else if (typeof value === "boolean") result = this._compareBoolean(operator);
|
|
@@ -7449,13 +7557,15 @@ var StringValueObject = class StringValueObject extends BaseValueObject {
|
|
|
7449
7557
|
if (rawValue.trim() === "") return ErrorValueObject.create("#VALUE!");
|
|
7450
7558
|
const parseData = (0, _univerjs_core.getNumfmtParseValueFilter)(rawValue, { dateSystem: this.getDateSystem() });
|
|
7451
7559
|
if (parseData && parseData.z) return createNumberValueObjectByRawValue(parseData.v, parseData.z).withDateSystem(this.getDateSystem());
|
|
7560
|
+
const compactMonthYear = parseCompactEnglishMonthYear(rawValue, this.getDateSystem());
|
|
7561
|
+
if (compactMonthYear !== null) return createNumberValueObjectByRawValue(compactMonthYear).withDateSystem(this.getDateSystem());
|
|
7452
7562
|
return createNumberValueObjectByRawValue(rawValue).withDateSystem(this.getDateSystem());
|
|
7453
7563
|
}
|
|
7454
7564
|
convertToBooleanObjectValue() {
|
|
7455
7565
|
return BooleanValueObject.create(true);
|
|
7456
7566
|
}
|
|
7457
|
-
_checkWildcard(value, operator) {
|
|
7458
|
-
const result = compareWithWildcard(this.getValue()
|
|
7567
|
+
_checkWildcard(value, operator, isCaseSensitive) {
|
|
7568
|
+
const result = compareWithWildcard(this.getValue(), value, operator, isCaseSensitive);
|
|
7459
7569
|
return BooleanValueObject.create(result);
|
|
7460
7570
|
}
|
|
7461
7571
|
};
|
|
@@ -8468,51 +8578,50 @@ var ArrayValueObject = class ArrayValueObject extends BaseValueObject {
|
|
|
8468
8578
|
__batchOperatorRowValue(valueObject, column, result, batchOperatorType, r, unitId, sheetId, startRow, startColumn, operator, isCaseSensitive) {
|
|
8469
8579
|
const currentValue = this.getValueOrDefault(r, column);
|
|
8470
8580
|
if (result[r] == null) result[r] = [];
|
|
8471
|
-
if (currentValue && valueObject)
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
result[r][column] = currentValue.ceil(valueObject);
|
|
8513
|
-
|
|
8514
|
-
}
|
|
8515
|
-
else result[r][column] = ErrorValueObject.create("#N/A");
|
|
8581
|
+
if (currentValue && valueObject) {
|
|
8582
|
+
if (currentValue.isError()) result[r][column] = currentValue;
|
|
8583
|
+
else if (valueObject.isError()) result[r][column] = valueObject;
|
|
8584
|
+
else switch (batchOperatorType) {
|
|
8585
|
+
case 1:
|
|
8586
|
+
result[r][column] = currentValue.plus(valueObject);
|
|
8587
|
+
break;
|
|
8588
|
+
case 0:
|
|
8589
|
+
result[r][column] = currentValue.minus(valueObject);
|
|
8590
|
+
break;
|
|
8591
|
+
case 2:
|
|
8592
|
+
result[r][column] = currentValue.multiply(valueObject);
|
|
8593
|
+
break;
|
|
8594
|
+
case 3:
|
|
8595
|
+
result[r][column] = currentValue.divided(valueObject);
|
|
8596
|
+
break;
|
|
8597
|
+
case 4:
|
|
8598
|
+
result[r][column] = currentValue.mod(valueObject);
|
|
8599
|
+
break;
|
|
8600
|
+
case 5:
|
|
8601
|
+
if (!operator) result[r][column] = ErrorValueObject.create("#VALUE!");
|
|
8602
|
+
else result[r][column] = currentValue.compare(valueObject, operator, isCaseSensitive);
|
|
8603
|
+
break;
|
|
8604
|
+
case 6:
|
|
8605
|
+
result[r][column] = currentValue.concatenateFront(valueObject);
|
|
8606
|
+
break;
|
|
8607
|
+
case 7:
|
|
8608
|
+
result[r][column] = currentValue.concatenateBack(valueObject);
|
|
8609
|
+
break;
|
|
8610
|
+
case 8:
|
|
8611
|
+
result[r][column] = currentValue.pow(valueObject);
|
|
8612
|
+
break;
|
|
8613
|
+
case 9:
|
|
8614
|
+
result[r][column] = currentValue.round(valueObject);
|
|
8615
|
+
break;
|
|
8616
|
+
case 10:
|
|
8617
|
+
result[r][column] = currentValue.floor(valueObject);
|
|
8618
|
+
break;
|
|
8619
|
+
case 12:
|
|
8620
|
+
result[r][column] = currentValue.atan2(valueObject);
|
|
8621
|
+
break;
|
|
8622
|
+
case 11: result[r][column] = currentValue.ceil(valueObject);
|
|
8623
|
+
}
|
|
8624
|
+
} else result[r][column] = ErrorValueObject.create("#N/A");
|
|
8516
8625
|
if (this._useInvertedIndexCache) CELL_INVERTED_INDEX_CACHE.set(unitId, sheetId, column + startColumn, (currentValue === null || currentValue === void 0 ? void 0 : currentValue.isNull()) ? null : currentValue === null || currentValue === void 0 ? void 0 : currentValue.getValue(), r + startRow);
|
|
8517
8626
|
}
|
|
8518
8627
|
_batchOperatorArray(valueObject, batchOperatorType, operator, isCaseSensitive) {
|
|
@@ -8536,51 +8645,50 @@ var ArrayValueObject = class ArrayValueObject extends BaseValueObject {
|
|
|
8536
8645
|
else if (opCalculateType === 1) opValue = valueObject.getValueOrDefault(0, c);
|
|
8537
8646
|
else if (opCalculateType === 2) opValue = valueObject.getValueOrDefault(r, 0);
|
|
8538
8647
|
else opValue = valueObject.getValueOrDefault(r, c);
|
|
8539
|
-
if (currentValue && opValue)
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
|
|
8564
|
-
|
|
8565
|
-
|
|
8566
|
-
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
|
|
8572
|
-
|
|
8573
|
-
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
rowList[c] = currentValue.ceil(opValue);
|
|
8581
|
-
|
|
8582
|
-
}
|
|
8583
|
-
else rowList[c] = ErrorValueObject.create("#N/A");
|
|
8648
|
+
if (currentValue && opValue) {
|
|
8649
|
+
if (currentValue.isError()) rowList[c] = currentValue;
|
|
8650
|
+
else if (opValue.isError()) rowList[c] = opValue;
|
|
8651
|
+
else switch (batchOperatorType) {
|
|
8652
|
+
case 1:
|
|
8653
|
+
rowList[c] = currentValue.plus(opValue);
|
|
8654
|
+
break;
|
|
8655
|
+
case 0:
|
|
8656
|
+
rowList[c] = currentValue.minus(opValue);
|
|
8657
|
+
break;
|
|
8658
|
+
case 2:
|
|
8659
|
+
rowList[c] = currentValue.multiply(opValue);
|
|
8660
|
+
break;
|
|
8661
|
+
case 3:
|
|
8662
|
+
rowList[c] = currentValue.divided(opValue);
|
|
8663
|
+
break;
|
|
8664
|
+
case 4:
|
|
8665
|
+
rowList[c] = currentValue.mod(opValue);
|
|
8666
|
+
break;
|
|
8667
|
+
case 5:
|
|
8668
|
+
if (!operator) rowList[c] = ErrorValueObject.create("#VALUE!");
|
|
8669
|
+
else rowList[c] = currentValue.compare(opValue, operator, isCaseSensitive);
|
|
8670
|
+
break;
|
|
8671
|
+
case 6:
|
|
8672
|
+
rowList[c] = currentValue.concatenateFront(opValue);
|
|
8673
|
+
break;
|
|
8674
|
+
case 7:
|
|
8675
|
+
rowList[c] = currentValue.concatenateBack(opValue);
|
|
8676
|
+
break;
|
|
8677
|
+
case 8:
|
|
8678
|
+
rowList[c] = currentValue.pow(opValue);
|
|
8679
|
+
break;
|
|
8680
|
+
case 9:
|
|
8681
|
+
rowList[c] = currentValue.round(opValue);
|
|
8682
|
+
break;
|
|
8683
|
+
case 12:
|
|
8684
|
+
rowList[c] = currentValue.atan2(opValue);
|
|
8685
|
+
break;
|
|
8686
|
+
case 10:
|
|
8687
|
+
rowList[c] = currentValue.floor(opValue);
|
|
8688
|
+
break;
|
|
8689
|
+
case 11: rowList[c] = currentValue.ceil(opValue);
|
|
8690
|
+
}
|
|
8691
|
+
} else rowList[c] = ErrorValueObject.create("#N/A");
|
|
8584
8692
|
}
|
|
8585
8693
|
result.push(rowList);
|
|
8586
8694
|
}
|
|
@@ -8964,7 +9072,7 @@ var BaseReferenceObject = class extends ObjectClassType {
|
|
|
8964
9072
|
getCellValueObject(cell) {
|
|
8965
9073
|
const value = getCellValue(cell);
|
|
8966
9074
|
const cellValueType = Number(cell.t);
|
|
8967
|
-
if (ERROR_TYPE_SET.has(value)) return ErrorValueObject.create(value);
|
|
9075
|
+
if (cellValueType !== _univerjs_core.CellValueType.FORCE_STRING && ERROR_TYPE_SET.has(value)) return ErrorValueObject.create(value);
|
|
8968
9076
|
if (cellValueType === _univerjs_core.CellValueType.NUMBER) {
|
|
8969
9077
|
const pattern = this._getPatternByCell(cell);
|
|
8970
9078
|
if ((0, _univerjs_core.isTextFormat)(pattern)) return StringValueObject.create(value.toString()).withDateSystem(this._dateSystem);
|
|
@@ -9407,6 +9515,14 @@ function createNewArray(result, rowCount, columnCount, unitId = "", sheetId = ""
|
|
|
9407
9515
|
|
|
9408
9516
|
//#endregion
|
|
9409
9517
|
//#region src/engine/utils/object-compare.ts
|
|
9518
|
+
function createCriteriaValueObject(content, dateSystem) {
|
|
9519
|
+
if ((0, _univerjs_core.isRealNum)(content)) {
|
|
9520
|
+
const number = Number(content);
|
|
9521
|
+
if (!/^ *[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)? *$/i.test(content) || !Number.isFinite(number)) return StringValueObject.create(content);
|
|
9522
|
+
return NumberValueObject.create(Math.abs(number) < 2 ** -1022 ? 0 : number);
|
|
9523
|
+
}
|
|
9524
|
+
return ValueObjectFactory.create(content, false, dateSystem);
|
|
9525
|
+
}
|
|
9410
9526
|
function findCompareToken(str, dateSystem) {
|
|
9411
9527
|
const comparisonTokens = [
|
|
9412
9528
|
"=",
|
|
@@ -9416,11 +9532,14 @@ function findCompareToken(str, dateSystem) {
|
|
|
9416
9532
|
"<=",
|
|
9417
9533
|
"<"
|
|
9418
9534
|
];
|
|
9535
|
+
let operator = "=";
|
|
9536
|
+
let content = str;
|
|
9419
9537
|
for (const token of comparisonTokens) if (str.startsWith(token)) {
|
|
9420
|
-
|
|
9421
|
-
|
|
9538
|
+
operator = token;
|
|
9539
|
+
content = str.substring(token.length);
|
|
9540
|
+
break;
|
|
9422
9541
|
}
|
|
9423
|
-
return [
|
|
9542
|
+
return [operator, createCriteriaValueObject(content, dateSystem)];
|
|
9424
9543
|
}
|
|
9425
9544
|
/**
|
|
9426
9545
|
* When it contains both comparison characters and wildcard characters
|
|
@@ -9429,11 +9548,13 @@ function findCompareToken(str, dateSystem) {
|
|
|
9429
9548
|
* 3. <apple*: normal value, <=apple: obtains the same effect as <apple*
|
|
9430
9549
|
*/
|
|
9431
9550
|
function valueObjectCompare(range, criteria, operator, isCaseSensitive) {
|
|
9432
|
-
if (!operator)
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
|
-
|
|
9436
|
-
|
|
9551
|
+
if (!operator) {
|
|
9552
|
+
if (criteria.isString()) {
|
|
9553
|
+
const [token, criteriaStringObject] = findCompareToken(`${criteria.getValue()}`, criteria.getDateSystem());
|
|
9554
|
+
operator = token;
|
|
9555
|
+
criteria = criteriaStringObject;
|
|
9556
|
+
} else operator = "=";
|
|
9557
|
+
}
|
|
9437
9558
|
return range.compare(criteria, operator, isCaseSensitive);
|
|
9438
9559
|
}
|
|
9439
9560
|
/**
|
|
@@ -9518,7 +9639,7 @@ function objectValueToCellValue(objectValue) {
|
|
|
9518
9639
|
};
|
|
9519
9640
|
if (vo.isString()) return {
|
|
9520
9641
|
v,
|
|
9521
|
-
t: _univerjs_core.CellValueType.STRING,
|
|
9642
|
+
t: ERROR_TYPE_SET.has(v) ? _univerjs_core.CellValueType.FORCE_STRING : _univerjs_core.CellValueType.STRING,
|
|
9522
9643
|
...cellWithStyle,
|
|
9523
9644
|
...cellWithCustomData
|
|
9524
9645
|
};
|
|
@@ -9544,13 +9665,15 @@ function calculateMaxDimensions(variants) {
|
|
|
9544
9665
|
let maxRowLength = 0;
|
|
9545
9666
|
let maxColumnLength = 0;
|
|
9546
9667
|
variants.forEach((variant, i) => {
|
|
9547
|
-
if (i % 2 === 1)
|
|
9548
|
-
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
|
|
9668
|
+
if (i % 2 === 1) {
|
|
9669
|
+
if (variant.isArray()) {
|
|
9670
|
+
const arrayValue = variant;
|
|
9671
|
+
maxRowLength = Math.max(maxRowLength, arrayValue.getRowCount());
|
|
9672
|
+
maxColumnLength = Math.max(maxColumnLength, arrayValue.getColumnCount());
|
|
9673
|
+
} else {
|
|
9674
|
+
maxRowLength = Math.max(maxRowLength, 1);
|
|
9675
|
+
maxColumnLength = Math.max(maxColumnLength, 1);
|
|
9676
|
+
}
|
|
9554
9677
|
}
|
|
9555
9678
|
});
|
|
9556
9679
|
return {
|
|
@@ -9727,17 +9850,18 @@ function filterSameValueObjectResult(array, range, criteria) {
|
|
|
9727
9850
|
if (criteriaObject.isString() && criteriaObject.getValue() !== "" && (operator === "<" || operator === "<=") && (rangeValueObject == null || rangeValueObject.isNull())) return BooleanValueObject.create(false);
|
|
9728
9851
|
if (criteriaObject.isString() && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString()) && (operator === "<" || operator === "<=") && isSameLowerBoundBucket(rangeValueObject.getValue(), criteriaObject.getValue())) return BooleanValueObject.create(false);
|
|
9729
9852
|
if ((rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isNumber()) && criteriaObject.isString()) {
|
|
9730
|
-
const criteriaNumber = criteriaObject.
|
|
9853
|
+
const criteriaNumber = createCriteriaValueObject(`${criteriaObject.getValue()}`, criteriaObject.getDateSystem());
|
|
9731
9854
|
if (criteriaNumber.isNumber()) return rangeValueObject.compare(criteriaNumber, operator);
|
|
9732
9855
|
}
|
|
9733
|
-
if (criteriaObject.isNumber() && criteriaObject.isDateFormat() && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString())) {
|
|
9856
|
+
if (operator !== "<>" && criteriaObject.isNumber() && criteriaObject.isDateFormat() && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString())) {
|
|
9734
9857
|
const rangeNumber = rangeValueObject.convertToNumberObjectValue();
|
|
9735
9858
|
if (rangeNumber.isNumber()) return rangeNumber.compare(criteriaObject, operator);
|
|
9736
9859
|
}
|
|
9737
9860
|
if (rangeValueObject && isSameValueObjectType(rangeValueObject, criteriaObject)) return valueObject;
|
|
9738
9861
|
if ((rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isError()) && criteriaObject.isError() && rangeValueObject.getValue() === criteriaObject.getValue()) return BooleanValueObject.create(true);
|
|
9739
9862
|
/**
|
|
9740
|
-
*
|
|
9863
|
+
* Equality criteria coerce numeric text; numeric inequality criteria
|
|
9864
|
+
* retain the distinction between text cells and numeric cells.
|
|
9741
9865
|
* Other operators require both valueObjects to be of the same type.
|
|
9742
9866
|
* For example:
|
|
9743
9867
|
* | A1 | B1 |
|
|
@@ -9749,8 +9873,8 @@ function filterSameValueObjectResult(array, range, criteria) {
|
|
|
9749
9873
|
* =COUNTIF(A1:B1, '<=123') will return 1
|
|
9750
9874
|
*/
|
|
9751
9875
|
if (operator === "=" || operator === "<>") {
|
|
9752
|
-
if (criteriaObject.isNumber() && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString())) {
|
|
9753
|
-
const rangeNumber = rangeValueObject.
|
|
9876
|
+
if (operator === "=" && criteriaObject.isNumber() && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString())) {
|
|
9877
|
+
const rangeNumber = createCriteriaValueObject(`${rangeValueObject.getValue()}`, rangeValueObject.getDateSystem());
|
|
9754
9878
|
if (rangeNumber.isNumber()) return rangeNumber.compare(criteriaObject, operator);
|
|
9755
9879
|
}
|
|
9756
9880
|
if (operator === "=") return BooleanValueObject.create(false);
|
|
@@ -9788,9 +9912,7 @@ function getReferenceObjectFromCache(trimToken, type) {
|
|
|
9788
9912
|
case 2:
|
|
9789
9913
|
referenceObject = new RowReferenceObject(trimToken);
|
|
9790
9914
|
break;
|
|
9791
|
-
default:
|
|
9792
|
-
referenceObject = new CellReferenceObject(trimToken);
|
|
9793
|
-
break;
|
|
9915
|
+
default: referenceObject = new CellReferenceObject(trimToken);
|
|
9794
9916
|
}
|
|
9795
9917
|
return referenceObject;
|
|
9796
9918
|
}
|
|
@@ -9816,10 +9938,12 @@ let HyperlinkEngineFormulaService = class HyperlinkEngineFormulaService extends
|
|
|
9816
9938
|
if (url.startsWith("#") && isReferenceString(url.slice(1))) {
|
|
9817
9939
|
const { unitId, sheetName, range } = deserializeRangeWithSheet(url.slice(1));
|
|
9818
9940
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
9819
|
-
if (unitId === "" || unitId === workbook.getUnitId())
|
|
9820
|
-
|
|
9821
|
-
|
|
9822
|
-
|
|
9941
|
+
if (unitId === "" || unitId === workbook.getUnitId()) {
|
|
9942
|
+
if (sheetName === "") payload = `#gid=${workbook.getActiveSheet().getSheetId()}&range=${serializeRange(range)}`;
|
|
9943
|
+
else {
|
|
9944
|
+
const worksheet = workbook.getSheetBySheetName(sheetName);
|
|
9945
|
+
if (worksheet) payload = `#gid=${worksheet.getSheetId()}&range=${serializeRange(range)}`;
|
|
9946
|
+
}
|
|
9823
9947
|
}
|
|
9824
9948
|
} else if (_univerjs_core.Tools.isLegalUrl(url)) payload = _univerjs_core.Tools.normalizeUrl(url);
|
|
9825
9949
|
return { p: _univerjs_core.RichTextBuilder.create().insertLink(label, payload).getData() };
|
|
@@ -9860,6 +9984,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
9860
9984
|
this._hyperlinkEngineFormulaService = _hyperlinkEngineFormulaService;
|
|
9861
9985
|
_defineProperty(this, "_formulaExecuteStage", 0);
|
|
9862
9986
|
_defineProperty(this, "_stopState", false);
|
|
9987
|
+
_defineProperty(this, "_externalReferenceUnavailable", false);
|
|
9863
9988
|
_defineProperty(this, "_currentRow", -1);
|
|
9864
9989
|
_defineProperty(this, "_currentColumn", -1);
|
|
9865
9990
|
_defineProperty(this, "_currentRowCount", Number.NEGATIVE_INFINITY);
|
|
@@ -9867,14 +9992,14 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
9867
9992
|
_defineProperty(this, "_functionRefInfoOverrideStack", []);
|
|
9868
9993
|
_defineProperty(this, "_currentSubUnitId", "");
|
|
9869
9994
|
_defineProperty(this, "_currentUnitId", "");
|
|
9870
|
-
_defineProperty(this, "_runtimeData",
|
|
9871
|
-
_defineProperty(this, "_runtimeOtherData",
|
|
9872
|
-
_defineProperty(this, "_unitArrayFormulaRange",
|
|
9873
|
-
_defineProperty(this, "_unitArrayFormulaEmbeddedMap",
|
|
9874
|
-
_defineProperty(this, "_runtimeArrayFormulaCellData",
|
|
9875
|
-
_defineProperty(this, "_runtimeClearArrayFormulaCellData",
|
|
9876
|
-
_defineProperty(this, "_runtimeFeatureRange",
|
|
9877
|
-
_defineProperty(this, "_runtimeFeatureCellData",
|
|
9995
|
+
_defineProperty(this, "_runtimeData", Object.create(null));
|
|
9996
|
+
_defineProperty(this, "_runtimeOtherData", Object.create(null));
|
|
9997
|
+
_defineProperty(this, "_unitArrayFormulaRange", Object.create(null));
|
|
9998
|
+
_defineProperty(this, "_unitArrayFormulaEmbeddedMap", Object.create(null));
|
|
9999
|
+
_defineProperty(this, "_runtimeArrayFormulaCellData", Object.create(null));
|
|
10000
|
+
_defineProperty(this, "_runtimeClearArrayFormulaCellData", Object.create(null));
|
|
10001
|
+
_defineProperty(this, "_runtimeFeatureRange", Object.create(null));
|
|
10002
|
+
_defineProperty(this, "_runtimeFeatureCellData", Object.create(null));
|
|
9878
10003
|
_defineProperty(this, "_runtimeImageFormulaData", []);
|
|
9879
10004
|
_defineProperty(this, "_functionsExecutedState", 0);
|
|
9880
10005
|
_defineProperty(this, "_functionDefinitionPrivacyVar", /* @__PURE__ */ new Map());
|
|
@@ -9909,8 +10034,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
9909
10034
|
dispose() {
|
|
9910
10035
|
super.dispose();
|
|
9911
10036
|
this.reset();
|
|
9912
|
-
this._runtimeFeatureCellData =
|
|
9913
|
-
this._runtimeFeatureRange =
|
|
10037
|
+
this._runtimeFeatureCellData = Object.create(null);
|
|
10038
|
+
this._runtimeFeatureRange = Object.create(null);
|
|
9914
10039
|
this.clearReferenceAndNumberformatCache();
|
|
9915
10040
|
}
|
|
9916
10041
|
enableCycleDependency() {
|
|
@@ -9979,12 +10104,12 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
9979
10104
|
}
|
|
9980
10105
|
reset() {
|
|
9981
10106
|
this._formulaExecuteStage = 0;
|
|
9982
|
-
this._runtimeData =
|
|
9983
|
-
this._runtimeOtherData =
|
|
9984
|
-
this._unitArrayFormulaRange =
|
|
9985
|
-
this._unitArrayFormulaEmbeddedMap =
|
|
9986
|
-
this._runtimeArrayFormulaCellData =
|
|
9987
|
-
this._runtimeClearArrayFormulaCellData =
|
|
10107
|
+
this._runtimeData = Object.create(null);
|
|
10108
|
+
this._runtimeOtherData = Object.create(null);
|
|
10109
|
+
this._unitArrayFormulaRange = Object.create(null);
|
|
10110
|
+
this._unitArrayFormulaEmbeddedMap = Object.create(null);
|
|
10111
|
+
this._runtimeArrayFormulaCellData = Object.create(null);
|
|
10112
|
+
this._runtimeClearArrayFormulaCellData = Object.create(null);
|
|
9988
10113
|
this._runtimeImageFormulaData = [];
|
|
9989
10114
|
this._functionDefinitionPrivacyVar.clear();
|
|
9990
10115
|
this.markedAsInitialFunctionsExecuted();
|
|
@@ -10001,6 +10126,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10001
10126
|
clearReferenceToRangeCache();
|
|
10002
10127
|
}
|
|
10003
10128
|
setCurrent(row, column, rowCount, columnCount, sheetId, unitId) {
|
|
10129
|
+
this._externalReferenceUnavailable = false;
|
|
10004
10130
|
this._currentRow = row;
|
|
10005
10131
|
this._currentColumn = column;
|
|
10006
10132
|
this._currentRowCount = rowCount;
|
|
@@ -10032,9 +10158,9 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10032
10158
|
setRuntimeOtherData(formulaId, x, y, functionVariant) {
|
|
10033
10159
|
const subUnitId = this._currentSubUnitId;
|
|
10034
10160
|
const unitId = this._currentUnitId;
|
|
10035
|
-
if (this._runtimeOtherData[unitId] === void 0) this._runtimeOtherData[unitId] =
|
|
10161
|
+
if (this._runtimeOtherData[unitId] === void 0) this._runtimeOtherData[unitId] = Object.create(null);
|
|
10036
10162
|
const unitData = this._runtimeOtherData[unitId];
|
|
10037
|
-
if (unitData[subUnitId] === void 0 || unitData[subUnitId] === null) unitData[subUnitId] =
|
|
10163
|
+
if (unitData[subUnitId] === void 0 || unitData[subUnitId] === null) unitData[subUnitId] = Object.create(null);
|
|
10038
10164
|
const subComponentData = unitData[subUnitId];
|
|
10039
10165
|
let cellDatas = [];
|
|
10040
10166
|
if (functionVariant.isReferenceObject() || functionVariant.isValueObject() && functionVariant.isArray()) {
|
|
@@ -10048,30 +10174,39 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10048
10174
|
cellDatas[row][column] = value;
|
|
10049
10175
|
});
|
|
10050
10176
|
} else cellDatas = [[this._getValueObjectOfRuntimeData(functionVariant)]];
|
|
10051
|
-
if (subComponentData[formulaId] === void 0 || subComponentData[formulaId] === null) subComponentData[formulaId] =
|
|
10052
|
-
if (subComponentData[formulaId][y] === void 0 || subComponentData[formulaId][y] === null) subComponentData[formulaId][y] =
|
|
10177
|
+
if (subComponentData[formulaId] === void 0 || subComponentData[formulaId] === null) subComponentData[formulaId] = Object.create(null);
|
|
10178
|
+
if (subComponentData[formulaId][y] === void 0 || subComponentData[formulaId][y] === null) subComponentData[formulaId][y] = Object.create(null);
|
|
10053
10179
|
subComponentData[formulaId][y][x] = cellDatas;
|
|
10054
10180
|
}
|
|
10181
|
+
markExternalReferenceUnavailable() {
|
|
10182
|
+
this._externalReferenceUnavailable = true;
|
|
10183
|
+
}
|
|
10055
10184
|
setRuntimeData(functionVariant) {
|
|
10185
|
+
if (this._externalReferenceUnavailable) {
|
|
10186
|
+
var _this$_currentConfigS, _this$_currentConfigS2;
|
|
10187
|
+
const cell = (_this$_currentConfigS = this._currentConfigService.getUnitData()[this._currentUnitId]) === null || _this$_currentConfigS === void 0 || (_this$_currentConfigS = _this$_currentConfigS[this._currentSubUnitId]) === null || _this$_currentConfigS === void 0 ? void 0 : _this$_currentConfigS.cellData.getValue(this._currentRow, this._currentColumn);
|
|
10188
|
+
const formula = (_this$_currentConfigS2 = this._currentConfigService.getFormulaData()[this._currentUnitId]) === null || _this$_currentConfigS2 === void 0 || (_this$_currentConfigS2 = _this$_currentConfigS2[this._currentSubUnitId]) === null || _this$_currentConfigS2 === void 0 || (_this$_currentConfigS2 = _this$_currentConfigS2[this._currentRow]) === null || _this$_currentConfigS2 === void 0 || (_this$_currentConfigS2 = _this$_currentConfigS2[this._currentColumn]) === null || _this$_currentConfigS2 === void 0 ? void 0 : _this$_currentConfigS2.f;
|
|
10189
|
+
if ((cell === null || cell === void 0 ? void 0 : cell.f) && cell.v != null && (formula == null || formula === cell.f)) return;
|
|
10190
|
+
}
|
|
10056
10191
|
const row = this._currentRow;
|
|
10057
10192
|
const column = this._currentColumn;
|
|
10058
10193
|
const rowCount = this._currentRowCount;
|
|
10059
10194
|
const columnCount = this.currentColumnCount;
|
|
10060
10195
|
const sheetId = this._currentSubUnitId;
|
|
10061
10196
|
const unitId = this._currentUnitId;
|
|
10062
|
-
if (this._runtimeData[unitId] == null) this._runtimeData[unitId] =
|
|
10197
|
+
if (this._runtimeData[unitId] == null) this._runtimeData[unitId] = Object.create(null);
|
|
10063
10198
|
const unitData = this._runtimeData[unitId];
|
|
10064
10199
|
if (unitData[sheetId] == null) unitData[sheetId] = new _univerjs_core.ObjectMatrix();
|
|
10065
10200
|
const sheetData = unitData[sheetId];
|
|
10066
|
-
if (this._unitArrayFormulaRange[unitId] == null) this._unitArrayFormulaRange[unitId] =
|
|
10201
|
+
if (this._unitArrayFormulaRange[unitId] == null) this._unitArrayFormulaRange[unitId] = Object.create(null);
|
|
10067
10202
|
const arrayFormulaRange = this._unitArrayFormulaRange[unitId];
|
|
10068
|
-
if (arrayFormulaRange[sheetId] === null || arrayFormulaRange[sheetId] === void 0) arrayFormulaRange[sheetId] =
|
|
10203
|
+
if (arrayFormulaRange[sheetId] === null || arrayFormulaRange[sheetId] === void 0) arrayFormulaRange[sheetId] = Object.create(null);
|
|
10069
10204
|
const arrayData = new _univerjs_core.ObjectMatrix(arrayFormulaRange[sheetId]);
|
|
10070
|
-
if (this._runtimeArrayFormulaCellData[unitId] === void 0) this._runtimeArrayFormulaCellData[unitId] =
|
|
10205
|
+
if (this._runtimeArrayFormulaCellData[unitId] === void 0) this._runtimeArrayFormulaCellData[unitId] = Object.create(null);
|
|
10071
10206
|
const runtimeArrayFormulaCellData = this._runtimeArrayFormulaCellData[unitId];
|
|
10072
10207
|
if (runtimeArrayFormulaCellData[sheetId] == null) runtimeArrayFormulaCellData[sheetId] = new _univerjs_core.ObjectMatrix();
|
|
10073
10208
|
const runtimeArrayUnitData = runtimeArrayFormulaCellData[sheetId];
|
|
10074
|
-
if (this._runtimeClearArrayFormulaCellData[unitId] === void 0) this._runtimeClearArrayFormulaCellData[unitId] =
|
|
10209
|
+
if (this._runtimeClearArrayFormulaCellData[unitId] === void 0) this._runtimeClearArrayFormulaCellData[unitId] = Object.create(null);
|
|
10075
10210
|
const clearArrayFormulaCellData = this._runtimeClearArrayFormulaCellData[unitId];
|
|
10076
10211
|
if (clearArrayFormulaCellData[sheetId] == null) clearArrayFormulaCellData[sheetId] = new _univerjs_core.ObjectMatrix();
|
|
10077
10212
|
const clearArrayUnitData = clearArrayFormulaCellData[sheetId];
|
|
@@ -10109,7 +10244,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10109
10244
|
const hasDataInArrayFormulaRange = this._checkIfArrayFormulaRangeHasData(unitId, sheetId, row, column, arrayRange);
|
|
10110
10245
|
const isArrayFormulaExceeded = this._checkIfArrayFormulaExceeded(rowCount, columnCount, arrayRange);
|
|
10111
10246
|
if (hasDataInArrayFormulaRange || isArrayFormulaExceeded) {
|
|
10112
|
-
var _this$
|
|
10247
|
+
var _this$_currentConfigS3;
|
|
10113
10248
|
const errorObject = this._getValueObjectOfRuntimeData(ErrorValueObject.create("#SPILL!"));
|
|
10114
10249
|
sheetData.setValue(row, column, errorObject);
|
|
10115
10250
|
clearArrayUnitData.setValue(row, column, errorObject);
|
|
@@ -10120,7 +10255,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10120
10255
|
*/
|
|
10121
10256
|
const unitData = this._currentConfigService.getUnitData();
|
|
10122
10257
|
const arrayData = this._currentConfigService.getArrayFormulaCellData();
|
|
10123
|
-
const previousArrayFormulaRange = (_this$
|
|
10258
|
+
const previousArrayFormulaRange = (_this$_currentConfigS3 = this._currentConfigService.getArrayFormulaRange()[unitId]) === null || _this$_currentConfigS3 === void 0 || (_this$_currentConfigS3 = _this$_currentConfigS3[sheetId]) === null || _this$_currentConfigS3 === void 0 || (_this$_currentConfigS3 = _this$_currentConfigS3[row]) === null || _this$_currentConfigS3 === void 0 ? void 0 : _this$_currentConfigS3[column];
|
|
10124
10259
|
objectValueRefOrArray.iterator((_, rowIndex, columnIndex) => {
|
|
10125
10260
|
var _unitData$unitId, _arrayData$unitId;
|
|
10126
10261
|
const currentRow = rowIndex - startRow + row;
|
|
@@ -10138,7 +10273,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10138
10273
|
} else {
|
|
10139
10274
|
const spillError = ErrorValueObject.create("#SPILL!");
|
|
10140
10275
|
objectValueRefOrArray.iterator((valueObject, rowIndex, columnIndex) => {
|
|
10141
|
-
CELL_INVERTED_INDEX_CACHE.set(unitId, sheetId, column - startColumn + columnIndex,
|
|
10276
|
+
CELL_INVERTED_INDEX_CACHE.set(unitId, sheetId, column - startColumn + columnIndex, valueObject == null || valueObject.isNull() ? null : valueObject.getValue(), row - startRow + rowIndex, true);
|
|
10142
10277
|
const value = this._getValueObjectOfRuntimeData(valueObject);
|
|
10143
10278
|
if (rowIndex === startRow && columnIndex === startColumn) {
|
|
10144
10279
|
/**
|
|
@@ -10170,7 +10305,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10170
10305
|
column
|
|
10171
10306
|
});
|
|
10172
10307
|
}
|
|
10173
|
-
CELL_INVERTED_INDEX_CACHE.set(unitId, sheetId, column, functionVariant.getValue(), row, true);
|
|
10308
|
+
CELL_INVERTED_INDEX_CACHE.set(unitId, sheetId, column, functionVariant.isNull() ? null : functionVariant.getValue(), row, true);
|
|
10174
10309
|
clearArrayUnitData.setValue(row, column, valueObject);
|
|
10175
10310
|
}
|
|
10176
10311
|
}
|
|
@@ -10193,9 +10328,9 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10193
10328
|
const rowIndex = this._currentRow;
|
|
10194
10329
|
const columnIndex = this._currentColumn;
|
|
10195
10330
|
const arrayFormulaEmbeddedMap = this._unitArrayFormulaEmbeddedMap;
|
|
10196
|
-
if (arrayFormulaEmbeddedMap[unitId] == null) arrayFormulaEmbeddedMap[unitId] =
|
|
10197
|
-
if (arrayFormulaEmbeddedMap[unitId][sheetId] == null) arrayFormulaEmbeddedMap[unitId][sheetId] =
|
|
10198
|
-
if (arrayFormulaEmbeddedMap[unitId][sheetId][rowIndex] == null) arrayFormulaEmbeddedMap[unitId][sheetId][rowIndex] =
|
|
10331
|
+
if (arrayFormulaEmbeddedMap[unitId] == null) arrayFormulaEmbeddedMap[unitId] = Object.create(null);
|
|
10332
|
+
if (arrayFormulaEmbeddedMap[unitId][sheetId] == null) arrayFormulaEmbeddedMap[unitId][sheetId] = Object.create(null);
|
|
10333
|
+
if (arrayFormulaEmbeddedMap[unitId][sheetId][rowIndex] == null) arrayFormulaEmbeddedMap[unitId][sheetId][rowIndex] = Object.create(null);
|
|
10199
10334
|
arrayFormulaEmbeddedMap[unitId][sheetId][rowIndex][columnIndex] = true;
|
|
10200
10335
|
}
|
|
10201
10336
|
getRuntimeOtherData() {
|
|
@@ -10257,11 +10392,11 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10257
10392
|
FORMULA_REF_TO_ARRAY_CACHE.clear();
|
|
10258
10393
|
}
|
|
10259
10394
|
_checkIfArrayFormulaRangeHasData(formulaUnitId, formulaSheetId, formulaRow, formulaColumn, arrayRange) {
|
|
10260
|
-
var _this$
|
|
10395
|
+
var _this$_currentConfigS4;
|
|
10261
10396
|
const { startRow, startColumn, endRow, endColumn } = arrayRange;
|
|
10262
10397
|
const unitData = this._currentConfigService.getUnitData();
|
|
10263
10398
|
const arrayData = this._currentConfigService.getArrayFormulaCellData();
|
|
10264
|
-
const previousArrayFormulaRange = (_this$
|
|
10399
|
+
const previousArrayFormulaRange = (_this$_currentConfigS4 = this._currentConfigService.getArrayFormulaRange()[formulaUnitId]) === null || _this$_currentConfigS4 === void 0 || (_this$_currentConfigS4 = _this$_currentConfigS4[formulaSheetId]) === null || _this$_currentConfigS4 === void 0 || (_this$_currentConfigS4 = _this$_currentConfigS4[formulaRow]) === null || _this$_currentConfigS4 === void 0 ? void 0 : _this$_currentConfigS4[formulaColumn];
|
|
10265
10400
|
for (let r = startRow; r <= endRow; r++) for (let c = startColumn; c <= endColumn; c++) {
|
|
10266
10401
|
var _this$_runtimeData, _arrayData$formulaUni, _unitData$formulaUnit;
|
|
10267
10402
|
if (r === formulaRow && formulaColumn === c) continue;
|
|
@@ -10297,8 +10432,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10297
10432
|
* @returns
|
|
10298
10433
|
*/
|
|
10299
10434
|
_isInOtherArrayFormulaRange(formulaUnitId, formulaSheetId, formulaRow, formulaColumn, r, c) {
|
|
10300
|
-
var _this$
|
|
10301
|
-
const arrayFormulaRange = (_this$
|
|
10435
|
+
var _this$_currentConfigS5;
|
|
10436
|
+
const arrayFormulaRange = (_this$_currentConfigS5 = this._currentConfigService.getArrayFormulaRange()[formulaUnitId]) === null || _this$_currentConfigS5 === void 0 ? void 0 : _this$_currentConfigS5[formulaSheetId];
|
|
10302
10437
|
if (arrayFormulaRange == null) return false;
|
|
10303
10438
|
let isCellOverlapping = false;
|
|
10304
10439
|
new _univerjs_core.ObjectMatrix(arrayFormulaRange).forValue((rangeRow, rangeCol, range) => {
|
|
@@ -10311,8 +10446,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10311
10446
|
return isCellOverlapping;
|
|
10312
10447
|
}
|
|
10313
10448
|
_isCurrentSingleCellArrayFormulaRange(unitId, sheetId, row, column) {
|
|
10314
|
-
var _this$
|
|
10315
|
-
const range = (_this$
|
|
10449
|
+
var _this$_currentConfigS6;
|
|
10450
|
+
const range = (_this$_currentConfigS6 = this._currentConfigService.getArrayFormulaRange()[unitId]) === null || _this$_currentConfigS6 === void 0 || (_this$_currentConfigS6 = _this$_currentConfigS6[sheetId]) === null || _this$_currentConfigS6 === void 0 || (_this$_currentConfigS6 = _this$_currentConfigS6[row]) === null || _this$_currentConfigS6 === void 0 ? void 0 : _this$_currentConfigS6[column];
|
|
10316
10451
|
return range != null && range.startRow === range.endRow && range.startColumn === range.endColumn;
|
|
10317
10452
|
}
|
|
10318
10453
|
_isInArrayFormulaRange(range, r, c) {
|
|
@@ -10322,7 +10457,9 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10322
10457
|
return false;
|
|
10323
10458
|
}
|
|
10324
10459
|
_isSameCellValue(cell, arrayDataCell) {
|
|
10325
|
-
|
|
10460
|
+
if ((cell === null || cell === void 0 ? void 0 : cell.t) !== (arrayDataCell === null || arrayDataCell === void 0 ? void 0 : arrayDataCell.t)) return false;
|
|
10461
|
+
if ((cell === null || cell === void 0 ? void 0 : cell.v) === (arrayDataCell === null || arrayDataCell === void 0 ? void 0 : arrayDataCell.v)) return true;
|
|
10462
|
+
return (cell === null || cell === void 0 ? void 0 : cell.t) === _univerjs_core.CellValueType.NUMBER && (0, _univerjs_core.isRealNum)(cell.v) && (0, _univerjs_core.isRealNum)(arrayDataCell === null || arrayDataCell === void 0 ? void 0 : arrayDataCell.v) && Number(cell.v) === Number(arrayDataCell === null || arrayDataCell === void 0 ? void 0 : arrayDataCell.v);
|
|
10326
10463
|
}
|
|
10327
10464
|
_checkIfArrayFormulaExceeded(rowCount, columnCount, arrayRange) {
|
|
10328
10465
|
if (arrayRange.endRow >= rowCount || arrayRange.endColumn >= columnCount) return true;
|
|
@@ -10413,7 +10550,7 @@ let FormulaUnitReferenceResolver = class FormulaUnitReferenceResolver {
|
|
|
10413
10550
|
constructor(_currentConfigService) {
|
|
10414
10551
|
this._currentConfigService = _currentConfigService;
|
|
10415
10552
|
}
|
|
10416
|
-
resolve({ hostUnitId, qualifier, referenceKind }) {
|
|
10553
|
+
resolve({ hostUnitId, qualifier, referenceKind, onUnavailable }) {
|
|
10417
10554
|
const unitNameMap = this._currentConfigService.getUnitNameMap();
|
|
10418
10555
|
const unitData = this._currentConfigService.getUnitData();
|
|
10419
10556
|
const address = qualifier || hostUnitId;
|
|
@@ -10427,7 +10564,10 @@ let FormulaUnitReferenceResolver = class FormulaUnitReferenceResolver {
|
|
|
10427
10564
|
const normalizedQualifier = qualifier.toLowerCase();
|
|
10428
10565
|
const exactMatches = namedUnits.filter(([, item]) => item.name.toLowerCase() === normalizedQualifier);
|
|
10429
10566
|
const matches = exactMatches.length > 0 ? exactMatches : namedUnits.filter(([, item]) => normalizeFormulaUnitName(item.name) === normalizeFormulaUnitName(qualifier));
|
|
10430
|
-
if (matches.length !== 1)
|
|
10567
|
+
if (matches.length !== 1) {
|
|
10568
|
+
if (matches.length === 0) onUnavailable === null || onUnavailable === void 0 || onUnavailable();
|
|
10569
|
+
return "#REF!";
|
|
10570
|
+
}
|
|
10431
10571
|
const [unitId, item] = matches[0];
|
|
10432
10572
|
return this._validateReferenceKind(hostUnitId, referenceKind, {
|
|
10433
10573
|
unitId,
|
|
@@ -10448,16 +10588,21 @@ FormulaUnitReferenceResolver = __decorate([__decorateParam(0, IFormulaCurrentCon
|
|
|
10448
10588
|
//#endregion
|
|
10449
10589
|
//#region src/engine/ast-node/prefix-node.ts
|
|
10450
10590
|
var PrefixNode = class extends BaseAstNode {
|
|
10591
|
+
getReferenceRanges() {
|
|
10592
|
+
return this._referenceRanges;
|
|
10593
|
+
}
|
|
10451
10594
|
constructor(_runtimeService, _operatorString, _functionExecutor) {
|
|
10452
10595
|
super(_operatorString);
|
|
10453
10596
|
this._runtimeService = _runtimeService;
|
|
10454
10597
|
this._operatorString = _operatorString;
|
|
10455
10598
|
this._functionExecutor = _functionExecutor;
|
|
10599
|
+
_defineProperty(this, "_referenceRanges", null);
|
|
10456
10600
|
}
|
|
10457
10601
|
get nodeType() {
|
|
10458
10602
|
return 11;
|
|
10459
10603
|
}
|
|
10460
10604
|
execute(dateSystem = _univerjs_core.DateSystem.Date1900) {
|
|
10605
|
+
this._referenceRanges = null;
|
|
10461
10606
|
let value = this.getChildren()[0].getValue();
|
|
10462
10607
|
let result;
|
|
10463
10608
|
if (value == null) {
|
|
@@ -10476,7 +10621,8 @@ var PrefixNode = class extends BaseAstNode {
|
|
|
10476
10621
|
if (value instanceof ArrayValueObject) return value.get(0, 0) ?? ErrorValueObject.create("#VALUE!");
|
|
10477
10622
|
if (!value.isReferenceObject()) return value;
|
|
10478
10623
|
const currentValue = value;
|
|
10479
|
-
|
|
10624
|
+
this._referenceRanges = [];
|
|
10625
|
+
if (currentValue.isCell()) return this._getReferencedCell(currentValue);
|
|
10480
10626
|
if (this._preserveAtRangeForFormula2LookupArray()) return currentValue;
|
|
10481
10627
|
const runtimeService = this._runtimeService;
|
|
10482
10628
|
const currentRow = runtimeService.currentRow || 0;
|
|
@@ -10484,11 +10630,27 @@ var PrefixNode = class extends BaseAstNode {
|
|
|
10484
10630
|
const { startRow, startColumn, endRow, endColumn } = currentValue.getRangePosition();
|
|
10485
10631
|
if (endColumn !== startColumn && endRow !== startRow) return ErrorValueObject.create("#VALUE!");
|
|
10486
10632
|
if (startRow === endRow && startColumn === endColumn) return ErrorValueObject.create("#VALUE!");
|
|
10487
|
-
if (endRow === startRow && currentColumn >= startColumn && currentColumn <= endColumn) return
|
|
10488
|
-
else if (startColumn === endColumn && currentRow >= startRow && currentRow <= endRow) return
|
|
10489
|
-
if (currentValue.isTable()) return
|
|
10633
|
+
if (endRow === startRow && currentColumn >= startColumn && currentColumn <= endColumn) return this._getReferencedCell(currentValue, void 0, currentColumn);
|
|
10634
|
+
else if (startColumn === endColumn && currentRow >= startRow && currentRow <= endRow) return this._getReferencedCell(currentValue, currentRow);
|
|
10635
|
+
if (currentValue.isTable()) return this._getReferencedCell(currentValue, currentRow);
|
|
10490
10636
|
return ErrorValueObject.create("#VALUE!");
|
|
10491
10637
|
}
|
|
10638
|
+
_getReferencedCell(reference, row, column) {
|
|
10639
|
+
const position = reference.getRangePosition();
|
|
10640
|
+
const selectedRow = row ?? position.startRow;
|
|
10641
|
+
const selectedColumn = column ?? position.startColumn;
|
|
10642
|
+
this._referenceRanges = reference.toUnitRanges().map((range) => ({
|
|
10643
|
+
unitId: range.unitId,
|
|
10644
|
+
sheetId: range.sheetId,
|
|
10645
|
+
range: {
|
|
10646
|
+
startRow: selectedRow,
|
|
10647
|
+
endRow: selectedRow,
|
|
10648
|
+
startColumn: selectedColumn,
|
|
10649
|
+
endColumn: selectedColumn
|
|
10650
|
+
}
|
|
10651
|
+
}));
|
|
10652
|
+
return reference.getCellByPosition(selectedRow, selectedColumn);
|
|
10653
|
+
}
|
|
10492
10654
|
_preserveAtRangeForFormula2LookupArray() {
|
|
10493
10655
|
let node = this;
|
|
10494
10656
|
let parent = node.getParent();
|
|
@@ -10828,7 +10990,8 @@ let FunctionNodeFactory = class FunctionNodeFactory extends BaseAstNodeFactory {
|
|
|
10828
10990
|
}
|
|
10829
10991
|
checkAndCreateNodeType(param) {
|
|
10830
10992
|
if (typeof param === "string") return;
|
|
10831
|
-
const
|
|
10993
|
+
const token = param.getToken();
|
|
10994
|
+
const { tokenTrim, minusPrefixNode, atPrefixNode } = prefixHandler(token.trim(), this._functionService, this._runtimeService);
|
|
10832
10995
|
const isColon = this._isParentUnionNode(param);
|
|
10833
10996
|
if (!Number.isNaN(Number(tokenTrim)) && !isColon) return ErrorNode.create("#VALUE!");
|
|
10834
10997
|
const tokenTrimUpper = normalizeFunctionToken(tokenTrim.toUpperCase());
|
|
@@ -11606,7 +11769,6 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11606
11769
|
default:
|
|
11607
11770
|
startRow = dataStartRow;
|
|
11608
11771
|
endRow = dataEndRow;
|
|
11609
|
-
break;
|
|
11610
11772
|
}
|
|
11611
11773
|
this.setRangeData({
|
|
11612
11774
|
startColumn,
|
|
@@ -11827,7 +11989,7 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11827
11989
|
}
|
|
11828
11990
|
/** Column title → column index; returns -1 if not found (caller should handle as parse error) */
|
|
11829
11991
|
_titleToIndex(name, titleMap) {
|
|
11830
|
-
const key = name.trim();
|
|
11992
|
+
const key = this._unescapeColumnName(name.trim());
|
|
11831
11993
|
const hit = titleMap.get(key);
|
|
11832
11994
|
if (hit !== void 0) return hit;
|
|
11833
11995
|
const keyNorm = key.replace(/\u3000/g, " ").trim();
|
|
@@ -11837,6 +11999,9 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11837
11999
|
for (const [title, index] of titleMap.entries()) if (title.replace(/\u3000/g, " ").trim().replace(/\r\n?/g, "\n") === lineBreakNorm) return index;
|
|
11838
12000
|
return -1;
|
|
11839
12001
|
}
|
|
12002
|
+
_unescapeColumnName(name) {
|
|
12003
|
+
return name.replace(/'(['#\[\]@])/g, "$1");
|
|
12004
|
+
}
|
|
11840
12005
|
/** Resolve #This Row's row number; takes first data row (tableStartRow+1) when no context available */
|
|
11841
12006
|
_resolveThisRow(dataStartRow, dataEndRow) {
|
|
11842
12007
|
this._isCurrentRowForRange = true;
|
|
@@ -11874,7 +12039,8 @@ var ReferenceNode = class extends BaseAstNode {
|
|
|
11874
12039
|
const resolution = this._unitReferenceResolver.resolve({
|
|
11875
12040
|
hostUnitId: runtimeService.currentUnitId,
|
|
11876
12041
|
qualifier: unitQualifier,
|
|
11877
|
-
referenceKind: "table"
|
|
12042
|
+
referenceKind: "table",
|
|
12043
|
+
onUnavailable: () => runtimeService.markExternalReferenceUnavailable()
|
|
11878
12044
|
});
|
|
11879
12045
|
if (typeof resolution === "string") {
|
|
11880
12046
|
this.setValue(ErrorValueObject.create(resolution));
|
|
@@ -11896,7 +12062,8 @@ var ReferenceNode = class extends BaseAstNode {
|
|
|
11896
12062
|
const resolution = this._unitReferenceResolver.resolve({
|
|
11897
12063
|
hostUnitId: runtimeService.currentUnitId,
|
|
11898
12064
|
qualifier: unitQualifier,
|
|
11899
|
-
referenceKind: "a1"
|
|
12065
|
+
referenceKind: "a1",
|
|
12066
|
+
onUnavailable: () => runtimeService.markExternalReferenceUnavailable()
|
|
11900
12067
|
});
|
|
11901
12068
|
if (typeof resolution === "string") {
|
|
11902
12069
|
this.setValue(ErrorValueObject.create(resolution));
|
|
@@ -11920,7 +12087,8 @@ var ReferenceNode = class extends BaseAstNode {
|
|
|
11920
12087
|
const resolution = this._unitReferenceResolver.resolve({
|
|
11921
12088
|
hostUnitId,
|
|
11922
12089
|
qualifier: unitQualifier,
|
|
11923
|
-
referenceKind
|
|
12090
|
+
referenceKind,
|
|
12091
|
+
onUnavailable: () => this._runtimeService.markExternalReferenceUnavailable()
|
|
11924
12092
|
});
|
|
11925
12093
|
if (typeof resolution === "string") {
|
|
11926
12094
|
this.setValue(ErrorValueObject.create(resolution));
|
|
@@ -11939,6 +12107,7 @@ var ReferenceNode = class extends BaseAstNode {
|
|
|
11939
12107
|
resolution
|
|
11940
12108
|
});
|
|
11941
12109
|
if (error) {
|
|
12110
|
+
if (error === "#N/A") this._runtimeService.markExternalReferenceUnavailable();
|
|
11942
12111
|
this.setValue(ErrorValueObject.create(error));
|
|
11943
12112
|
return 1;
|
|
11944
12113
|
}
|
|
@@ -12039,11 +12208,9 @@ let ReferenceNodeFactory = class ReferenceNodeFactory extends BaseAstNodeFactory
|
|
|
12039
12208
|
return this._getTableReferenceNode(tokenTrim, isPrepareMerge, false);
|
|
12040
12209
|
}
|
|
12041
12210
|
_getTableReferenceNode(tokenTrim, isPrepareMerge, isSuperTableDirectly = false) {
|
|
12042
|
-
if (!this._checkTokenIsTableReference(tokenTrim) && !isSuperTableDirectly) return;
|
|
12211
|
+
if ((!tokenTrim.includes("[") || !this._checkTokenIsTableReference(tokenTrim)) && !isSuperTableDirectly) return;
|
|
12043
12212
|
const { unitQualifier, tableName, columnStruct } = splitTableStructuredRef(tokenTrim);
|
|
12044
|
-
|
|
12045
|
-
const hasLocalTable = Array.from((tableMap === null || tableMap === void 0 ? void 0 : tableMap.keys()) || []).some((name) => name.toLocaleLowerCase() === tableName.toLocaleLowerCase());
|
|
12046
|
-
if (unitQualifier || hasLocalTable) return new ReferenceNode(this._currentConfigService, this._formulaRuntimeService, tokenTrim, 1, this._unitReferenceResolver, this._superTableService, this._externalReferenceDataLoader, isPrepareMerge, {
|
|
12213
|
+
return new ReferenceNode(this._currentConfigService, this._formulaRuntimeService, tokenTrim, 1, this._unitReferenceResolver, this._superTableService, this._externalReferenceDataLoader, isPrepareMerge, {
|
|
12047
12214
|
unitQualifier,
|
|
12048
12215
|
tableName,
|
|
12049
12216
|
columnStruct
|
|
@@ -12714,9 +12881,7 @@ let AstTreeBuilder = class AstTreeBuilder extends _univerjs_core.Disposable {
|
|
|
12714
12881
|
case 11:
|
|
12715
12882
|
calculateStack.push(astNode);
|
|
12716
12883
|
break;
|
|
12717
|
-
case 12:
|
|
12718
|
-
calculateStack.push(astNode);
|
|
12719
|
-
break;
|
|
12884
|
+
case 12: calculateStack.push(astNode);
|
|
12720
12885
|
}
|
|
12721
12886
|
}
|
|
12722
12887
|
const calculateStackCount = calculateStack.length;
|
|
@@ -13240,11 +13405,11 @@ const IFeatureCalculationManagerService = (0, _univerjs_core.createIdentifier)("
|
|
|
13240
13405
|
var OtherFormulaManagerService = class extends _univerjs_core.Disposable {
|
|
13241
13406
|
constructor(..._args) {
|
|
13242
13407
|
super(..._args);
|
|
13243
|
-
_defineProperty(this, "_otherFormulaData",
|
|
13408
|
+
_defineProperty(this, "_otherFormulaData", Object.create(null));
|
|
13244
13409
|
}
|
|
13245
13410
|
dispose() {
|
|
13246
13411
|
super.dispose();
|
|
13247
|
-
this._otherFormulaData =
|
|
13412
|
+
this._otherFormulaData = Object.create(null);
|
|
13248
13413
|
}
|
|
13249
13414
|
remove(searchParam) {
|
|
13250
13415
|
var _this$_otherFormulaDa;
|
|
@@ -13263,8 +13428,8 @@ var OtherFormulaManagerService = class extends _univerjs_core.Disposable {
|
|
|
13263
13428
|
}
|
|
13264
13429
|
register(insertParam) {
|
|
13265
13430
|
const { unitId, subUnitId, formulaId, item } = insertParam;
|
|
13266
|
-
if (!this._otherFormulaData[unitId]) this._otherFormulaData[unitId] =
|
|
13267
|
-
if (!this._otherFormulaData[unitId][subUnitId]) this._otherFormulaData[unitId][subUnitId] =
|
|
13431
|
+
if (!this._otherFormulaData[unitId]) this._otherFormulaData[unitId] = Object.create(null);
|
|
13432
|
+
if (!this._otherFormulaData[unitId][subUnitId]) this._otherFormulaData[unitId][subUnitId] = Object.create(null);
|
|
13268
13433
|
this._otherFormulaData[unitId][subUnitId][formulaId] = item;
|
|
13269
13434
|
}
|
|
13270
13435
|
batchRegister(formulaData) {
|
|
@@ -13790,7 +13955,8 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends _unive
|
|
|
13790
13955
|
}
|
|
13791
13956
|
_getFeatureFormulaTree(featureId, treeId, params) {
|
|
13792
13957
|
const { unitId, subUnitId, dependencyRanges, getDirtyData } = params;
|
|
13793
|
-
const
|
|
13958
|
+
const treeIdNum = treeId || generateRandomDependencyTreeId(this._dependencyManagerService);
|
|
13959
|
+
const FDtree = new FormulaDependencyTree(treeIdNum);
|
|
13794
13960
|
FDtree.unitId = unitId;
|
|
13795
13961
|
FDtree.subUnitId = subUnitId;
|
|
13796
13962
|
FDtree.rangeList = dependencyRanges;
|
|
@@ -13801,7 +13967,7 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends _unive
|
|
|
13801
13967
|
FDtree.type = 2;
|
|
13802
13968
|
this._dependencyManagerService.addFeatureFormulaDependency(unitId, subUnitId, featureId, FDtree);
|
|
13803
13969
|
this._dependencyTreeCache.set(FDtree.treeId, FDtree);
|
|
13804
|
-
if (
|
|
13970
|
+
if (treeId != null) FDtree.isCache = true;
|
|
13805
13971
|
return FDtree;
|
|
13806
13972
|
}
|
|
13807
13973
|
_registerOtherFormulas(otherFormulaData, otherFormulaDataKeys, treeList) {
|
|
@@ -13826,7 +13992,8 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends _unive
|
|
|
13826
13992
|
if (hasOtherFormula) isCache = true;
|
|
13827
13993
|
const { firstRow, firstColumn } = this._getFirstCellOfRange(ranges);
|
|
13828
13994
|
const treeMatrix = this._dependencyManagerService.getOtherFormulaDependency(unitId, subUnitId, subFormulaDataId);
|
|
13829
|
-
const
|
|
13995
|
+
const firstTreeId = (treeMatrix === null || treeMatrix === void 0 ? void 0 : treeMatrix.getValue(0, 0)) ?? generateRandomDependencyTreeId(this._dependencyManagerService);
|
|
13996
|
+
const firstFDtree = new FormulaDependencyTree(firstTreeId);
|
|
13830
13997
|
for (let i = 0; i < ranges.length; i++) {
|
|
13831
13998
|
const range = ranges[i];
|
|
13832
13999
|
const { startRow, startColumn } = range;
|
|
@@ -14221,6 +14388,14 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends _unive
|
|
|
14221
14388
|
const node = preCalculateNodeList[i];
|
|
14222
14389
|
const value = await this._executeNode(node, refOffsetX, refOffsetY);
|
|
14223
14390
|
if (value != null) rangeList.push(...value.toUnitRanges());
|
|
14391
|
+
else if (node.nodeType === 11) {
|
|
14392
|
+
const intersectionRanges = node.getReferenceRanges();
|
|
14393
|
+
rangeList.push(...intersectionRanges ?? await this._getRangeListByNode({
|
|
14394
|
+
node,
|
|
14395
|
+
refOffsetX,
|
|
14396
|
+
refOffsetY
|
|
14397
|
+
}));
|
|
14398
|
+
}
|
|
14224
14399
|
node.setValue(null);
|
|
14225
14400
|
}
|
|
14226
14401
|
return rangeList;
|
|
@@ -14666,7 +14841,7 @@ let CalculateFormulaService = class CalculateFormulaService extends _univerjs_co
|
|
|
14666
14841
|
}
|
|
14667
14842
|
_getArrayFormulaDirtyRangeAndExcludedRange(arrayFormulaRange, runtimeFeatureRange) {
|
|
14668
14843
|
const dirtyRanges = [];
|
|
14669
|
-
const excludedCell =
|
|
14844
|
+
const excludedCell = Object.create(null);
|
|
14670
14845
|
Object.keys(arrayFormulaRange).forEach((unitId) => {
|
|
14671
14846
|
const sheetArrayFormulaRange = arrayFormulaRange[unitId];
|
|
14672
14847
|
if (sheetArrayFormulaRange == null) return true;
|
|
@@ -14682,7 +14857,7 @@ let CalculateFormulaService = class CalculateFormulaService extends _univerjs_co
|
|
|
14682
14857
|
range
|
|
14683
14858
|
});
|
|
14684
14859
|
});
|
|
14685
|
-
if (excludedCell[unitId] == null) excludedCell[unitId] =
|
|
14860
|
+
if (excludedCell[unitId] == null) excludedCell[unitId] = Object.create(null);
|
|
14686
14861
|
excludedCell[unitId][sheetId] = newCellData;
|
|
14687
14862
|
});
|
|
14688
14863
|
});
|
|
@@ -14787,21 +14962,21 @@ let CalculateFormulaService = class CalculateFormulaService extends _univerjs_co
|
|
|
14787
14962
|
this._currentConfigService.loadDataLite(rowData);
|
|
14788
14963
|
const unitData = this._currentConfigService.getUnitData();
|
|
14789
14964
|
this._runtimeService.reset();
|
|
14790
|
-
const result =
|
|
14965
|
+
const result = Object.create(null);
|
|
14791
14966
|
for (const unitId of Object.keys(formulas)) {
|
|
14792
14967
|
const sheetFormulas = formulas[unitId];
|
|
14793
14968
|
if (sheetFormulas == null) continue;
|
|
14794
|
-
result[unitId] =
|
|
14969
|
+
result[unitId] = Object.create(null);
|
|
14795
14970
|
for (const sheetId of Object.keys(sheetFormulas)) {
|
|
14796
14971
|
var _unitData$unitId;
|
|
14797
14972
|
const rowFormulas = sheetFormulas[sheetId];
|
|
14798
14973
|
if (rowFormulas == null) continue;
|
|
14799
14974
|
const sheetItem = (_unitData$unitId = unitData[unitId]) === null || _unitData$unitId === void 0 ? void 0 : _unitData$unitId[sheetId];
|
|
14800
14975
|
if (sheetItem == null) continue;
|
|
14801
|
-
result[unitId][sheetId] =
|
|
14976
|
+
result[unitId][sheetId] = Object.create(null);
|
|
14802
14977
|
for (const rowString of Object.keys(rowFormulas)) {
|
|
14803
14978
|
const row = Number.parseInt(rowString);
|
|
14804
|
-
result[unitId][sheetId][row] =
|
|
14979
|
+
result[unitId][sheetId][row] = Object.create(null);
|
|
14805
14980
|
const cellData = rowFormulas[row];
|
|
14806
14981
|
if (!cellData) continue;
|
|
14807
14982
|
for (const columnString of Object.keys(cellData)) {
|
|
@@ -14995,7 +15170,7 @@ let CalculateController = class CalculateController extends _univerjs_core.Dispo
|
|
|
14995
15170
|
case 3:
|
|
14996
15171
|
this._applyResult(data);
|
|
14997
15172
|
break;
|
|
14998
|
-
case 0:
|
|
15173
|
+
case 0:
|
|
14999
15174
|
}
|
|
15000
15175
|
this._commandService.executeCommand(SetFormulaCalculationNotificationMutation.id, { functionsExecutedState }, { onlyLocal: true });
|
|
15001
15176
|
});
|
|
@@ -16441,12 +16616,13 @@ var BaseFunction = class {
|
|
|
16441
16616
|
}
|
|
16442
16617
|
createReferenceObject(reference, range) {
|
|
16443
16618
|
const unitId = reference.getForcedUnitId() || reference.getDefaultUnitId() || "";
|
|
16444
|
-
const sheetId = reference.getForcedSheetId() || reference.
|
|
16445
|
-
const
|
|
16619
|
+
const sheetId = reference.getForcedSheetId() || reference.getDefaultSheetId() || "";
|
|
16620
|
+
const gridRangeName = {
|
|
16446
16621
|
unitId,
|
|
16447
16622
|
sheetName: reference.getForcedSheetName(),
|
|
16448
16623
|
range
|
|
16449
|
-
}
|
|
16624
|
+
};
|
|
16625
|
+
const token = serializeRangeToRefString(gridRangeName);
|
|
16450
16626
|
let referenceObject;
|
|
16451
16627
|
if (regexTestSingeRange(token)) referenceObject = new CellReferenceObject(token);
|
|
16452
16628
|
else if (regexTestSingleRow(token)) referenceObject = new RowReferenceObject(token);
|
|
@@ -16867,7 +17043,7 @@ let BESSEL;
|
|
|
16867
17043
|
.39894228
|
|
16868
17044
|
];
|
|
16869
17045
|
function bessel0(x) {
|
|
16870
|
-
if (x <= 3.75) return _horner(b0_a, x * x /
|
|
17046
|
+
if (x <= 3.75) return _horner(b0_a, x * x / 14.0625);
|
|
16871
17047
|
return Math.exp(Math.abs(x)) / Math.sqrt(Math.abs(x)) * _horner(b0_b, 3.75 / Math.abs(x));
|
|
16872
17048
|
}
|
|
16873
17049
|
const b1_a = [
|
|
@@ -16891,7 +17067,7 @@ let BESSEL;
|
|
|
16891
17067
|
.39894228
|
|
16892
17068
|
];
|
|
16893
17069
|
function bessel1(x) {
|
|
16894
|
-
if (x < 3.75) return x * _horner(b1_a, x * x /
|
|
17070
|
+
if (x < 3.75) return x * _horner(b1_a, x * x / 14.0625);
|
|
16895
17071
|
return (x < 0 ? -1 : 1) * Math.exp(Math.abs(x)) / Math.sqrt(Math.abs(x)) * _horner(b1_b, 3.75 / Math.abs(x));
|
|
16896
17072
|
}
|
|
16897
17073
|
return function besseli(x, n) {
|
|
@@ -17111,22 +17287,9 @@ function calculateMdeterm(matrix) {
|
|
|
17111
17287
|
return det === 0 ? 0 : det;
|
|
17112
17288
|
}
|
|
17113
17289
|
function calculateMinverse(matrix) {
|
|
17114
|
-
const
|
|
17115
|
-
if (
|
|
17116
|
-
|
|
17117
|
-
return adjoint(matrix).map((row) => row.map((value) => value / det));
|
|
17118
|
-
}
|
|
17119
|
-
function minor(matrix, row, col) {
|
|
17120
|
-
return matrix.filter((_, r) => r !== row).map((row) => row.filter((_, c) => c !== col));
|
|
17121
|
-
}
|
|
17122
|
-
function adjoint(matrix) {
|
|
17123
|
-
const n = matrix.length;
|
|
17124
|
-
const adj = Array.from({ length: n }, () => new Array(n).fill(0));
|
|
17125
|
-
for (let i = 0; i < n; i++) for (let j = 0; j < n; j++) {
|
|
17126
|
-
const res = ((i + j) % 2 === 0 ? 1 : -1) * calculateMdeterm(minor(matrix, i, j));
|
|
17127
|
-
adj[j][i] = res === 0 ? 0 : res;
|
|
17128
|
-
}
|
|
17129
|
-
return adj;
|
|
17290
|
+
const { smallPivotDetected, luMatrix, permutation } = performLUDecomposition(matrix, false, Number.EPSILON);
|
|
17291
|
+
if (smallPivotDetected) return null;
|
|
17292
|
+
return transformMatrix(luMatrix, permutation);
|
|
17130
17293
|
}
|
|
17131
17294
|
function calculateMmult(matrix1, matrix2) {
|
|
17132
17295
|
return matrix1.map((row) => matrix2[0].map((_, colIndex) => row.reduce((sum, element, rowIndex) => sum + element * matrix2[rowIndex][colIndex], 0)));
|
|
@@ -17139,8 +17302,8 @@ function inverseMatrixByLUD(matrix) {
|
|
|
17139
17302
|
if (smallPivotDetected) return null;
|
|
17140
17303
|
return transformMatrix(luMatrix, permutation);
|
|
17141
17304
|
}
|
|
17142
|
-
function performLUDecomposition(matrix) {
|
|
17143
|
-
const decomposedMatrix = matrixTranspose(matrix);
|
|
17305
|
+
function performLUDecomposition(matrix, transpose = true, minimumPivot = 1e-11) {
|
|
17306
|
+
const decomposedMatrix = transpose ? matrixTranspose(matrix) : matrix.map((row) => [...row]);
|
|
17144
17307
|
const numRows = decomposedMatrix.length;
|
|
17145
17308
|
const numCols = decomposedMatrix[0].length;
|
|
17146
17309
|
let isRowSwap = true;
|
|
@@ -17165,7 +17328,8 @@ function performLUDecomposition(matrix) {
|
|
|
17165
17328
|
pivotRow = r;
|
|
17166
17329
|
}
|
|
17167
17330
|
}
|
|
17168
|
-
|
|
17331
|
+
const pivot = Math.abs(luMatrix[pivotRow][c]);
|
|
17332
|
+
if (!Number.isFinite(pivot) || pivot <= minimumPivot) {
|
|
17169
17333
|
smallPivotDetected = true;
|
|
17170
17334
|
break;
|
|
17171
17335
|
}
|
|
@@ -18134,6 +18298,53 @@ function getSlopeAndInterceptOfConstbIsFalse(knownXsValues, knownYsValues) {
|
|
|
18134
18298
|
intercept: 0
|
|
18135
18299
|
};
|
|
18136
18300
|
}
|
|
18301
|
+
function solveLeastSquaresByQR(matrix, values) {
|
|
18302
|
+
var _matrix$;
|
|
18303
|
+
const rows = matrix.length;
|
|
18304
|
+
const columns = ((_matrix$ = matrix[0]) === null || _matrix$ === void 0 ? void 0 : _matrix$.length) ?? 0;
|
|
18305
|
+
if (!columns || rows < columns || values.length !== rows || matrix.some((row) => row.length !== columns)) return null;
|
|
18306
|
+
const qr = matrix.map((row) => [...row]);
|
|
18307
|
+
const scales = [];
|
|
18308
|
+
for (let column = 0; column < columns; column++) {
|
|
18309
|
+
let sumSquares = 0;
|
|
18310
|
+
for (let row = 0; row < rows; row++) sumSquares += qr[row][column] ** 2;
|
|
18311
|
+
const scale = Math.sqrt(sumSquares);
|
|
18312
|
+
if (!Number.isFinite(scale) || scale === 0) return null;
|
|
18313
|
+
scales.push(scale);
|
|
18314
|
+
for (let row = 0; row < rows; row++) qr[row][column] /= scale;
|
|
18315
|
+
}
|
|
18316
|
+
const transformed = [...values];
|
|
18317
|
+
for (let pivot = 0; pivot < columns; pivot++) {
|
|
18318
|
+
let sumSquares = 0;
|
|
18319
|
+
for (let row = pivot; row < rows; row++) sumSquares += qr[row][pivot] ** 2;
|
|
18320
|
+
const norm = Math.sqrt(sumSquares);
|
|
18321
|
+
if (!Number.isFinite(norm) || norm <= Number.EPSILON * rows) return null;
|
|
18322
|
+
const alpha = qr[pivot][pivot] >= 0 ? -norm : norm;
|
|
18323
|
+
const reflector = Array.from({ length: rows - pivot }, (_, offset) => qr[pivot + offset][pivot]);
|
|
18324
|
+
reflector[0] -= alpha;
|
|
18325
|
+
const reflectorNorm = reflector.reduce((sum, value) => sum + value ** 2, 0);
|
|
18326
|
+
if (!Number.isFinite(reflectorNorm) || reflectorNorm === 0) return null;
|
|
18327
|
+
for (let column = pivot; column < columns; column++) {
|
|
18328
|
+
let projection = 0;
|
|
18329
|
+
for (let offset = 0; offset < reflector.length; offset++) projection += reflector[offset] * qr[pivot + offset][column];
|
|
18330
|
+
const factor = 2 * projection / reflectorNorm;
|
|
18331
|
+
for (let offset = 0; offset < reflector.length; offset++) qr[pivot + offset][column] -= factor * reflector[offset];
|
|
18332
|
+
}
|
|
18333
|
+
let projection = 0;
|
|
18334
|
+
for (let offset = 0; offset < reflector.length; offset++) projection += reflector[offset] * transformed[pivot + offset];
|
|
18335
|
+
const factor = 2 * projection / reflectorNorm;
|
|
18336
|
+
for (let offset = 0; offset < reflector.length; offset++) transformed[pivot + offset] -= factor * reflector[offset];
|
|
18337
|
+
}
|
|
18338
|
+
const coefficients = new Array(columns).fill(0);
|
|
18339
|
+
for (let row = columns - 1; row >= 0; row--) {
|
|
18340
|
+
const diagonal = qr[row][row];
|
|
18341
|
+
if (!Number.isFinite(diagonal) || Math.abs(diagonal) <= Number.EPSILON * rows) return null;
|
|
18342
|
+
let remainder = 0;
|
|
18343
|
+
for (let column = row + 1; column < columns; column++) remainder += qr[row][column] * coefficients[column];
|
|
18344
|
+
coefficients[row] = (transformed[row] - remainder) / diagonal;
|
|
18345
|
+
}
|
|
18346
|
+
return coefficients.map((coefficient, index) => coefficient / scales[index]);
|
|
18347
|
+
}
|
|
18137
18348
|
function getKnownsArrayCoefficients(knownYsValues, knownXsValues, newXsValues, constb, isExponentialTransform) {
|
|
18138
18349
|
const isOneRow = knownYsValues.length === 1 && knownYsValues[0].length > 1;
|
|
18139
18350
|
let Y = knownYsValues;
|
|
@@ -18148,15 +18359,14 @@ function getKnownsArrayCoefficients(knownYsValues, knownXsValues, newXsValues, c
|
|
|
18148
18359
|
if (constb) X = X.map((row) => [...row, 1]);
|
|
18149
18360
|
const XT = matrixTranspose(X);
|
|
18150
18361
|
const XTX = calculateMmult(XT, X);
|
|
18151
|
-
const XTY = calculateMmult(XT, Y);
|
|
18152
18362
|
let XTXInverse = inverseMatrixByLUD(XTX);
|
|
18153
18363
|
if (!XTXInverse) {
|
|
18154
18364
|
XTXInverse = inverseMatrixByUSV(XTX);
|
|
18155
18365
|
if (!XTXInverse) return ErrorValueObject.create("#N/A");
|
|
18156
18366
|
}
|
|
18157
|
-
|
|
18158
|
-
|
|
18159
|
-
|
|
18367
|
+
const solved = solveLeastSquaresByQR(X, Y.map((row) => row[0]));
|
|
18368
|
+
const coefficients = solved ? [solved] : matrixTranspose(calculateMmult(XTXInverse, calculateMmult(XT, Y)));
|
|
18369
|
+
if (!constb) coefficients[0].push(0);
|
|
18160
18370
|
const pop = coefficients[0].pop();
|
|
18161
18371
|
coefficients[0].reverse();
|
|
18162
18372
|
coefficients[0].push(pop);
|
|
@@ -18179,9 +18389,10 @@ function parseAggregateDataRefs(refs) {
|
|
|
18179
18389
|
let isError = false;
|
|
18180
18390
|
for (let i = 0; i < refs.length; i++) {
|
|
18181
18391
|
const ref = refs[i];
|
|
18182
|
-
if (ref.isReferenceObject())
|
|
18183
|
-
|
|
18184
|
-
|
|
18392
|
+
if (ref.isReferenceObject()) {
|
|
18393
|
+
if (ref.isMultiArea()) multiAreaRefs.push(ref);
|
|
18394
|
+
else normalRefs.push(ref);
|
|
18395
|
+
} else {
|
|
18185
18396
|
isError = true;
|
|
18186
18397
|
break;
|
|
18187
18398
|
}
|
|
@@ -18199,6 +18410,7 @@ function isRowHidden(rowData, rowIndex) {
|
|
|
18199
18410
|
}
|
|
18200
18411
|
const NESTED_AGGREGATE_FORMULA_CACHE = /* @__PURE__ */ new WeakMap();
|
|
18201
18412
|
function isNestedAggregateOrSubtotal(cellData, rowIndex, columnIndex, sheetId, unitId, formulaDataModel) {
|
|
18413
|
+
if (!cellData) return false;
|
|
18202
18414
|
const cellValue = cellData.getValue(rowIndex, columnIndex);
|
|
18203
18415
|
if (!(cellValue === null || cellValue === void 0 ? void 0 : cellValue.f) && !(cellValue === null || cellValue === void 0 ? void 0 : cellValue.si)) return false;
|
|
18204
18416
|
if (typeof cellValue.f === "string") return hasNestedAggregateFormula(cellValue.f);
|
|
@@ -19287,7 +19499,8 @@ var PercentileInc = class extends BaseFunction {
|
|
|
19287
19499
|
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(k);
|
|
19288
19500
|
if (isError) return errorObject;
|
|
19289
19501
|
const [kObject] = variants;
|
|
19290
|
-
|
|
19502
|
+
const kValue = +kObject.getValue();
|
|
19503
|
+
return getPercentileIncResult(array, kValue);
|
|
19291
19504
|
}
|
|
19292
19505
|
};
|
|
19293
19506
|
|
|
@@ -19325,8 +19538,10 @@ var PercentrankInc = class extends BaseFunction {
|
|
|
19325
19538
|
const significanceValue = Math.floor(+significanceObject.getValue());
|
|
19326
19539
|
const n = array.length;
|
|
19327
19540
|
if (n === 0 || xValue < array[0] || xValue > array[n - 1]) return ErrorValueObject.create("#N/A");
|
|
19328
|
-
if (n === 1)
|
|
19329
|
-
|
|
19541
|
+
if (n === 1) {
|
|
19542
|
+
if (xValue === array[0]) return NumberValueObject.create(1);
|
|
19543
|
+
else return ErrorValueObject.create("#N/A");
|
|
19544
|
+
}
|
|
19330
19545
|
let result = 0;
|
|
19331
19546
|
let match = false;
|
|
19332
19547
|
let i = 0;
|
|
@@ -19423,7 +19638,8 @@ var QuartileInc = class extends BaseFunction {
|
|
|
19423
19638
|
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(quart);
|
|
19424
19639
|
if (isError) return errorObject;
|
|
19425
19640
|
const [quartObject] = variants;
|
|
19426
|
-
|
|
19641
|
+
const quartValue = Math.floor(+quartObject.getValue());
|
|
19642
|
+
return getQuartileIncResult(array, quartValue);
|
|
19427
19643
|
}
|
|
19428
19644
|
};
|
|
19429
19645
|
|
|
@@ -19834,7 +20050,8 @@ var ZTest = class extends BaseFunction {
|
|
|
19834
20050
|
sigmaValue = Math.sqrt((sumSquare - 2 * mean * sum + n * mean ** 2) / (n - 1));
|
|
19835
20051
|
}
|
|
19836
20052
|
if (sigmaValue <= 0) return ErrorValueObject.create("#NUM!");
|
|
19837
|
-
const
|
|
20053
|
+
const z = (sum / n - xValue) / (sigmaValue / Math.sqrt(n));
|
|
20054
|
+
const result = 1 - normalCDF(z, 0, 1);
|
|
19838
20055
|
if (Number.isNaN(result) || !Number.isFinite(result)) return ErrorValueObject.create("#NUM!");
|
|
19839
20056
|
return NumberValueObject.create(result);
|
|
19840
20057
|
}
|
|
@@ -20102,7 +20319,8 @@ var Normsdist = class extends BaseFunction {
|
|
|
20102
20319
|
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(zObject);
|
|
20103
20320
|
if (isError) return errorObject;
|
|
20104
20321
|
const [_zObject] = variants;
|
|
20105
|
-
const
|
|
20322
|
+
const zValue = +_zObject.getValue();
|
|
20323
|
+
const result = normalCDF(zValue, 0, 1);
|
|
20106
20324
|
return NumberValueObject.create(result);
|
|
20107
20325
|
}
|
|
20108
20326
|
};
|
|
@@ -21039,8 +21257,10 @@ function getWeekendArray(weekend) {
|
|
|
21039
21257
|
if (!isValidWeekend(weekend)) return [];
|
|
21040
21258
|
if (typeof weekend === "string" && /^[0|1]{7}/.test(weekend)) {
|
|
21041
21259
|
const result = [];
|
|
21042
|
-
for (let i = 1; i <= weekend.length; i++) if (`${weekend[i - 1]}` === "1")
|
|
21043
|
-
|
|
21260
|
+
for (let i = 1; i <= weekend.length; i++) if (`${weekend[i - 1]}` === "1") {
|
|
21261
|
+
if (i === weekend.length) result.push(0);
|
|
21262
|
+
else result.push(i);
|
|
21263
|
+
}
|
|
21044
21264
|
return result;
|
|
21045
21265
|
}
|
|
21046
21266
|
return weekendNumberMap[Number(weekend)] || [];
|
|
@@ -21141,12 +21361,14 @@ function getDaysByNASD(startDateSerialNumber, endDateSerialNumber, dateSystem) {
|
|
|
21141
21361
|
if (startIsLastDayOfFebruary) startDay = 30;
|
|
21142
21362
|
else if (startDay === 31) startDay = 30;
|
|
21143
21363
|
if (endMonth === 2 && endDay === getDaysInMonth(endYear, endMonth - 1) && startIsLastDayOfFebruary) endDay = 30;
|
|
21144
|
-
else if (endDay === 31)
|
|
21145
|
-
|
|
21146
|
-
|
|
21147
|
-
|
|
21148
|
-
|
|
21149
|
-
|
|
21364
|
+
else if (endDay === 31) {
|
|
21365
|
+
if (startDay < 30) {
|
|
21366
|
+
endDateDate = (0, _univerjs_core.excelSerialToDate)(endDateSerialNumber + 1, dateSystem);
|
|
21367
|
+
endYear = endDateDate.getUTCFullYear();
|
|
21368
|
+
endMonth = endDateDate.getUTCMonth() + 1;
|
|
21369
|
+
endDay = endDateDate.getUTCDate();
|
|
21370
|
+
} else endDay = 30;
|
|
21371
|
+
}
|
|
21150
21372
|
const daysInYears = (endYear - startYear) * 360;
|
|
21151
21373
|
const daysInStartMonth = endDateSerialNumber >= startDateSerialNumber ? 30 - startDay : -startDay;
|
|
21152
21374
|
const daysInEndMonth = endDateSerialNumber >= startDateSerialNumber ? endDay : endDay - 30;
|
|
@@ -21310,7 +21532,8 @@ var DateFunction = class extends BaseFunction {
|
|
|
21310
21532
|
const dayValue = Math.floor(+_dayObject.getValue());
|
|
21311
21533
|
if (yearValue < 0 || yearValue > 9999) return ErrorValueObject.create("#NUM!");
|
|
21312
21534
|
if (yearValue >= 0 && yearValue < 1899) yearValue += 1900;
|
|
21313
|
-
const
|
|
21535
|
+
const firstDateOfMonth = new Date(Date.UTC(yearValue, monthValue - 1, 1));
|
|
21536
|
+
const currentSerial = (0, _univerjs_core.excelDateSerial)(firstDateOfMonth, this.getDateSystem()) + dayValue - 1;
|
|
21314
21537
|
if (currentSerial < 0) return ErrorValueObject.create("#NUM!");
|
|
21315
21538
|
return NumberValueObject.create(currentSerial, DEFAULT_DATE_FORMAT);
|
|
21316
21539
|
});
|
|
@@ -21519,7 +21742,8 @@ var Days360 = class extends BaseFunction {
|
|
|
21519
21742
|
if (typeof endDateSerialNumber !== "number") return endDateSerialNumber;
|
|
21520
21743
|
if (methodObject.isString()) methodObject = methodObject.convertToNumberObjectValue();
|
|
21521
21744
|
if (methodObject.isError()) return methodObject;
|
|
21522
|
-
const
|
|
21745
|
+
const methodValue = +methodObject.getValue();
|
|
21746
|
+
const { days } = getTwoDateDaysByBasis(startDateSerialNumber, endDateSerialNumber, !methodValue ? 0 : 4, this.getDateSystem());
|
|
21523
21747
|
const result = endDateSerialNumber >= startDateSerialNumber ? days : -days;
|
|
21524
21748
|
return NumberValueObject.create(result);
|
|
21525
21749
|
});
|
|
@@ -21559,7 +21783,8 @@ var Edate = class extends BaseFunction {
|
|
|
21559
21783
|
const month = _startDate.getUTCMonth() + monthsValue;
|
|
21560
21784
|
const day = _startDate.getUTCDate();
|
|
21561
21785
|
const lastDayOfTargetMonth = new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
|
|
21562
|
-
const
|
|
21786
|
+
const resultDate = new Date(Date.UTC(year, month, Math.min(day, lastDayOfTargetMonth)));
|
|
21787
|
+
const currentSerial = (0, _univerjs_core.excelDateSerial)(resultDate, this.getDateSystem());
|
|
21563
21788
|
return NumberValueObject.create(currentSerial, DEFAULT_DATE_FORMAT);
|
|
21564
21789
|
});
|
|
21565
21790
|
}
|
|
@@ -21599,7 +21824,8 @@ var Eomonth = class extends BaseFunction {
|
|
|
21599
21824
|
const startMonth = isDate1900SerialZero ? 0 : startDateDate.getUTCMonth();
|
|
21600
21825
|
const monthsValue = Math.floor(+_months.getValue());
|
|
21601
21826
|
if (Number.isNaN(monthsValue)) return ErrorValueObject.create("#VALUE!");
|
|
21602
|
-
const
|
|
21827
|
+
const targetDate = new Date(Date.UTC(startYear, startMonth + monthsValue + 1, 0));
|
|
21828
|
+
const result = (0, _univerjs_core.excelDateSerial)(targetDate, this.getDateSystem());
|
|
21603
21829
|
return NumberValueObject.create(result);
|
|
21604
21830
|
}
|
|
21605
21831
|
};
|
|
@@ -21964,7 +22190,8 @@ var Now = class extends BaseFunction {
|
|
|
21964
22190
|
}
|
|
21965
22191
|
calculate() {
|
|
21966
22192
|
const now = /* @__PURE__ */ new Date();
|
|
21967
|
-
const
|
|
22193
|
+
const utcNow = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds()));
|
|
22194
|
+
const currentSerial = (0, _univerjs_core.excelDateTimeSerial)(utcNow, this.getDateSystem());
|
|
21968
22195
|
return NumberValueObject.create(currentSerial, DEFAULT_NOW_FORMAT);
|
|
21969
22196
|
}
|
|
21970
22197
|
};
|
|
@@ -22057,7 +22284,8 @@ var Timevalue = class extends BaseFunction {
|
|
|
22057
22284
|
_handleSingleObject(timeTextObject) {
|
|
22058
22285
|
if (timeTextObject.isError()) return timeTextObject;
|
|
22059
22286
|
if (timeTextObject.isString()) {
|
|
22060
|
-
const
|
|
22287
|
+
const value = `${timeTextObject.getValue()}`;
|
|
22288
|
+
const parsedTime = (0, _univerjs_core.getNumfmtParseValueFilter)(value, { dateSystem: this.getDateSystem() });
|
|
22061
22289
|
if (parsedTime) {
|
|
22062
22290
|
let { v, z } = parsedTime;
|
|
22063
22291
|
if (z && isDate(z)) {
|
|
@@ -22121,7 +22349,8 @@ var Today = class extends BaseFunction {
|
|
|
22121
22349
|
}
|
|
22122
22350
|
calculate() {
|
|
22123
22351
|
const now = /* @__PURE__ */ new Date();
|
|
22124
|
-
const
|
|
22352
|
+
const utcNow = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()));
|
|
22353
|
+
const currentSerial = (0, _univerjs_core.excelDateSerial)(utcNow, this.getDateSystem());
|
|
22125
22354
|
return NumberValueObject.create(currentSerial, DEFAULT_DATE_FORMAT);
|
|
22126
22355
|
}
|
|
22127
22356
|
};
|
|
@@ -23022,13 +23251,15 @@ var Complex$1 = class Complex$1 {
|
|
|
23022
23251
|
this._isError = true;
|
|
23023
23252
|
return;
|
|
23024
23253
|
}
|
|
23025
|
-
if (plus >= 0)
|
|
23026
|
-
|
|
23027
|
-
|
|
23254
|
+
if (plus >= 0) {
|
|
23255
|
+
if (Number.isNaN(+inumberStr.substring(0, plus)) || Number.isNaN(+inumberStr.substring(plus + 1, inumberStr.length - 1))) this._isError = true;
|
|
23256
|
+
else this._realNum = +inumberStr.substring(0, plus);
|
|
23257
|
+
} else if (Number.isNaN(+inumberStr.substring(0, minus)) || Number.isNaN(+inumberStr.substring(minus + 1, inumberStr.length - 1))) this._isError = true;
|
|
23028
23258
|
else this._realNum = +inumberStr.substring(0, minus);
|
|
23029
|
-
} else if (unit)
|
|
23030
|
-
|
|
23031
|
-
|
|
23259
|
+
} else if (unit) {
|
|
23260
|
+
if (Number.isNaN(+inumberStr.substring(0, inumberStr.length - 1))) this._isError = true;
|
|
23261
|
+
else this._realNum = 0;
|
|
23262
|
+
} else if (Number.isNaN(+inumberStr)) this._isError = true;
|
|
23032
23263
|
else this._realNum = +inumberStr;
|
|
23033
23264
|
}
|
|
23034
23265
|
_getImAginary() {
|
|
@@ -23054,13 +23285,15 @@ var Complex$1 = class Complex$1 {
|
|
|
23054
23285
|
this._isError = true;
|
|
23055
23286
|
return;
|
|
23056
23287
|
}
|
|
23057
|
-
if (plus >= 0)
|
|
23058
|
-
|
|
23059
|
-
|
|
23288
|
+
if (plus >= 0) {
|
|
23289
|
+
if (Number.isNaN(+inumberStr.substring(0, plus)) || Number.isNaN(+inumberStr.substring(plus + 1, inumberStr.length - 1))) this._isError = true;
|
|
23290
|
+
else this._iNum = +inumberStr.substring(plus + 1, inumberStr.length - 1);
|
|
23291
|
+
} else if (Number.isNaN(+inumberStr.substring(0, minus)) || Number.isNaN(+inumberStr.substring(minus + 1, inumberStr.length - 1))) this._isError = true;
|
|
23060
23292
|
else this._iNum = -+inumberStr.substring(minus + 1, inumberStr.length - 1);
|
|
23061
|
-
} else if (unit)
|
|
23062
|
-
|
|
23063
|
-
|
|
23293
|
+
} else if (unit) {
|
|
23294
|
+
if (Number.isNaN(+inumberStr.substring(0, inumberStr.length - 1))) this._isError = true;
|
|
23295
|
+
else this._iNum = +inumberStr.substring(0, inumberStr.length - 1);
|
|
23296
|
+
} else if (Number.isNaN(+inumberStr)) this._isError = true;
|
|
23064
23297
|
else this._iNum = 0;
|
|
23065
23298
|
}
|
|
23066
23299
|
_getImSuffix() {
|
|
@@ -23216,10 +23449,12 @@ var Complex$1 = class Complex$1 {
|
|
|
23216
23449
|
return Complex$1.getComplex(realNum, iNum, this._suffix);
|
|
23217
23450
|
}
|
|
23218
23451
|
Power(number) {
|
|
23219
|
-
if (this._realNum === 0 && this._iNum === 0)
|
|
23220
|
-
|
|
23221
|
-
|
|
23222
|
-
|
|
23452
|
+
if (this._realNum === 0 && this._iNum === 0) {
|
|
23453
|
+
if (number > 0) return Complex$1.getComplex(this._realNum, this._iNum, this._suffix);
|
|
23454
|
+
else {
|
|
23455
|
+
this._isError = true;
|
|
23456
|
+
return "";
|
|
23457
|
+
}
|
|
23223
23458
|
}
|
|
23224
23459
|
let power = decimal_js.default.sqrt(decimal_js.default.pow(this._realNum, 2).add(decimal_js.default.pow(this._iNum, 2)));
|
|
23225
23460
|
let phi = decimal_js.default.acos(new decimal_js.default(this._realNum).div(power));
|
|
@@ -23357,7 +23592,8 @@ var Complex = class extends BaseFunction {
|
|
|
23357
23592
|
_defineProperty(this, "maxParams", 3);
|
|
23358
23593
|
}
|
|
23359
23594
|
calculate(realNum, iNum, suffix) {
|
|
23360
|
-
const
|
|
23595
|
+
const _suffix = suffix ?? StringValueObject.create("i");
|
|
23596
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(realNum, iNum, _suffix);
|
|
23361
23597
|
if (isError) return errorObject;
|
|
23362
23598
|
const [realNumObject, iNumObject, suffixObject] = variants;
|
|
23363
23599
|
const realNumValue = +realNumObject.getValue();
|
|
@@ -24899,10 +25135,8 @@ var Convert = class extends BaseFunction {
|
|
|
24899
25135
|
if (from === null || to === null) return ErrorValueObject.create("#N/A");
|
|
24900
25136
|
if (from[3] !== to[3]) return ErrorValueObject.create("#N/A");
|
|
24901
25137
|
let result;
|
|
24902
|
-
if (from[3] === "temperature")
|
|
24903
|
-
|
|
24904
|
-
result = +result.toFixed(2);
|
|
24905
|
-
} else result = numberValue * from[6] * fromMultiplier / (to[6] * toMultiplier);
|
|
25138
|
+
if (from[3] === "temperature") result = this._getTemperatureConversion(numberValue, from[1], to[1]);
|
|
25139
|
+
else result = numberValue * from[6] * fromMultiplier / (to[6] * toMultiplier);
|
|
24906
25140
|
return NumberValueObject.create(result);
|
|
24907
25141
|
}
|
|
24908
25142
|
_lookupFromAndToUnits(fromUnitValue, toUnitValue) {
|
|
@@ -25157,7 +25391,8 @@ var Delta = class extends BaseFunction {
|
|
|
25157
25391
|
_defineProperty(this, "maxParams", 2);
|
|
25158
25392
|
}
|
|
25159
25393
|
calculate(number1, number2) {
|
|
25160
|
-
const
|
|
25394
|
+
const _number2 = number2 ?? NumberValueObject.create(0);
|
|
25395
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(number1, _number2);
|
|
25161
25396
|
if (isError) return errorObject;
|
|
25162
25397
|
const [number1Object, number2Object] = variants;
|
|
25163
25398
|
const number1Value = +number1Object.getValue();
|
|
@@ -25265,7 +25500,8 @@ var Gestep = class extends BaseFunction {
|
|
|
25265
25500
|
}
|
|
25266
25501
|
calculate(number, step) {
|
|
25267
25502
|
if (number.isNull()) return ErrorValueObject.create("#N/A");
|
|
25268
|
-
const
|
|
25503
|
+
const _step = step ?? NumberValueObject.create(0);
|
|
25504
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(number, _step);
|
|
25269
25505
|
if (isError) return errorObject;
|
|
25270
25506
|
const [numberObject, stepObject] = variants;
|
|
25271
25507
|
const numberValue = +numberObject.getValue();
|
|
@@ -25389,7 +25625,8 @@ var Imabs = class extends BaseFunction {
|
|
|
25389
25625
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25390
25626
|
if (isError) return errorObject;
|
|
25391
25627
|
const [inumberObject] = variants;
|
|
25392
|
-
const
|
|
25628
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25629
|
+
const complex = new Complex$1(inumberValue);
|
|
25393
25630
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25394
25631
|
const result = complex.Abs();
|
|
25395
25632
|
return NumberValueObject.create(result);
|
|
@@ -25408,7 +25645,8 @@ var Imaginary = class extends BaseFunction {
|
|
|
25408
25645
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25409
25646
|
if (isError) return errorObject;
|
|
25410
25647
|
const [inumberObject] = variants;
|
|
25411
|
-
const
|
|
25648
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25649
|
+
const complex = new Complex$1(inumberValue);
|
|
25412
25650
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25413
25651
|
const result = complex.getINum();
|
|
25414
25652
|
return NumberValueObject.create(result);
|
|
@@ -25427,7 +25665,8 @@ var Imargument = class extends BaseFunction {
|
|
|
25427
25665
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25428
25666
|
if (isError) return errorObject;
|
|
25429
25667
|
const [inumberObject] = variants;
|
|
25430
|
-
const
|
|
25668
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25669
|
+
const complex = new Complex$1(inumberValue);
|
|
25431
25670
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25432
25671
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return ErrorValueObject.create("#DIV/0!");
|
|
25433
25672
|
const result = complex.Argument();
|
|
@@ -25447,7 +25686,8 @@ var Imconjugate = class extends BaseFunction {
|
|
|
25447
25686
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25448
25687
|
if (isError) return errorObject;
|
|
25449
25688
|
const [inumberObject] = variants;
|
|
25450
|
-
const
|
|
25689
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25690
|
+
const complex = new Complex$1(inumberValue);
|
|
25451
25691
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25452
25692
|
const result = complex.Conjugate();
|
|
25453
25693
|
if (typeof result === "number" || (0, _univerjs_core.isRealNum)(result)) return NumberValueObject.create(+result);
|
|
@@ -25467,7 +25707,8 @@ var Imcos = class extends BaseFunction {
|
|
|
25467
25707
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25468
25708
|
if (isError) return errorObject;
|
|
25469
25709
|
const [inumberObject] = variants;
|
|
25470
|
-
const
|
|
25710
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25711
|
+
const complex = new Complex$1(inumberValue);
|
|
25471
25712
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25472
25713
|
const result = complex.Cos();
|
|
25473
25714
|
if (typeof result === "number" || (0, _univerjs_core.isRealNum)(result)) return NumberValueObject.create(+result);
|
|
@@ -25487,7 +25728,8 @@ var Imcosh = class extends BaseFunction {
|
|
|
25487
25728
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25488
25729
|
if (isError) return errorObject;
|
|
25489
25730
|
const [inumberObject] = variants;
|
|
25490
|
-
const
|
|
25731
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25732
|
+
const complex = new Complex$1(inumberValue);
|
|
25491
25733
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25492
25734
|
const result = complex.Cosh();
|
|
25493
25735
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
@@ -25508,7 +25750,8 @@ var Imcot = class extends BaseFunction {
|
|
|
25508
25750
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25509
25751
|
if (isError) return errorObject;
|
|
25510
25752
|
const [inumberObject] = variants;
|
|
25511
|
-
const
|
|
25753
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25754
|
+
const complex = new Complex$1(inumberValue);
|
|
25512
25755
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25513
25756
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return ErrorValueObject.create("#NUM!");
|
|
25514
25757
|
const result = complex.Cot();
|
|
@@ -25529,7 +25772,8 @@ var Imcoth = class extends BaseFunction {
|
|
|
25529
25772
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25530
25773
|
if (isError) return errorObject;
|
|
25531
25774
|
const [inumberObject] = variants;
|
|
25532
|
-
const
|
|
25775
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25776
|
+
const complex = new Complex$1(inumberValue);
|
|
25533
25777
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25534
25778
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return ErrorValueObject.create("#NUM!");
|
|
25535
25779
|
const result = complex.Coth();
|
|
@@ -25551,7 +25795,8 @@ var Imcsc = class extends BaseFunction {
|
|
|
25551
25795
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25552
25796
|
if (isError) return errorObject;
|
|
25553
25797
|
const [inumberObject] = variants;
|
|
25554
|
-
const
|
|
25798
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25799
|
+
const complex = new Complex$1(inumberValue);
|
|
25555
25800
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25556
25801
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return ErrorValueObject.create("#NUM!");
|
|
25557
25802
|
const result = complex.Csc();
|
|
@@ -25572,7 +25817,8 @@ var Imcsch = class extends BaseFunction {
|
|
|
25572
25817
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25573
25818
|
if (isError) return errorObject;
|
|
25574
25819
|
const [inumberObject] = variants;
|
|
25575
|
-
const
|
|
25820
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25821
|
+
const complex = new Complex$1(inumberValue);
|
|
25576
25822
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25577
25823
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return ErrorValueObject.create("#NUM!");
|
|
25578
25824
|
const result = complex.Csch();
|
|
@@ -25619,7 +25865,8 @@ var Imexp = class extends BaseFunction {
|
|
|
25619
25865
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25620
25866
|
if (isError) return errorObject;
|
|
25621
25867
|
const [inumberObject] = variants;
|
|
25622
|
-
const
|
|
25868
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25869
|
+
const complex = new Complex$1(inumberValue);
|
|
25623
25870
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25624
25871
|
const result = complex.Exp();
|
|
25625
25872
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
@@ -25640,7 +25887,8 @@ var Imln = class extends BaseFunction {
|
|
|
25640
25887
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25641
25888
|
if (isError) return errorObject;
|
|
25642
25889
|
const [inumberObject] = variants;
|
|
25643
|
-
const
|
|
25890
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25891
|
+
const complex = new Complex$1(inumberValue);
|
|
25644
25892
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25645
25893
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return ErrorValueObject.create("#NUM!");
|
|
25646
25894
|
const result = complex.Ln();
|
|
@@ -25696,7 +25944,8 @@ var Imlog2 = class extends BaseFunction {
|
|
|
25696
25944
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25697
25945
|
if (isError) return errorObject;
|
|
25698
25946
|
const [inumberObject] = variants;
|
|
25699
|
-
const
|
|
25947
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25948
|
+
const complex = new Complex$1(inumberValue);
|
|
25700
25949
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25701
25950
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return ErrorValueObject.create("#NUM!");
|
|
25702
25951
|
const result = complex.Log(2);
|
|
@@ -25717,7 +25966,8 @@ var Imlog10 = class extends BaseFunction {
|
|
|
25717
25966
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25718
25967
|
if (isError) return errorObject;
|
|
25719
25968
|
const [inumberObject] = variants;
|
|
25720
|
-
const
|
|
25969
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25970
|
+
const complex = new Complex$1(inumberValue);
|
|
25721
25971
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25722
25972
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return ErrorValueObject.create("#NUM!");
|
|
25723
25973
|
const result = complex.Log(10);
|
|
@@ -25739,7 +25989,8 @@ var Impower = class extends BaseFunction {
|
|
|
25739
25989
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber, number);
|
|
25740
25990
|
if (isError) return errorObject;
|
|
25741
25991
|
const [inumberObject, numberObject] = variants;
|
|
25742
|
-
const
|
|
25992
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25993
|
+
const complex = new Complex$1(inumberValue);
|
|
25743
25994
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25744
25995
|
const numberValue = +numberObject.getValue();
|
|
25745
25996
|
if (Number.isNaN(numberValue)) return ErrorValueObject.create("#VALUE!");
|
|
@@ -25813,7 +26064,8 @@ var Imreal = class extends BaseFunction {
|
|
|
25813
26064
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25814
26065
|
if (isError) return errorObject;
|
|
25815
26066
|
const [inumberObject] = variants;
|
|
25816
|
-
const
|
|
26067
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
26068
|
+
const complex = new Complex$1(inumberValue);
|
|
25817
26069
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25818
26070
|
const result = complex.getRealNum();
|
|
25819
26071
|
return NumberValueObject.create(result);
|
|
@@ -25832,7 +26084,8 @@ var Imsec = class extends BaseFunction {
|
|
|
25832
26084
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25833
26085
|
if (isError) return errorObject;
|
|
25834
26086
|
const [inumberObject] = variants;
|
|
25835
|
-
const
|
|
26087
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
26088
|
+
const complex = new Complex$1(inumberValue);
|
|
25836
26089
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25837
26090
|
const result = complex.Sec();
|
|
25838
26091
|
if (typeof result === "number" || (0, _univerjs_core.isRealNum)(result)) return NumberValueObject.create(+result);
|
|
@@ -25852,7 +26105,8 @@ var Imsech = class extends BaseFunction {
|
|
|
25852
26105
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25853
26106
|
if (isError) return errorObject;
|
|
25854
26107
|
const [inumberObject] = variants;
|
|
25855
|
-
const
|
|
26108
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
26109
|
+
const complex = new Complex$1(inumberValue);
|
|
25856
26110
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25857
26111
|
const result = complex.Sech();
|
|
25858
26112
|
if (typeof result === "number" || (0, _univerjs_core.isRealNum)(result)) return NumberValueObject.create(+result);
|
|
@@ -25872,7 +26126,8 @@ var Imsin = class extends BaseFunction {
|
|
|
25872
26126
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25873
26127
|
if (isError) return errorObject;
|
|
25874
26128
|
const [inumberObject] = variants;
|
|
25875
|
-
const
|
|
26129
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
26130
|
+
const complex = new Complex$1(inumberValue);
|
|
25876
26131
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25877
26132
|
const result = complex.Sin();
|
|
25878
26133
|
if (typeof result === "number" || (0, _univerjs_core.isRealNum)(result)) return NumberValueObject.create(+result);
|
|
@@ -25892,7 +26147,8 @@ var Imsinh = class extends BaseFunction {
|
|
|
25892
26147
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25893
26148
|
if (isError) return errorObject;
|
|
25894
26149
|
const [inumberObject] = variants;
|
|
25895
|
-
const
|
|
26150
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
26151
|
+
const complex = new Complex$1(inumberValue);
|
|
25896
26152
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25897
26153
|
const result = complex.Sinh();
|
|
25898
26154
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
@@ -25913,7 +26169,8 @@ var Imsqrt = class extends BaseFunction {
|
|
|
25913
26169
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25914
26170
|
if (isError) return errorObject;
|
|
25915
26171
|
const [inumberObject] = variants;
|
|
25916
|
-
const
|
|
26172
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
26173
|
+
const complex = new Complex$1(inumberValue);
|
|
25917
26174
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25918
26175
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return NumberValueObject.create(0);
|
|
25919
26176
|
const result = complex.Sqrt();
|
|
@@ -26010,7 +26267,8 @@ var Imtan = class extends BaseFunction {
|
|
|
26010
26267
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
26011
26268
|
if (isError) return errorObject;
|
|
26012
26269
|
const [inumberObject] = variants;
|
|
26013
|
-
const
|
|
26270
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
26271
|
+
const complex = new Complex$1(inumberValue);
|
|
26014
26272
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
26015
26273
|
const result = complex.Tan();
|
|
26016
26274
|
if (typeof result === "number" || (0, _univerjs_core.isRealNum)(result)) return NumberValueObject.create(+result);
|
|
@@ -26030,7 +26288,8 @@ var Imtanh = class extends BaseFunction {
|
|
|
26030
26288
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
26031
26289
|
if (isError) return errorObject;
|
|
26032
26290
|
const [inumberObject] = variants;
|
|
26033
|
-
const
|
|
26291
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
26292
|
+
const complex = new Complex$1(inumberValue);
|
|
26034
26293
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
26035
26294
|
const result = complex.Tanh();
|
|
26036
26295
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
@@ -26315,7 +26574,8 @@ function getCouponSchedule(settlementSerialNumber, maturitySerialNumber, frequen
|
|
|
26315
26574
|
};
|
|
26316
26575
|
}
|
|
26317
26576
|
function calculateCoupdaybs(settlementSerialNumber, maturitySerialNumber, frequency, basis, dateSystem = _univerjs_core.DateSystem.Date1900) {
|
|
26318
|
-
const
|
|
26577
|
+
const coupDateSerialNumber = calculateCouppcd(settlementSerialNumber, maturitySerialNumber, frequency, dateSystem);
|
|
26578
|
+
const { days } = getTwoDateDaysByBasis(coupDateSerialNumber, settlementSerialNumber, basis, dateSystem);
|
|
26319
26579
|
return days;
|
|
26320
26580
|
}
|
|
26321
26581
|
function calculateCoupdays(settlementSerialNumber, maturitySerialNumber, frequency, basis, dateSystem = _univerjs_core.DateSystem.Date1900) {
|
|
@@ -26412,7 +26672,8 @@ function calculateOddLongFirstCoupon(settlementSerialNumber, maturitySerialNumbe
|
|
|
26412
26672
|
let DSC;
|
|
26413
26673
|
if (basis === 2 || basis === 3) DSC = getPositiveDaysBetween(settlementSerialNumber, calculateCoupncd(settlementSerialNumber, firstCouponSerialNumber, frequency, dateSystem), basis, dateSystem);
|
|
26414
26674
|
else {
|
|
26415
|
-
const
|
|
26675
|
+
const couppcd = calculateCouppcd(settlementSerialNumber, firstCouponSerialNumber, frequency, dateSystem);
|
|
26676
|
+
const { days } = getTwoDateDaysByBasis(couppcd, settlementSerialNumber, basis, dateSystem);
|
|
26416
26677
|
DSC = E - days;
|
|
26417
26678
|
}
|
|
26418
26679
|
result += redemption / (1 + yld / frequency) ** (N + Nq + DSC / E);
|
|
@@ -26460,7 +26721,9 @@ function getDateSerialNumberByMonths(serialNumber, months, returnLastDay, dateSy
|
|
|
26460
26721
|
let date = (0, _univerjs_core.excelSerialToDate)(serialNumber, dateSystem);
|
|
26461
26722
|
date = dateAddMonths(date, months);
|
|
26462
26723
|
if (returnLastDay) {
|
|
26463
|
-
const
|
|
26724
|
+
const year = date.getUTCFullYear();
|
|
26725
|
+
const month = date.getUTCMonth();
|
|
26726
|
+
const daysInMonth = getDaysInMonth(year, month);
|
|
26464
26727
|
date.setUTCDate(daysInMonth);
|
|
26465
26728
|
}
|
|
26466
26729
|
return (0, _univerjs_core.excelDateSerial)(date, dateSystem);
|
|
@@ -26525,7 +26788,7 @@ function guessIsNaNorInfinity(guess, iterF) {
|
|
|
26525
26788
|
low = xBegin + step * (xBegin - xEnd);
|
|
26526
26789
|
high = xEnd + step * (xEnd - xBegin);
|
|
26527
26790
|
} else return ErrorValueObject.create("#NUM!");
|
|
26528
|
-
if (i ===
|
|
26791
|
+
if (i === 59) return ErrorValueObject.create("#NUM!");
|
|
26529
26792
|
}
|
|
26530
26793
|
xBegin = xBegin;
|
|
26531
26794
|
xEnd = xEnd;
|
|
@@ -26617,7 +26880,10 @@ var Accrint = class extends BaseFunction {
|
|
|
26617
26880
|
const couppcd = calculateCouppcd(settlementSerialNumber, firstInterestSerialNumber, frequencyValue, this.getDateSystem());
|
|
26618
26881
|
const numMonths = 12 / frequencyValue;
|
|
26619
26882
|
const firstInterestDate = (0, _univerjs_core.excelSerialToDate)(firstInterestSerialNumber, this.getDateSystem());
|
|
26620
|
-
const
|
|
26883
|
+
const firstInterestDateYear = firstInterestDate.getUTCFullYear();
|
|
26884
|
+
const firstInterestDateMonth = firstInterestDate.getUTCMonth();
|
|
26885
|
+
const firstInterestDateDay = firstInterestDate.getUTCDate();
|
|
26886
|
+
const lastDayOfMonthF = lastDayOfMonth(firstInterestDateYear, firstInterestDateMonth, firstInterestDateDay);
|
|
26621
26887
|
let coupDateSerialNumber = getDateSerialNumberByMonths(firstInterestSerialNumber, -numMonths, lastDayOfMonthF, this.getDateSystem());
|
|
26622
26888
|
const startsAtFirstCoupon = issueSerialNumber === 0 && issueCouppcd === 0;
|
|
26623
26889
|
if (settlementSerialNumber > firstInterestSerialNumber && calcMethodValue) {
|
|
@@ -26668,7 +26934,8 @@ var Accrintm = class extends BaseFunction {
|
|
|
26668
26934
|
_defineProperty(this, "maxParams", 5);
|
|
26669
26935
|
}
|
|
26670
26936
|
calculate(issue, settlement, rate, par, basis) {
|
|
26671
|
-
const
|
|
26937
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
26938
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(issue, settlement, rate, par, _basis);
|
|
26672
26939
|
if (isError) return errorObject;
|
|
26673
26940
|
const [issueObject, settlementObject, rateObject, parObject, basisObject] = variants;
|
|
26674
26941
|
const issueSerialNumber = getDateSerialNumberByObject(issueObject, this.getDateSystem());
|
|
@@ -26696,7 +26963,8 @@ var Amorlinc = class extends BaseFunction {
|
|
|
26696
26963
|
_defineProperty(this, "maxParams", 7);
|
|
26697
26964
|
}
|
|
26698
26965
|
calculate(cost, datePurchased, firstPeriod, salvage, period, rate, basis) {
|
|
26699
|
-
const
|
|
26966
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
26967
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(cost, datePurchased, firstPeriod, salvage, period, rate, _basis);
|
|
26700
26968
|
if (isError) return errorObject;
|
|
26701
26969
|
const [costObject, datePurchasedObject, firstPeriodObject, salvageObject, periodObject, rateObject, basisObject] = variants;
|
|
26702
26970
|
const datePurchasedSerialNumber = getDateSerialNumberByObject(datePurchasedObject, this.getDateSystem());
|
|
@@ -26743,7 +27011,8 @@ var Coupdaybs = class extends BaseFunction {
|
|
|
26743
27011
|
_defineProperty(this, "maxParams", 4);
|
|
26744
27012
|
}
|
|
26745
27013
|
calculate(settlement, maturity, frequency, basis) {
|
|
26746
|
-
const
|
|
27014
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
27015
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, _basis);
|
|
26747
27016
|
if (isError) return errorObject;
|
|
26748
27017
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26749
27018
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject, this.getDateSystem());
|
|
@@ -26773,7 +27042,8 @@ var Coupdays = class extends BaseFunction {
|
|
|
26773
27042
|
_defineProperty(this, "maxParams", 4);
|
|
26774
27043
|
}
|
|
26775
27044
|
calculate(settlement, maturity, frequency, basis) {
|
|
26776
|
-
const
|
|
27045
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
27046
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, _basis);
|
|
26777
27047
|
if (isError) return errorObject;
|
|
26778
27048
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26779
27049
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject, this.getDateSystem());
|
|
@@ -26802,7 +27072,8 @@ var Coupdaysnc = class extends BaseFunction {
|
|
|
26802
27072
|
_defineProperty(this, "maxParams", 4);
|
|
26803
27073
|
}
|
|
26804
27074
|
calculate(settlement, maturity, frequency, basis) {
|
|
26805
|
-
const
|
|
27075
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
27076
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, _basis);
|
|
26806
27077
|
if (isError) return errorObject;
|
|
26807
27078
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26808
27079
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject, this.getDateSystem());
|
|
@@ -26817,7 +27088,8 @@ var Coupdaysnc = class extends BaseFunction {
|
|
|
26817
27088
|
2,
|
|
26818
27089
|
4
|
|
26819
27090
|
].includes(frequencyValue) || basisValue < 0 || basisValue > 4 || Math.floor(settlementSerialNumber) >= Math.floor(maturitySerialNumber)) return ErrorValueObject.create("#NUM!");
|
|
26820
|
-
const
|
|
27091
|
+
const coupDateSerialNumber = calculateCoupncd(settlementSerialNumber, maturitySerialNumber, frequencyValue, this.getDateSystem());
|
|
27092
|
+
const { days } = getTwoDateDaysByBasis(settlementSerialNumber, coupDateSerialNumber, basisValue, this.getDateSystem());
|
|
26821
27093
|
return NumberValueObject.create(days);
|
|
26822
27094
|
}
|
|
26823
27095
|
};
|
|
@@ -26831,7 +27103,8 @@ var Coupncd = class extends BaseFunction {
|
|
|
26831
27103
|
_defineProperty(this, "maxParams", 4);
|
|
26832
27104
|
}
|
|
26833
27105
|
calculate(settlement, maturity, frequency, basis) {
|
|
26834
|
-
const
|
|
27106
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
27107
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, _basis);
|
|
26835
27108
|
if (isError) return errorObject;
|
|
26836
27109
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26837
27110
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject, this.getDateSystem());
|
|
@@ -26860,7 +27133,8 @@ var Coupnum = class extends BaseFunction {
|
|
|
26860
27133
|
_defineProperty(this, "maxParams", 4);
|
|
26861
27134
|
}
|
|
26862
27135
|
calculate(settlement, maturity, frequency, basis) {
|
|
26863
|
-
const
|
|
27136
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
27137
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, _basis);
|
|
26864
27138
|
if (isError) return errorObject;
|
|
26865
27139
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26866
27140
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject, this.getDateSystem());
|
|
@@ -26891,7 +27165,8 @@ var Couppcd = class extends BaseFunction {
|
|
|
26891
27165
|
_defineProperty(this, "maxParams", 4);
|
|
26892
27166
|
}
|
|
26893
27167
|
calculate(settlement, maturity, frequency, basis) {
|
|
26894
|
-
const
|
|
27168
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
27169
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, _basis);
|
|
26895
27170
|
if (isError) return errorObject;
|
|
26896
27171
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26897
27172
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject, this.getDateSystem());
|
|
@@ -27015,7 +27290,11 @@ var Db = class extends BaseFunction {
|
|
|
27015
27290
|
const periodArray = expandArrayValueObject(maxRowLength, maxColumnLength, period, ErrorValueObject.create("#N/A"));
|
|
27016
27291
|
const monthArray = expandArrayValueObject(maxRowLength, maxColumnLength, _month, ErrorValueObject.create("#N/A"));
|
|
27017
27292
|
const resultArray = costArray.map((costObject, rowIndex, columnIndex) => {
|
|
27018
|
-
const
|
|
27293
|
+
const salvageObject = salvageArray.get(rowIndex, columnIndex);
|
|
27294
|
+
const lifeObject = lifeArray.get(rowIndex, columnIndex);
|
|
27295
|
+
const periodObject = periodArray.get(rowIndex, columnIndex);
|
|
27296
|
+
const monthObject = monthArray.get(rowIndex, columnIndex);
|
|
27297
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(costObject, salvageObject, lifeObject, periodObject, monthObject);
|
|
27019
27298
|
if (isError) return errorObject;
|
|
27020
27299
|
const [_costObject, _salvageObject, _lifeObject, _periodObject, _monthObject] = variants;
|
|
27021
27300
|
const costValue = +_costObject.getValue();
|
|
@@ -27071,7 +27350,11 @@ var Ddb = class extends BaseFunction {
|
|
|
27071
27350
|
const periodArray = expandArrayValueObject(maxRowLength, maxColumnLength, period, ErrorValueObject.create("#N/A"));
|
|
27072
27351
|
const factorArray = expandArrayValueObject(maxRowLength, maxColumnLength, _factor, ErrorValueObject.create("#N/A"));
|
|
27073
27352
|
const resultArray = costArray.map((costObject, rowIndex, columnIndex) => {
|
|
27074
|
-
const
|
|
27353
|
+
const salvageObject = salvageArray.get(rowIndex, columnIndex);
|
|
27354
|
+
const lifeObject = lifeArray.get(rowIndex, columnIndex);
|
|
27355
|
+
const periodObject = periodArray.get(rowIndex, columnIndex);
|
|
27356
|
+
const factorObject = factorArray.get(rowIndex, columnIndex);
|
|
27357
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(costObject, salvageObject, lifeObject, periodObject, factorObject);
|
|
27075
27358
|
if (isError) return errorObject;
|
|
27076
27359
|
const [_costObject, _salvageObject, _lifeObject, _periodObject, _factorObject] = variants;
|
|
27077
27360
|
const costValue = +_costObject.getValue();
|
|
@@ -27099,7 +27382,8 @@ var Disc = class extends BaseFunction {
|
|
|
27099
27382
|
_defineProperty(this, "maxParams", 5);
|
|
27100
27383
|
}
|
|
27101
27384
|
calculate(settlement, maturity, pr, redemption, basis) {
|
|
27102
|
-
const
|
|
27385
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
27386
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, pr, redemption, _basis);
|
|
27103
27387
|
if (isError) return errorObject;
|
|
27104
27388
|
const [settlementObject, maturityObject, prObject, redemptionObject, basisObject] = variants;
|
|
27105
27389
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject, this.getDateSystem());
|
|
@@ -27243,10 +27527,19 @@ var Fv = class extends BaseFunction {
|
|
|
27243
27527
|
const pvArray = expandArrayValueObject(maxRowLength, maxColumnLength, _pv, ErrorValueObject.create("#N/A"));
|
|
27244
27528
|
const typeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _type, ErrorValueObject.create("#N/A"));
|
|
27245
27529
|
const resultArray = rateArray.map((rateObject, rowIndex, columnIndex) => {
|
|
27246
|
-
const
|
|
27530
|
+
const nperObject = nperArray.get(rowIndex, columnIndex);
|
|
27531
|
+
const pmtObject = pmtArray.get(rowIndex, columnIndex);
|
|
27532
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
27533
|
+
const typeObject = typeArray.get(rowIndex, columnIndex);
|
|
27534
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rateObject, nperObject, pmtObject, pvObject, typeObject);
|
|
27247
27535
|
if (isError) return errorObject;
|
|
27248
27536
|
const [_rateObject, _nperObject, _pmtObject, _pvObject, _typeObject] = variants;
|
|
27249
|
-
const
|
|
27537
|
+
const rateValue = +_rateObject.getValue();
|
|
27538
|
+
const nperValue = +_nperObject.getValue();
|
|
27539
|
+
const pmtValue = +_pmtObject.getValue();
|
|
27540
|
+
const pvValue = +_pvObject.getValue();
|
|
27541
|
+
const typeValue = +_typeObject.getValue();
|
|
27542
|
+
const result = calculateFV(rateValue, nperValue, pmtValue, pvValue, typeValue ? 1 : 0);
|
|
27250
27543
|
if (Number.isNaN(result) || !Number.isFinite(result)) return ErrorValueObject.create("#NUM!");
|
|
27251
27544
|
if (rowIndex === 0 && columnIndex === 0) return NumberValueObject.create(result, getCurrencyFormat(this.getLocale()));
|
|
27252
27545
|
else return NumberValueObject.create(result);
|
|
@@ -27299,7 +27592,8 @@ var Intrate = class extends BaseFunction {
|
|
|
27299
27592
|
_defineProperty(this, "maxParams", 5);
|
|
27300
27593
|
}
|
|
27301
27594
|
calculate(settlement, maturity, investment, redemption, basis) {
|
|
27302
|
-
const
|
|
27595
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
27596
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, investment, redemption, _basis);
|
|
27303
27597
|
if (isError) return errorObject;
|
|
27304
27598
|
const [settlementObject, maturityObject, investmentObject, redemptionObject, basisObject] = variants;
|
|
27305
27599
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject, this.getDateSystem());
|
|
@@ -27338,7 +27632,12 @@ var Ipmt = class extends BaseFunction {
|
|
|
27338
27632
|
const fvArray = expandArrayValueObject(maxRowLength, maxColumnLength, _fv, ErrorValueObject.create("#N/A"));
|
|
27339
27633
|
const typeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _type, ErrorValueObject.create("#N/A"));
|
|
27340
27634
|
const resultArray = rateArray.map((rateObject, rowIndex, columnIndex) => {
|
|
27341
|
-
const
|
|
27635
|
+
const perObject = perArray.get(rowIndex, columnIndex);
|
|
27636
|
+
const nperObject = nperArray.get(rowIndex, columnIndex);
|
|
27637
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
27638
|
+
const fvObject = fvArray.get(rowIndex, columnIndex);
|
|
27639
|
+
const typeObject = typeArray.get(rowIndex, columnIndex);
|
|
27640
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rateObject, perObject, nperObject, pvObject, fvObject, typeObject);
|
|
27342
27641
|
if (isError) return errorObject;
|
|
27343
27642
|
const [_rateObject, _perObject, _nperObject, _pvObject, _fvObject, _typeObject] = variants;
|
|
27344
27643
|
const rateValue = +_rateObject.getValue();
|
|
@@ -27441,7 +27740,10 @@ var Ispmt = class extends BaseFunction {
|
|
|
27441
27740
|
const nperArray = expandArrayValueObject(maxRowLength, maxColumnLength, nper, ErrorValueObject.create("#N/A"));
|
|
27442
27741
|
const pvArray = expandArrayValueObject(maxRowLength, maxColumnLength, pv, ErrorValueObject.create("#N/A"));
|
|
27443
27742
|
const resultArray = rateArray.map((rateObject, rowIndex, columnIndex) => {
|
|
27444
|
-
const
|
|
27743
|
+
const perObject = perArray.get(rowIndex, columnIndex);
|
|
27744
|
+
const nperObject = nperArray.get(rowIndex, columnIndex);
|
|
27745
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
27746
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rateObject, perObject, nperObject, pvObject);
|
|
27445
27747
|
if (isError) return errorObject;
|
|
27446
27748
|
const [_rateObject, _perObject, _nperObject, _pvObject] = variants;
|
|
27447
27749
|
const rateValue = +_rateObject.getValue();
|
|
@@ -27528,14 +27830,16 @@ var Mirr = class extends BaseFunction {
|
|
|
27528
27830
|
let _numberValues = [];
|
|
27529
27831
|
let _positive = false;
|
|
27530
27832
|
let _negative = false;
|
|
27531
|
-
if (!values.isError())
|
|
27532
|
-
|
|
27533
|
-
|
|
27534
|
-
|
|
27535
|
-
|
|
27536
|
-
|
|
27537
|
-
|
|
27538
|
-
|
|
27833
|
+
if (!values.isError()) {
|
|
27834
|
+
if (values.isNull()) _values = ErrorValueObject.create("#VALUE!");
|
|
27835
|
+
else if (!values.isArray()) _values = ErrorValueObject.create("#DIV/0!");
|
|
27836
|
+
else {
|
|
27837
|
+
const { numberValues, valuesHasError, errorObject, positive, negative } = this._checkValues(values);
|
|
27838
|
+
if (valuesHasError) _values = errorObject;
|
|
27839
|
+
_numberValues = numberValues;
|
|
27840
|
+
_positive = positive;
|
|
27841
|
+
_negative = negative;
|
|
27842
|
+
}
|
|
27539
27843
|
}
|
|
27540
27844
|
return {
|
|
27541
27845
|
_values,
|
|
@@ -27633,7 +27937,11 @@ var Nper = class extends BaseFunction {
|
|
|
27633
27937
|
const fvArray = expandArrayValueObject(maxRowLength, maxColumnLength, _fv, ErrorValueObject.create("#N/A"));
|
|
27634
27938
|
const typeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _type, ErrorValueObject.create("#N/A"));
|
|
27635
27939
|
const resultArray = rateArray.map((rateObject, rowIndex, columnIndex) => {
|
|
27636
|
-
const
|
|
27940
|
+
const pmtObject = pmtArray.get(rowIndex, columnIndex);
|
|
27941
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
27942
|
+
const fvObject = fvArray.get(rowIndex, columnIndex);
|
|
27943
|
+
const typeObject = typeArray.get(rowIndex, columnIndex);
|
|
27944
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rateObject, pmtObject, pvObject, fvObject, typeObject);
|
|
27637
27945
|
if (isError) return errorObject;
|
|
27638
27946
|
const [_rateObject, _pmtObject, _pvObject, _fvObject, _typeObject] = variants;
|
|
27639
27947
|
const rateValue = +_rateObject.getValue();
|
|
@@ -27678,7 +27986,8 @@ var Npv = class extends BaseFunction {
|
|
|
27678
27986
|
if (_rate.isString()) _rate = _rate.convertToNumberObjectValue();
|
|
27679
27987
|
if (_rate.isError()) return _rate;
|
|
27680
27988
|
if (isError) return errorObject;
|
|
27681
|
-
const
|
|
27989
|
+
const rateValue = +rate.getValue();
|
|
27990
|
+
const result = calculateNpv(rateValue, values);
|
|
27682
27991
|
if (Number.isNaN(result) || Math.abs(result) === Infinity) return ErrorValueObject.create("#DIV/0!");
|
|
27683
27992
|
if (rowIndex === 0 && columnIndex === 0) return NumberValueObject.create(result, getCurrencyFormat(this.getLocale()));
|
|
27684
27993
|
return NumberValueObject.create(result);
|
|
@@ -28009,7 +28318,9 @@ var Pduration = class extends BaseFunction {
|
|
|
28009
28318
|
const pvArray = expandArrayValueObject(maxRowLength, maxColumnLength, pv, ErrorValueObject.create("#N/A"));
|
|
28010
28319
|
const fvArray = expandArrayValueObject(maxRowLength, maxColumnLength, fv, ErrorValueObject.create("#N/A"));
|
|
28011
28320
|
const resultArray = rateArray.map((rateObject, rowIndex, columnIndex) => {
|
|
28012
|
-
const
|
|
28321
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
28322
|
+
const fvObject = fvArray.get(rowIndex, columnIndex);
|
|
28323
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rateObject, pvObject, fvObject);
|
|
28013
28324
|
if (isError) return errorObject;
|
|
28014
28325
|
const [_rateObject, _pvObject, _fvObject] = variants;
|
|
28015
28326
|
const rateValue = +_rateObject.getValue();
|
|
@@ -28045,7 +28356,11 @@ var Pmt = class extends BaseFunction {
|
|
|
28045
28356
|
const fvArray = expandArrayValueObject(maxRowLength, maxColumnLength, _fv, ErrorValueObject.create("#N/A"));
|
|
28046
28357
|
const typeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _type, ErrorValueObject.create("#N/A"));
|
|
28047
28358
|
const resultArray = rateArray.map((rateObject, rowIndex, columnIndex) => {
|
|
28048
|
-
const
|
|
28359
|
+
const nperObject = nperArray.get(rowIndex, columnIndex);
|
|
28360
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
28361
|
+
const fvObject = fvArray.get(rowIndex, columnIndex);
|
|
28362
|
+
const typeObject = typeArray.get(rowIndex, columnIndex);
|
|
28363
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rateObject, nperObject, pvObject, fvObject, typeObject);
|
|
28049
28364
|
if (isError) return errorObject;
|
|
28050
28365
|
const [_rateObject, _nperObject, _pvObject, _fvObject, _typeObject] = variants;
|
|
28051
28366
|
const rateValue = +_rateObject.getValue();
|
|
@@ -28085,7 +28400,12 @@ var Ppmt = class extends BaseFunction {
|
|
|
28085
28400
|
const fvArray = expandArrayValueObject(maxRowLength, maxColumnLength, _fv, ErrorValueObject.create("#N/A"));
|
|
28086
28401
|
const typeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _type, ErrorValueObject.create("#N/A"));
|
|
28087
28402
|
const resultArray = rateArray.map((rateObject, rowIndex, columnIndex) => {
|
|
28088
|
-
const
|
|
28403
|
+
const perObject = perArray.get(rowIndex, columnIndex);
|
|
28404
|
+
const nperObject = nperArray.get(rowIndex, columnIndex);
|
|
28405
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
28406
|
+
const fvObject = fvArray.get(rowIndex, columnIndex);
|
|
28407
|
+
const typeObject = typeArray.get(rowIndex, columnIndex);
|
|
28408
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rateObject, perObject, nperObject, pvObject, fvObject, typeObject);
|
|
28089
28409
|
if (isError) return errorObject;
|
|
28090
28410
|
const [_rateObject, _perObject, _nperObject, _pvObject, _fvObject, _typeObject] = variants;
|
|
28091
28411
|
const rateValue = +_rateObject.getValue();
|
|
@@ -28226,7 +28546,11 @@ var Pv = class extends BaseFunction {
|
|
|
28226
28546
|
const fvArray = expandArrayValueObject(maxRowLength, maxColumnLength, _fv, ErrorValueObject.create("#N/A"));
|
|
28227
28547
|
const typeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _type, ErrorValueObject.create("#N/A"));
|
|
28228
28548
|
const resultArray = rateArray.map((rateObject, rowIndex, columnIndex) => {
|
|
28229
|
-
const
|
|
28549
|
+
const nperObject = nperArray.get(rowIndex, columnIndex);
|
|
28550
|
+
const pmtObject = pmtArray.get(rowIndex, columnIndex);
|
|
28551
|
+
const fvObject = fvArray.get(rowIndex, columnIndex);
|
|
28552
|
+
const typeObject = typeArray.get(rowIndex, columnIndex);
|
|
28553
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rateObject, nperObject, pmtObject, fvObject, typeObject);
|
|
28230
28554
|
if (isError) return errorObject;
|
|
28231
28555
|
const [_rateObject, _nperObject, _pmtObject, _fvObject, _typeObject] = variants;
|
|
28232
28556
|
const rateValue = +_rateObject.getValue();
|
|
@@ -28266,7 +28590,12 @@ var Rate = class extends BaseFunction {
|
|
|
28266
28590
|
const typeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _type, ErrorValueObject.create("#N/A"));
|
|
28267
28591
|
const guessArray = expandArrayValueObject(maxRowLength, maxColumnLength, _guess, ErrorValueObject.create("#N/A"));
|
|
28268
28592
|
const resultArray = nperArray.map((nperObject, rowIndex, columnIndex) => {
|
|
28269
|
-
const
|
|
28593
|
+
const pmtObject = pmtArray.get(rowIndex, columnIndex);
|
|
28594
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
28595
|
+
const fvObject = fvArray.get(rowIndex, columnIndex);
|
|
28596
|
+
const typeObject = typeArray.get(rowIndex, columnIndex);
|
|
28597
|
+
const guessObject = guessArray.get(rowIndex, columnIndex);
|
|
28598
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(nperObject, pmtObject, pvObject, fvObject, typeObject, guessObject);
|
|
28270
28599
|
if (isError) return errorObject;
|
|
28271
28600
|
const [_nperObject, _pmtObject, _pvObject, _fvObject, _typeObject, _guessObject] = variants;
|
|
28272
28601
|
const nperValue = +_nperObject.getValue();
|
|
@@ -28377,7 +28706,9 @@ var Rri = class extends BaseFunction {
|
|
|
28377
28706
|
const pvArray = expandArrayValueObject(maxRowLength, maxColumnLength, pv, ErrorValueObject.create("#N/A"));
|
|
28378
28707
|
const fvArray = expandArrayValueObject(maxRowLength, maxColumnLength, fv, ErrorValueObject.create("#N/A"));
|
|
28379
28708
|
const resultArray = nperArray.map((nperObject, rowIndex, columnIndex) => {
|
|
28380
|
-
const
|
|
28709
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
28710
|
+
const fvObject = fvArray.get(rowIndex, columnIndex);
|
|
28711
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(nperObject, pvObject, fvObject);
|
|
28381
28712
|
if (isError) return errorObject;
|
|
28382
28713
|
const [_nperObject, _pvObject, _fvObject] = variants;
|
|
28383
28714
|
const nperValue = +_nperObject.getValue();
|
|
@@ -28488,7 +28819,8 @@ var Tbilleq = class extends BaseFunction {
|
|
|
28488
28819
|
const DSM = Math.floor(maturitySerialNumber) - Math.floor(settlementSerialNumber);
|
|
28489
28820
|
const date = (0, _univerjs_core.excelSerialToDate)(settlementSerialNumber, this.getDateSystem());
|
|
28490
28821
|
const isSerialZero = settlementSerialNumber === 0;
|
|
28491
|
-
const
|
|
28822
|
+
const year = this.getDateSystem() === _univerjs_core.DateSystem.Date1900 && isSerialZero ? 1900 : date.getUTCFullYear();
|
|
28823
|
+
const yearDays = getDaysInYear(year);
|
|
28492
28824
|
if (DSM > yearDays) return ErrorValueObject.create("#NUM!");
|
|
28493
28825
|
let result = 365 * discountValue / (360 - discountValue * DSM);
|
|
28494
28826
|
if (DSM > 182) {
|
|
@@ -28524,7 +28856,8 @@ var Tbillprice = class extends BaseFunction {
|
|
|
28524
28856
|
if (discountValue <= 0 || settlementSerialNumber >= maturitySerialNumber) return ErrorValueObject.create("#NUM!");
|
|
28525
28857
|
const DSM = Math.floor(maturitySerialNumber) - Math.floor(settlementSerialNumber);
|
|
28526
28858
|
const date = (0, _univerjs_core.excelSerialToDate)(settlementSerialNumber, this.getDateSystem());
|
|
28527
|
-
|
|
28859
|
+
const year = this.getDateSystem() === _univerjs_core.DateSystem.Date1900 && settlementSerialNumber === 0 ? 1900 : date.getUTCFullYear();
|
|
28860
|
+
if (DSM > getDaysInYear(year)) return ErrorValueObject.create("#NUM!");
|
|
28528
28861
|
const result = 100 * (1 - discountValue * DSM / 360);
|
|
28529
28862
|
if (result < 0) return ErrorValueObject.create("#NUM!");
|
|
28530
28863
|
return NumberValueObject.create(result, getCurrencyFormat(this.getLocale()));
|
|
@@ -28552,7 +28885,8 @@ var Tbillyield = class extends BaseFunction {
|
|
|
28552
28885
|
if (prValue <= 0 || settlementSerialNumber >= maturitySerialNumber) return ErrorValueObject.create("#NUM!");
|
|
28553
28886
|
const DSM = Math.floor(maturitySerialNumber) - Math.floor(settlementSerialNumber);
|
|
28554
28887
|
const date = (0, _univerjs_core.excelSerialToDate)(settlementSerialNumber, this.getDateSystem());
|
|
28555
|
-
|
|
28888
|
+
const year = this.getDateSystem() === _univerjs_core.DateSystem.Date1900 && settlementSerialNumber === 0 ? 1900 : date.getUTCFullYear();
|
|
28889
|
+
if (DSM > getDaysInYear(year)) return ErrorValueObject.create("#NUM!");
|
|
28556
28890
|
const result = (100 - prValue) / prValue * 360 / DSM;
|
|
28557
28891
|
return NumberValueObject.create(result);
|
|
28558
28892
|
}
|
|
@@ -28585,7 +28919,13 @@ var Vdb = class extends BaseFunction {
|
|
|
28585
28919
|
}
|
|
28586
28920
|
_getResultArray(costArray, salvageArray, lifeArray, startPeriodArray, endPeriodArray, factorArray, noSwitchArray, maxRowLength, maxColumnLength) {
|
|
28587
28921
|
const resultArray = costArray.map((costObject, rowIndex, columnIndex) => {
|
|
28588
|
-
const
|
|
28922
|
+
const salvageObject = salvageArray.get(rowIndex, columnIndex);
|
|
28923
|
+
const lifeObject = lifeArray.get(rowIndex, columnIndex);
|
|
28924
|
+
const startPeriodObject = startPeriodArray.get(rowIndex, columnIndex);
|
|
28925
|
+
const endPeriodObject = endPeriodArray.get(rowIndex, columnIndex);
|
|
28926
|
+
const factorObject = factorArray.get(rowIndex, columnIndex);
|
|
28927
|
+
const noSwitchObject = noSwitchArray.get(rowIndex, columnIndex);
|
|
28928
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(costObject, salvageObject, lifeObject, startPeriodObject, endPeriodObject, factorObject, noSwitchObject);
|
|
28589
28929
|
if (isError) return errorObject;
|
|
28590
28930
|
const [_costObject, _salvageObject, _lifeObject, _startPeriodObject, _endPeriodObject, _factorObject, _noSwitchObject] = variants;
|
|
28591
28931
|
const costValue = +_costObject.getValue();
|
|
@@ -29220,12 +29560,16 @@ var Cell = class extends BaseFunction {
|
|
|
29220
29560
|
return this._handleSingleObject(_infoType, reference);
|
|
29221
29561
|
}
|
|
29222
29562
|
_handleSingleObject(infoType, reference, infoTypeIsArray = false) {
|
|
29563
|
+
var _referenceObject$getC;
|
|
29223
29564
|
let _reference = reference;
|
|
29224
29565
|
if (_reference.isError()) return _reference;
|
|
29225
29566
|
if (!_reference.isReferenceObject()) return ErrorValueObject.create("#N/A");
|
|
29226
29567
|
const { columnData, defaultColumnWidth } = _reference.getCurrentActiveSheetData();
|
|
29227
29568
|
const forcedSheetName = _reference.getForcedSheetName();
|
|
29228
|
-
|
|
29569
|
+
const referenceObject = _reference;
|
|
29570
|
+
const cellData = referenceObject.getCellData(referenceObject.getRangePosition().startRow, referenceObject.getRangePosition().startColumn);
|
|
29571
|
+
const numberFormat = (_referenceObject$getC = referenceObject.getCurrentStylesData()) === null || _referenceObject$getC === void 0 || (_referenceObject$getC = _referenceObject$getC.getStyleByCell(cellData)) === null || _referenceObject$getC === void 0 || (_referenceObject$getC = _referenceObject$getC.n) === null || _referenceObject$getC === void 0 ? void 0 : _referenceObject$getC.pattern;
|
|
29572
|
+
_reference = referenceObject.toArrayValueObject();
|
|
29229
29573
|
const _currentRow = _reference.getCurrentRow();
|
|
29230
29574
|
const _currentColumn = _reference.getCurrentColumn();
|
|
29231
29575
|
_reference = _reference.getFirstCell();
|
|
@@ -29237,7 +29581,7 @@ var Cell = class extends BaseFunction {
|
|
|
29237
29581
|
case "color": return NumberValueObject.create(0);
|
|
29238
29582
|
case "contents": return _reference;
|
|
29239
29583
|
case "filename": return ErrorValueObject.create("#VALUE!");
|
|
29240
|
-
case "format": return StringValueObject.create(
|
|
29584
|
+
case "format": return StringValueObject.create(getCellFormatCode(numberFormat));
|
|
29241
29585
|
case "parentheses": return NumberValueObject.create(0);
|
|
29242
29586
|
case "prefix": return StringValueObject.create("");
|
|
29243
29587
|
case "protect": return NumberValueObject.create(1);
|
|
@@ -29260,6 +29604,24 @@ var Cell = class extends BaseFunction {
|
|
|
29260
29604
|
return ArrayValueObject.createByArray(resultArray);
|
|
29261
29605
|
}
|
|
29262
29606
|
};
|
|
29607
|
+
function getCellFormatCode(pattern) {
|
|
29608
|
+
if (!pattern || /^general$/iu.test(pattern.trim())) return "G";
|
|
29609
|
+
const normalized = pattern.split(";")[0].replace(/"[^"]*"/gu, "").replace(/\\./gu, "").replace(/_.|\*./gu, "").toLocaleLowerCase();
|
|
29610
|
+
const hasDate = /[yd]/u.test(normalized);
|
|
29611
|
+
const hasTime = /h|s/u.test(normalized);
|
|
29612
|
+
if (hasDate) return "D4";
|
|
29613
|
+
if (hasTime) return /s/u.test(normalized) ? "D8" : "D9";
|
|
29614
|
+
if (/%/u.test(normalized)) return `P${decimalPlaces(normalized)}`;
|
|
29615
|
+
if (/[eE][+-]?0+/u.test(normalized)) return `S${decimalPlaces(normalized)}`;
|
|
29616
|
+
if (/[$£¥€]/u.test(normalized)) return `C${decimalPlaces(normalized)}`;
|
|
29617
|
+
if (/,/u.test(normalized)) return `,${decimalPlaces(normalized)}`;
|
|
29618
|
+
if (/[0#?]/u.test(normalized)) return `F${decimalPlaces(normalized)}`;
|
|
29619
|
+
return "G";
|
|
29620
|
+
}
|
|
29621
|
+
function decimalPlaces(pattern) {
|
|
29622
|
+
var _pattern$match;
|
|
29623
|
+
return ((_pattern$match = pattern.match(/\.([0#?]+)/u)) === null || _pattern$match === void 0 || (_pattern$match = _pattern$match[1]) === null || _pattern$match === void 0 ? void 0 : _pattern$match.length) ?? 0;
|
|
29624
|
+
}
|
|
29263
29625
|
|
|
29264
29626
|
//#endregion
|
|
29265
29627
|
//#region src/functions/information/error-type/index.ts
|
|
@@ -29301,7 +29663,9 @@ var Isbetween = class extends BaseFunction {
|
|
|
29301
29663
|
_defineProperty(this, "maxParams", 5);
|
|
29302
29664
|
}
|
|
29303
29665
|
calculate(valueToCompare, lowerValue, upperValue, lowerValueIsInclusive, upperValueIsInclusive) {
|
|
29304
|
-
const
|
|
29666
|
+
const _lowerValueIsInclusive = lowerValueIsInclusive ?? BooleanValueObject.create(true);
|
|
29667
|
+
const _upperValueIsInclusive = upperValueIsInclusive ?? BooleanValueObject.create(true);
|
|
29668
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArray(valueToCompare, lowerValue, upperValue, _lowerValueIsInclusive, _upperValueIsInclusive);
|
|
29305
29669
|
if (isError) return errorObject;
|
|
29306
29670
|
const [valueToCompareObject, lowerValueObject, upperValueObject, lowerValueIsInclusiveObject, upperValueIsInclusiveObject] = variants;
|
|
29307
29671
|
if (lowerValueIsInclusiveObject.isString() || upperValueIsInclusiveObject.isString()) return ErrorValueObject.create("#VALUE!");
|
|
@@ -30511,13 +30875,15 @@ var Map$1 = class extends BaseFunction {
|
|
|
30511
30875
|
_variant_reference = variant;
|
|
30512
30876
|
variant = variant.toArrayValueObject();
|
|
30513
30877
|
}
|
|
30514
|
-
if (!variant.isArray())
|
|
30515
|
-
|
|
30516
|
-
|
|
30517
|
-
|
|
30518
|
-
|
|
30519
|
-
|
|
30520
|
-
|
|
30878
|
+
if (!variant.isArray()) {
|
|
30879
|
+
if (r === 0 && c === 0) {
|
|
30880
|
+
lambdaVariant.push(_variant_reference || variant);
|
|
30881
|
+
continue;
|
|
30882
|
+
} else {
|
|
30883
|
+
row.push(ErrorValueObject.create("#N/A"));
|
|
30884
|
+
isRowPushed = true;
|
|
30885
|
+
break;
|
|
30886
|
+
}
|
|
30521
30887
|
}
|
|
30522
30888
|
let valueObject = variant.get(r, c);
|
|
30523
30889
|
if (!valueObject) {
|
|
@@ -31023,7 +31389,8 @@ var Address = class extends BaseFunction {
|
|
|
31023
31389
|
if (Number.isNaN(row) || Number.isNaN(column) || Number.isNaN(absNumberValue) || absNumberValue < 1 || absNumberValue > 4) return ErrorValueObject.create("#VALUE!");
|
|
31024
31390
|
const absType = transformAbsoluteRefType(absNumberValue);
|
|
31025
31391
|
const a1Value = this.getZeroOrOneByOneDefault(a1);
|
|
31026
|
-
const
|
|
31392
|
+
const sheetTextValue = `${sheetText.getValue()}`;
|
|
31393
|
+
const sheetName = addQuotesBothSides(sheetTextValue);
|
|
31027
31394
|
const range = {
|
|
31028
31395
|
startRow: row,
|
|
31029
31396
|
startColumn: column,
|
|
@@ -31150,8 +31517,10 @@ var Choosecols = class extends BaseFunction {
|
|
|
31150
31517
|
const variantValue = Math.trunc(+variantObject.getValue());
|
|
31151
31518
|
if (variantValue === 0 || Math.abs(variantValue) > arrayColumnCount) return ErrorValueObject.create("#VALUE!");
|
|
31152
31519
|
let searchColArray = array;
|
|
31153
|
-
if (arrayColumnCount > 1)
|
|
31154
|
-
|
|
31520
|
+
if (arrayColumnCount > 1) {
|
|
31521
|
+
if (variantValue < 0) searchColArray = array.slice(void 0, [variantValue + arrayColumnCount, variantValue + 1 + arrayColumnCount]);
|
|
31522
|
+
else searchColArray = array.slice(void 0, [variantValue - 1, variantValue]);
|
|
31523
|
+
}
|
|
31155
31524
|
for (let r = 0; r < arrayRowCount; r++) {
|
|
31156
31525
|
if (!result[r]) result[r] = [];
|
|
31157
31526
|
if (array.isArray()) result[r].push(searchColArray.get(r, 0));
|
|
@@ -31195,8 +31564,10 @@ var Chooserows = class extends BaseFunction {
|
|
|
31195
31564
|
const variantValue = Math.trunc(+variantObject.getValue());
|
|
31196
31565
|
if (variantValue === 0 || Math.abs(variantValue) > arrayRowCount) return ErrorValueObject.create("#VALUE!");
|
|
31197
31566
|
let searchRowArray = array;
|
|
31198
|
-
if (arrayRowCount > 1)
|
|
31199
|
-
|
|
31567
|
+
if (arrayRowCount > 1) {
|
|
31568
|
+
if (variantValue < 0) searchRowArray = array.slice([variantValue + arrayRowCount, variantValue + 1 + arrayRowCount]);
|
|
31569
|
+
else searchRowArray = array.slice([variantValue - 1, variantValue]);
|
|
31570
|
+
}
|
|
31200
31571
|
if (array.isArray()) result.push(searchRowArray.getArrayValue()[0]);
|
|
31201
31572
|
else result.push([array]);
|
|
31202
31573
|
}
|
|
@@ -31558,19 +31929,24 @@ var Hlookup = class extends BaseFunction {
|
|
|
31558
31929
|
if (lookupValue.isError()) return lookupValue;
|
|
31559
31930
|
if (tableArray.isError()) return ErrorValueObject.create("#REF!");
|
|
31560
31931
|
if (!tableArray.isArray()) return ErrorValueObject.create("#N/A");
|
|
31561
|
-
if (rowIndexNum.isError()) return
|
|
31932
|
+
if (rowIndexNum.isError()) return rowIndexNum;
|
|
31562
31933
|
if (rangeLookup === null || rangeLookup === void 0 ? void 0 : rangeLookup.isError()) return ErrorValueObject.create("#N/A");
|
|
31563
31934
|
const rangeLookupValue = this.getZeroOrOneByOneDefault(rangeLookup);
|
|
31564
31935
|
if (rangeLookupValue == null) return ErrorValueObject.create("#VALUE!");
|
|
31565
31936
|
const rowIndexNumValue = this.getIndexNumValue(rowIndexNum);
|
|
31566
|
-
if (rowIndexNumValue instanceof ErrorValueObject) return
|
|
31937
|
+
if (rowIndexNumValue instanceof ErrorValueObject) return ErrorValueObject.create("#VALUE!");
|
|
31938
|
+
const rowIndex = Math.floor(rowIndexNumValue);
|
|
31567
31939
|
const searchArray = tableArray.slice([0, 1]);
|
|
31568
|
-
const resultArray = tableArray.slice([
|
|
31569
|
-
if (searchArray == null
|
|
31570
|
-
if (lookupValue.isArray()) return lookupValue.map((value) => this._handleSingleObject(value, searchArray, resultArray, rangeLookupValue));
|
|
31571
|
-
return this._handleSingleObject(lookupValue, searchArray, resultArray, rangeLookupValue);
|
|
31940
|
+
const resultArray = tableArray.slice([rowIndex - 1, rowIndex]);
|
|
31941
|
+
if (searchArray == null) return ErrorValueObject.create("#REF!");
|
|
31942
|
+
if (lookupValue.isArray()) return lookupValue.map((value) => this._handleSingleObject(value, searchArray, resultArray, rangeLookupValue, rowIndex));
|
|
31943
|
+
return this._handleSingleObject(lookupValue, searchArray, resultArray, rangeLookupValue, rowIndex);
|
|
31572
31944
|
}
|
|
31573
|
-
_handleSingleObject(value, searchArray, resultArray, rangeLookupValue) {
|
|
31945
|
+
_handleSingleObject(value, searchArray, resultArray, rangeLookupValue, rowIndex) {
|
|
31946
|
+
if (resultArray == null || rowIndex < 1) {
|
|
31947
|
+
const match = this._handleSingleObject(value, searchArray, searchArray, rangeLookupValue, 1);
|
|
31948
|
+
return match.isError() ? match : ErrorValueObject.create(rowIndex < 1 ? "#VALUE!" : "#REF!");
|
|
31949
|
+
}
|
|
31574
31950
|
if (rangeLookupValue === 0) return this._blankResultAsZero(this.equalSearch(value, searchArray, resultArray));
|
|
31575
31951
|
return this.binarySearch(value, searchArray, resultArray);
|
|
31576
31952
|
}
|
|
@@ -31792,6 +32168,7 @@ var Index = class extends BaseFunction {
|
|
|
31792
32168
|
if (rowNumValue > referenceRowColumnCount.rowCount || columnNumValue > referenceRowColumnCount.columnCount) return ErrorValueObject.create("#REF!");
|
|
31793
32169
|
let _reference = reference;
|
|
31794
32170
|
if (areaNumValue > 1) _reference = reference.getCubeValues()[areaNumValue - 1];
|
|
32171
|
+
if (!columnNum && rowNumValue > 0 && referenceRowColumnCount.rowCount > 1 && referenceRowColumnCount.columnCount > 1 && _reference.isReferenceObject()) return ErrorValueObject.create("#REF!");
|
|
31795
32172
|
if (_reference.isReferenceObject()) return this._calculateReferenceObject(_reference, rowNumValue, columnNumValue);
|
|
31796
32173
|
return this._calculateArrayObject(_reference, rowNumValue, columnNumValue);
|
|
31797
32174
|
}
|
|
@@ -32960,13 +33337,15 @@ var Vlookup = class extends BaseFunction {
|
|
|
32960
33337
|
}
|
|
32961
33338
|
_handleTableArray(lookupValue, tableArray, colIndexNum, rangeLookupValue) {
|
|
32962
33339
|
let colIndexNumValue = this.getIndexNumValue(colIndexNum);
|
|
32963
|
-
if (colIndexNumValue instanceof ErrorValueObject) return
|
|
33340
|
+
if (colIndexNumValue instanceof ErrorValueObject) return ErrorValueObject.create("#VALUE!");
|
|
32964
33341
|
colIndexNumValue = Math.floor(colIndexNumValue);
|
|
32965
|
-
if (colIndexNumValue < 1) return ErrorValueObject.create("#VALUE!");
|
|
32966
33342
|
const searchArray = tableArray.slice(void 0, [0, 1]);
|
|
32967
33343
|
if (searchArray == null) return ErrorValueObject.create("#VALUE!");
|
|
32968
33344
|
const resultArray = tableArray.slice(void 0, [colIndexNumValue - 1, colIndexNumValue]);
|
|
32969
|
-
if (resultArray == null
|
|
33345
|
+
if (resultArray == null || colIndexNumValue < 1) {
|
|
33346
|
+
const match = this._handleSingleObject(lookupValue, searchArray, searchArray, rangeLookupValue);
|
|
33347
|
+
return match.isError() ? match : ErrorValueObject.create(colIndexNumValue < 1 ? "#VALUE!" : "#REF!");
|
|
33348
|
+
}
|
|
32970
33349
|
return this._handleSingleObject(lookupValue, searchArray, resultArray, rangeLookupValue);
|
|
32971
33350
|
}
|
|
32972
33351
|
_handleSingleObject(value, searchArray, resultArray, rangeLookupValue) {
|
|
@@ -34289,7 +34668,8 @@ var Fact = class extends BaseFunction {
|
|
|
34289
34668
|
let _number = number;
|
|
34290
34669
|
if (_number.isString()) _number = _number.convertToNumberObjectValue();
|
|
34291
34670
|
if (_number.isError()) return _number;
|
|
34292
|
-
const
|
|
34671
|
+
const numberValue = Math.floor(+_number.getValue());
|
|
34672
|
+
const result = calculateFactorial(numberValue);
|
|
34293
34673
|
if (Number.isNaN(result) || !Number.isFinite(result)) return ErrorValueObject.create("#NUM!");
|
|
34294
34674
|
return NumberValueObject.create(result);
|
|
34295
34675
|
}
|
|
@@ -34317,7 +34697,8 @@ var Factdouble = class extends BaseFunction {
|
|
|
34317
34697
|
let _number = number;
|
|
34318
34698
|
if (_number.isString()) _number = _number.convertToNumberObjectValue();
|
|
34319
34699
|
if (_number.isError()) return _number;
|
|
34320
|
-
const
|
|
34700
|
+
const numberValue = Math.floor(+_number.getValue());
|
|
34701
|
+
const result = calculateFactorial(numberValue, 2);
|
|
34321
34702
|
if (Number.isNaN(result) || !Number.isFinite(result)) return ErrorValueObject.create("#NUM!");
|
|
34322
34703
|
return NumberValueObject.create(result);
|
|
34323
34704
|
}
|
|
@@ -35373,13 +35754,12 @@ var Roundbank = class extends BaseFunction {
|
|
|
35373
35754
|
_roundBank(number, numDigits) {
|
|
35374
35755
|
if (numDigits > 16) return number;
|
|
35375
35756
|
if (numDigits < -16) return 0;
|
|
35376
|
-
const EPSILON = 1e-8;
|
|
35377
35757
|
const multiplier = 10 ** numDigits;
|
|
35378
35758
|
const adjustedNum = +(number * multiplier).toFixed(8);
|
|
35379
35759
|
const integerPart = Math.floor(adjustedNum);
|
|
35380
35760
|
const decimalPart = adjustedNum - integerPart;
|
|
35381
35761
|
let result = Math.round(adjustedNum);
|
|
35382
|
-
if (decimalPart > .
|
|
35762
|
+
if (decimalPart > .49999999 && decimalPart < .50000001) result = integerPart % 2 === 0 ? integerPart : integerPart + 1;
|
|
35383
35763
|
return numDigits ? result / multiplier : result;
|
|
35384
35764
|
}
|
|
35385
35765
|
};
|
|
@@ -35859,6 +36239,8 @@ var Sumif = class extends BaseFunction {
|
|
|
35859
36239
|
_defineProperty(this, "needsReferenceObject", true);
|
|
35860
36240
|
}
|
|
35861
36241
|
calculate(range, criteria, sumRange) {
|
|
36242
|
+
if (range.isError()) return range;
|
|
36243
|
+
if (sumRange === null || sumRange === void 0 ? void 0 : sumRange.isError()) return sumRange;
|
|
35862
36244
|
if (!range.isReferenceObject() || sumRange && !sumRange.isReferenceObject()) return ErrorValueObject.create("#VALUE!");
|
|
35863
36245
|
let _criteria = criteria;
|
|
35864
36246
|
if (criteria.isReferenceObject()) _criteria = criteria.toArrayValueObject();
|
|
@@ -35963,7 +36345,7 @@ var Sumproduct = class extends BaseFunction {
|
|
|
35963
36345
|
const arr = v;
|
|
35964
36346
|
const variantRowCount = arr.getRowCount();
|
|
35965
36347
|
const variantColumnCount = arr.getColumnCount();
|
|
35966
|
-
if (variantRowCount !== rowCount
|
|
36348
|
+
if (variantRowCount !== rowCount || variantColumnCount !== columnCount) return ErrorValueObject.create("#VALUE!");
|
|
35967
36349
|
}
|
|
35968
36350
|
}
|
|
35969
36351
|
return null;
|
|
@@ -37266,7 +37648,7 @@ var Countif = class extends BaseFunction {
|
|
|
37266
37648
|
}
|
|
37267
37649
|
}
|
|
37268
37650
|
if (_criteria.isArray()) {
|
|
37269
|
-
const resultArray = _criteria.mapValue((criteriaObject) => this._handleSingleObject(range, criteriaObject));
|
|
37651
|
+
const resultArray = _criteria.mapValue((criteriaObject) => this._handleSingleObject(range, criteria.isReferenceObject() && criteriaObject.isNull() ? NumberValueObject.create(0) : criteriaObject));
|
|
37270
37652
|
if (resultArray.getRowCount() === 1 && resultArray.getColumnCount() === 1) return resultArray.get(0, 0);
|
|
37271
37653
|
return resultArray;
|
|
37272
37654
|
}
|
|
@@ -37781,7 +38163,8 @@ var Gauss = class extends BaseFunction {
|
|
|
37781
38163
|
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(z);
|
|
37782
38164
|
if (isError) return errorObject;
|
|
37783
38165
|
const [zObject] = variants;
|
|
37784
|
-
const
|
|
38166
|
+
const zValue = +zObject.getValue();
|
|
38167
|
+
const result = normalCDF(zValue, 0, 1) - .5;
|
|
37785
38168
|
return NumberValueObject.create(result);
|
|
37786
38169
|
}
|
|
37787
38170
|
};
|
|
@@ -37892,7 +38275,8 @@ var Growth = class extends BaseFunction {
|
|
|
37892
38275
|
}
|
|
37893
38276
|
_getResultBySimpleVariables(knownYsValues, knownXsValues, newXsValues, constb) {
|
|
37894
38277
|
const knownYsValuesFlat = knownYsValues.flat();
|
|
37895
|
-
const
|
|
38278
|
+
const knownXsValuesFlat = knownXsValues.flat();
|
|
38279
|
+
const { slope, intercept } = getSlopeAndIntercept(knownXsValuesFlat, knownYsValuesFlat, constb, true);
|
|
37896
38280
|
const result = newXsValues.map((row) => {
|
|
37897
38281
|
return row.map((value) => intercept * slope ** value);
|
|
37898
38282
|
});
|
|
@@ -38114,7 +38498,8 @@ var Large = class extends BaseFunction {
|
|
|
38114
38498
|
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(k);
|
|
38115
38499
|
if (isError) return errorObject;
|
|
38116
38500
|
const [kObject] = variants;
|
|
38117
|
-
|
|
38501
|
+
const kValue = +kObject.getValue();
|
|
38502
|
+
return getLargeResult(array, kValue);
|
|
38118
38503
|
}
|
|
38119
38504
|
};
|
|
38120
38505
|
|
|
@@ -38980,7 +39365,8 @@ var PercentileExc = class extends BaseFunction {
|
|
|
38980
39365
|
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(k);
|
|
38981
39366
|
if (isError) return errorObject;
|
|
38982
39367
|
const [kObject] = variants;
|
|
38983
|
-
|
|
39368
|
+
const kValue = +kObject.getValue();
|
|
39369
|
+
return getPercentileExcResult(array, kValue);
|
|
38984
39370
|
}
|
|
38985
39371
|
};
|
|
38986
39372
|
|
|
@@ -39018,8 +39404,10 @@ var PercentrankExc = class extends BaseFunction {
|
|
|
39018
39404
|
const significanceValue = Math.floor(+significanceObject.getValue());
|
|
39019
39405
|
const n = array.length;
|
|
39020
39406
|
if (n === 0 || xValue < array[0] || xValue > array[n - 1]) return ErrorValueObject.create("#N/A");
|
|
39021
|
-
if (n === 1)
|
|
39022
|
-
|
|
39407
|
+
if (n === 1) {
|
|
39408
|
+
if (xValue === array[0]) return NumberValueObject.create(1);
|
|
39409
|
+
else return ErrorValueObject.create("#N/A");
|
|
39410
|
+
}
|
|
39023
39411
|
let result = 0;
|
|
39024
39412
|
let match = false;
|
|
39025
39413
|
let i = 0;
|
|
@@ -39110,8 +39498,10 @@ var Permutationa = class extends BaseFunction {
|
|
|
39110
39498
|
const numberValue = Math.floor(+_numberObject.getValue());
|
|
39111
39499
|
const numberChosenValue = Math.floor(+_numberChosenObject.getValue());
|
|
39112
39500
|
if (numberValue < 0 || numberValue >= 2147483647 || numberChosenValue < 0) return ErrorValueObject.create("#NUM!");
|
|
39113
|
-
if (numberValue === 0)
|
|
39114
|
-
|
|
39501
|
+
if (numberValue === 0) {
|
|
39502
|
+
if (numberChosenValue === 0) return NumberValueObject.create(1);
|
|
39503
|
+
else return NumberValueObject.create(0);
|
|
39504
|
+
}
|
|
39115
39505
|
const result = numberValue ** numberChosenValue;
|
|
39116
39506
|
if (!Number.isFinite(result)) return ErrorValueObject.create("#NUM!");
|
|
39117
39507
|
return NumberValueObject.create(result);
|
|
@@ -39265,7 +39655,8 @@ var QuartileExc = class extends BaseFunction {
|
|
|
39265
39655
|
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(quart);
|
|
39266
39656
|
if (isError) return errorObject;
|
|
39267
39657
|
const [quartObject] = variants;
|
|
39268
|
-
|
|
39658
|
+
const quartValue = Math.floor(+quartObject.getValue());
|
|
39659
|
+
return getQuartileExcResult(array, quartValue);
|
|
39269
39660
|
}
|
|
39270
39661
|
};
|
|
39271
39662
|
|
|
@@ -39633,7 +40024,8 @@ var Small = class extends BaseFunction {
|
|
|
39633
40024
|
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(k);
|
|
39634
40025
|
if (isError) return errorObject;
|
|
39635
40026
|
const [kObject] = variants;
|
|
39636
|
-
|
|
40027
|
+
const kValue = +kObject.getValue();
|
|
40028
|
+
return getSmallResult(array, kValue);
|
|
39637
40029
|
}
|
|
39638
40030
|
};
|
|
39639
40031
|
|
|
@@ -39960,7 +40352,8 @@ var Trend = class extends BaseFunction {
|
|
|
39960
40352
|
}
|
|
39961
40353
|
_getResultBySimpleVariables(knownYsValues, knownXsValues, newXsValues, constb) {
|
|
39962
40354
|
const knownYsValuesFlat = knownYsValues.flat();
|
|
39963
|
-
const
|
|
40355
|
+
const knownXsValuesFlat = knownXsValues.flat();
|
|
40356
|
+
const { slope: m, intercept: b } = getSlopeAndIntercept(knownXsValuesFlat, knownYsValuesFlat, constb, false);
|
|
39964
40357
|
if (Number.isNaN(m)) return ErrorValueObject.create("#N/A");
|
|
39965
40358
|
const result = newXsValues.map((row) => {
|
|
39966
40359
|
return row.map((value) => m * value + b);
|
|
@@ -40217,9 +40610,12 @@ var Arraytotext = class extends BaseFunction {
|
|
|
40217
40610
|
if (valueObject.isBoolean()) value = value.toLocaleUpperCase();
|
|
40218
40611
|
if (valueObject.isString() && formatValue) result += `"${value}"`;
|
|
40219
40612
|
else result += value;
|
|
40220
|
-
if (!(r === arrayRowCount - 1 && c === arrayColumnCount - 1))
|
|
40221
|
-
|
|
40222
|
-
|
|
40613
|
+
if (!(r === arrayRowCount - 1 && c === arrayColumnCount - 1)) {
|
|
40614
|
+
if (formatValue) {
|
|
40615
|
+
if (c === arrayColumnCount - 1) result += ";";
|
|
40616
|
+
else result += ",";
|
|
40617
|
+
} else result += ", ";
|
|
40618
|
+
}
|
|
40223
40619
|
}
|
|
40224
40620
|
if (formatValue) result = `{${result}}`;
|
|
40225
40621
|
if (result.length > 32767) return ErrorValueObject.create("#CALC!");
|
|
@@ -40290,9 +40686,10 @@ var Bahttext = class extends BaseFunction {
|
|
|
40290
40686
|
const integerPart = Math.abs(Number.parseInt(numberValue.toString(), 10));
|
|
40291
40687
|
const decimalPart = Number.parseFloat((Math.abs(numberValue) - integerPart).toFixed(2));
|
|
40292
40688
|
let result = "";
|
|
40293
|
-
if (integerPart === 0)
|
|
40294
|
-
|
|
40295
|
-
|
|
40689
|
+
if (integerPart === 0) {
|
|
40690
|
+
if (decimalPart !== 0) result = `${numberValue < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(decimalPart * 100)}สตางค์`;
|
|
40691
|
+
else result = "ศูนย์บาทถ้วน";
|
|
40692
|
+
} else if (decimalPart === 0) result = `${numberValue < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(integerPart)}บาทถ้วน`;
|
|
40296
40693
|
else result = `${numberValue < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(integerPart)}บาท${this._convertNumberToThaiText(decimalPart * 100)}สตางค์`;
|
|
40297
40694
|
return StringValueObject.create(result);
|
|
40298
40695
|
}
|
|
@@ -40343,9 +40740,7 @@ var Bahttext = class extends BaseFunction {
|
|
|
40343
40740
|
result += i < n ? special[5] : digitText;
|
|
40344
40741
|
break;
|
|
40345
40742
|
case 1: break;
|
|
40346
|
-
default:
|
|
40347
|
-
result += digitText;
|
|
40348
|
-
break;
|
|
40743
|
+
default: result += digitText;
|
|
40349
40744
|
}
|
|
40350
40745
|
else if (digit === 0) {
|
|
40351
40746
|
if (position === 0) result += units[position];
|
|
@@ -40648,8 +41043,10 @@ const getTextValueOfNumberFormat = (text) => {
|
|
|
40648
41043
|
let textValue = `${text.getValue()}`;
|
|
40649
41044
|
if (text.isNull()) textValue = "";
|
|
40650
41045
|
if (text.isBoolean()) textValue = textValue.toLocaleUpperCase();
|
|
40651
|
-
if (text.isNumber())
|
|
40652
|
-
|
|
41046
|
+
if (text.isNumber()) {
|
|
41047
|
+
if (text.getPattern() !== "") textValue = getFormatPreview(text.getPattern(), +text.getValue(), text.getDateSystem());
|
|
41048
|
+
else textValue = `${stripErrorMargin(+text.getValue())}`;
|
|
41049
|
+
}
|
|
40653
41050
|
return textValue;
|
|
40654
41051
|
};
|
|
40655
41052
|
|
|
@@ -40959,7 +41356,8 @@ var Lenb = class extends BaseFunction {
|
|
|
40959
41356
|
}
|
|
40960
41357
|
_handleSingleText(text) {
|
|
40961
41358
|
if (text.isError()) return text;
|
|
40962
|
-
const
|
|
41359
|
+
const textValue = getTextValueOfNumberFormat(text);
|
|
41360
|
+
const textByteLen = charLenByte(textValue);
|
|
40963
41361
|
return NumberValueObject.create(textByteLen);
|
|
40964
41362
|
}
|
|
40965
41363
|
};
|
|
@@ -42275,14 +42673,17 @@ var Text = class extends BaseFunction {
|
|
|
42275
42673
|
if (textValue.isBoolean()) return textValue;
|
|
42276
42674
|
let textValueNumber = textValue.getValue();
|
|
42277
42675
|
if (textValue.isNull()) textValueNumber = 0;
|
|
42278
|
-
if (textValue.isString())
|
|
42279
|
-
|
|
42280
|
-
|
|
42281
|
-
|
|
42676
|
+
if (textValue.isString()) {
|
|
42677
|
+
if ((0, _univerjs_core.isRealNum)(textValueNumber)) textValueNumber = Number(textValueNumber);
|
|
42678
|
+
else {
|
|
42679
|
+
const parsedValue = (0, _univerjs_core.getNumfmtParseValueFilter)(`${textValueNumber}`, { dateSystem: textValue.getDateSystem() });
|
|
42680
|
+
if (parsedValue && parsedValue.v != null && typeof parsedValue.v === "number") textValueNumber = parsedValue.v;
|
|
42681
|
+
}
|
|
42282
42682
|
}
|
|
42283
42683
|
if (formatTextValue.isNull()) formatTextValue = StringValueObject.create(" ");
|
|
42284
42684
|
const formatTextValueString = `${formatTextValue.getValue()}`;
|
|
42285
|
-
const
|
|
42685
|
+
const normalizedFormatTextValueString = normalizeExcelWeekdayFormat(formatTextValueString);
|
|
42686
|
+
const previewText = getFormatPreview(normalizedFormatTextValueString, textValueNumber, textValue.getDateSystem());
|
|
42286
42687
|
return StringValueObject.create(formatTextValueString === " " ? previewText.trimEnd() : previewText);
|
|
42287
42688
|
});
|
|
42288
42689
|
if (resultArray.getRowCount() === 1 && resultArray.getColumnCount() === 1) return resultArray.get(0, 0);
|
|
@@ -42339,8 +42740,10 @@ var Textafter = class extends BaseFunction {
|
|
|
42339
42740
|
if (_variantsNumberFloorValue instanceof ErrorValueObject) return _variantsNumberFloorValue;
|
|
42340
42741
|
const [instanceNumValue, matchModeValue, matchEndValue] = _variantsNumberFloorValue;
|
|
42341
42742
|
if (instanceNumValue === 0 || matchModeValue < 0 || matchModeValue > 1 || matchEndValue < 0 || matchEndValue > 1) return ErrorValueObject.create("#VALUE!");
|
|
42342
|
-
if (delimiterValue.includes(""))
|
|
42343
|
-
|
|
42743
|
+
if (delimiterValue.includes("")) {
|
|
42744
|
+
if (instanceNumValue > 0) return StringValueObject.create(textValue);
|
|
42745
|
+
else return StringValueObject.create("");
|
|
42746
|
+
}
|
|
42344
42747
|
if (!instanceNumIsNull && Math.abs(instanceNumValue) > textValue.length) return ErrorValueObject.create("#VALUE!");
|
|
42345
42748
|
if (delimiterValue.every((item) => item.length > textValue.length)) return ErrorValueObject.create("#N/A");
|
|
42346
42749
|
return this._getResult(textValue, delimiterValue, instanceNumValue, matchModeValue, matchEndValue, ifNotFoundObject, onlyThreeVariant);
|
|
@@ -42428,8 +42831,10 @@ var Textafter = class extends BaseFunction {
|
|
|
42428
42831
|
}
|
|
42429
42832
|
if (matchNum && matchNum < Math.abs(instanceNumValue) && onlyThreeVariant) return ErrorValueObject.create("#N/A");
|
|
42430
42833
|
if (!matchNum || matchNum < Math.abs(instanceNumValue)) {
|
|
42431
|
-
if (matchEndValue)
|
|
42432
|
-
|
|
42834
|
+
if (matchEndValue) {
|
|
42835
|
+
if (instanceNumValue > 0) return StringValueObject.create("");
|
|
42836
|
+
else return StringValueObject.create(textValue);
|
|
42837
|
+
}
|
|
42433
42838
|
return ifNotFoundObject;
|
|
42434
42839
|
}
|
|
42435
42840
|
const result = textValue.substr(resultIndex + preDelimiterLength);
|
|
@@ -42482,8 +42887,10 @@ var Textbefore = class extends BaseFunction {
|
|
|
42482
42887
|
if (_variantsNumberFloorValue instanceof ErrorValueObject) return _variantsNumberFloorValue;
|
|
42483
42888
|
const [instanceNumValue, matchModeValue, matchEndValue] = _variantsNumberFloorValue;
|
|
42484
42889
|
if (instanceNumValue === 0 || matchModeValue < 0 || matchModeValue > 1 || matchEndValue < 0 || matchEndValue > 1) return ErrorValueObject.create("#VALUE!");
|
|
42485
|
-
if (delimiterValue.includes(""))
|
|
42486
|
-
|
|
42890
|
+
if (delimiterValue.includes("")) {
|
|
42891
|
+
if (instanceNumValue > 0) return StringValueObject.create("");
|
|
42892
|
+
else return StringValueObject.create(textValue);
|
|
42893
|
+
}
|
|
42487
42894
|
if (!instanceNumIsNull && Math.abs(instanceNumValue) > textValue.length) return ErrorValueObject.create("#VALUE!");
|
|
42488
42895
|
if (delimiterValue.every((item) => item.length > textValue.length)) return ErrorValueObject.create("#N/A");
|
|
42489
42896
|
return this._getResult(textValue, delimiterValue, instanceNumValue, matchModeValue, matchEndValue, ifNotFoundObject, onlyThreeVariant);
|
|
@@ -42570,8 +42977,10 @@ var Textbefore = class extends BaseFunction {
|
|
|
42570
42977
|
}
|
|
42571
42978
|
if (matchNum && matchNum < Math.abs(instanceNumValue) && onlyThreeVariant) return ErrorValueObject.create("#N/A");
|
|
42572
42979
|
if (!matchNum || matchNum < Math.abs(instanceNumValue)) {
|
|
42573
|
-
if (matchEndValue)
|
|
42574
|
-
|
|
42980
|
+
if (matchEndValue) {
|
|
42981
|
+
if (instanceNumValue > 0) return StringValueObject.create(textValue);
|
|
42982
|
+
else return StringValueObject.create("");
|
|
42983
|
+
}
|
|
42575
42984
|
return ifNotFoundObject;
|
|
42576
42985
|
}
|
|
42577
42986
|
const result = textValue.substr(0, resultIndex);
|
|
@@ -43221,7 +43630,7 @@ function getObjectValue(result, isUseStrip = false) {
|
|
|
43221
43630
|
//#endregion
|
|
43222
43631
|
//#region package.json
|
|
43223
43632
|
var name = "@univerjs/engine-formula";
|
|
43224
|
-
var version = "1.0.
|
|
43633
|
+
var version = "1.0.1";
|
|
43225
43634
|
|
|
43226
43635
|
//#endregion
|
|
43227
43636
|
//#region src/services/global-computing-status.service.ts
|
|
@@ -43393,10 +43802,13 @@ let FormulaCalculationTriggerService = class FormulaCalculationTriggerService ex
|
|
|
43393
43802
|
if (this._hasPendingCalculation || this._waitingCommandQueue.length > 0) this._scheduleFlush();
|
|
43394
43803
|
}
|
|
43395
43804
|
_generateDirty(commands) {
|
|
43396
|
-
|
|
43805
|
+
const result = createEmptyDirtyData();
|
|
43806
|
+
const rangeKeys = /* @__PURE__ */ new Set();
|
|
43807
|
+
for (const command of commands) {
|
|
43397
43808
|
const conversion = this._activeDirtyManagerService.get(command.id);
|
|
43398
|
-
|
|
43399
|
-
}
|
|
43809
|
+
if (conversion) appendDirtyData(result, conversion.getDirtyData(command), rangeKeys);
|
|
43810
|
+
}
|
|
43811
|
+
return result;
|
|
43400
43812
|
}
|
|
43401
43813
|
};
|
|
43402
43814
|
FormulaCalculationTriggerService = __decorate([__decorateParam(0, _univerjs_core.ICommandService), __decorateParam(1, IActiveDirtyManagerService)], FormulaCalculationTriggerService);
|
|
@@ -43404,30 +43816,32 @@ function createEmptyDirtyData() {
|
|
|
43404
43816
|
return {
|
|
43405
43817
|
forceCalculation: false,
|
|
43406
43818
|
dirtyRanges: [],
|
|
43407
|
-
dirtyNameMap:
|
|
43408
|
-
dirtyDefinedNameMap:
|
|
43409
|
-
dirtySuperTableMap:
|
|
43410
|
-
dirtyUnitFeatureMap:
|
|
43411
|
-
dirtyUnitOtherFormulaMap:
|
|
43412
|
-
clearDependencyTreeCache:
|
|
43819
|
+
dirtyNameMap: Object.create(null),
|
|
43820
|
+
dirtyDefinedNameMap: Object.create(null),
|
|
43821
|
+
dirtySuperTableMap: Object.create(null),
|
|
43822
|
+
dirtyUnitFeatureMap: Object.create(null),
|
|
43823
|
+
dirtyUnitOtherFormulaMap: Object.create(null),
|
|
43824
|
+
clearDependencyTreeCache: Object.create(null)
|
|
43413
43825
|
};
|
|
43414
43826
|
}
|
|
43415
43827
|
function mergeDirtyData(left, right) {
|
|
43416
|
-
const
|
|
43417
|
-
|
|
43418
|
-
|
|
43419
|
-
|
|
43420
|
-
|
|
43421
|
-
dirtyDefinedNameMap: mergeDirtyUnitStringMap(left.dirtyDefinedNameMap, right.dirtyDefinedNameMap),
|
|
43422
|
-
dirtySuperTableMap: mergeDirtyUnitStringMap(left.dirtySuperTableMap ?? {}, right.dirtySuperTableMap),
|
|
43423
|
-
dirtyUnitFeatureMap: mergeDirtyUnitNestedMap(left.dirtyUnitFeatureMap, right.dirtyUnitFeatureMap),
|
|
43424
|
-
dirtyUnitOtherFormulaMap: mergeDirtyUnitNestedMap(left.dirtyUnitOtherFormulaMap, right.dirtyUnitOtherFormulaMap),
|
|
43425
|
-
clearDependencyTreeCache: mergeDirtyUnitStringMap(left.clearDependencyTreeCache, right.clearDependencyTreeCache),
|
|
43426
|
-
forceCalculation: left.forceCalculation || Boolean(right.forceCalculation)
|
|
43427
|
-
};
|
|
43828
|
+
const result = createEmptyDirtyData();
|
|
43829
|
+
const rangeKeys = /* @__PURE__ */ new Set();
|
|
43830
|
+
appendDirtyData(result, left, rangeKeys);
|
|
43831
|
+
appendDirtyData(result, right, rangeKeys);
|
|
43832
|
+
return result;
|
|
43428
43833
|
}
|
|
43429
|
-
function
|
|
43430
|
-
|
|
43834
|
+
function appendDirtyData(target, source, rangeKeys) {
|
|
43835
|
+
mergeDirtyRanges(target.dirtyRanges, source.dirtyRanges ?? [], rangeKeys);
|
|
43836
|
+
mergeDirtyUnitStringMap(target.dirtyNameMap, source.dirtyNameMap);
|
|
43837
|
+
mergeDirtyUnitStringMap(target.dirtyDefinedNameMap, source.dirtyDefinedNameMap);
|
|
43838
|
+
mergeDirtyUnitStringMap(target.dirtySuperTableMap ??= Object.create(null), source.dirtySuperTableMap);
|
|
43839
|
+
mergeDirtyUnitNestedMap(target.dirtyUnitFeatureMap, source.dirtyUnitFeatureMap);
|
|
43840
|
+
mergeDirtyUnitNestedMap(target.dirtyUnitOtherFormulaMap, source.dirtyUnitOtherFormulaMap);
|
|
43841
|
+
mergeDirtyUnitStringMap(target.clearDependencyTreeCache, source.clearDependencyTreeCache);
|
|
43842
|
+
target.forceCalculation = target.forceCalculation || Boolean(source.forceCalculation);
|
|
43843
|
+
}
|
|
43844
|
+
function mergeDirtyRanges(target, source, keys) {
|
|
43431
43845
|
source.forEach((range) => {
|
|
43432
43846
|
const key = getDirtyRangeKey(range);
|
|
43433
43847
|
if (!keys.has(key)) {
|
|
@@ -43447,29 +43861,18 @@ function getDirtyRangeKey({ unitId, sheetId, range }) {
|
|
|
43447
43861
|
range.rangeType
|
|
43448
43862
|
]);
|
|
43449
43863
|
}
|
|
43450
|
-
function mergeDirtyUnitStringMap(
|
|
43451
|
-
const result = { ...left };
|
|
43864
|
+
function mergeDirtyUnitStringMap(target, right) {
|
|
43452
43865
|
Object.entries(right ?? {}).forEach(([unitId, values]) => {
|
|
43453
|
-
|
|
43454
|
-
...result[unitId],
|
|
43455
|
-
...values
|
|
43456
|
-
};
|
|
43866
|
+
Object.assign(target[unitId] ??= Object.create(null), values);
|
|
43457
43867
|
});
|
|
43458
|
-
return result;
|
|
43459
43868
|
}
|
|
43460
|
-
function mergeDirtyUnitNestedMap(
|
|
43461
|
-
const result = { ...left };
|
|
43869
|
+
function mergeDirtyUnitNestedMap(target, right) {
|
|
43462
43870
|
Object.entries(right ?? {}).forEach(([unitId, sheets]) => {
|
|
43463
|
-
const unitResult =
|
|
43871
|
+
const unitResult = target[unitId] ??= Object.create(null);
|
|
43464
43872
|
Object.entries(sheets ?? {}).forEach(([sheetId, values]) => {
|
|
43465
|
-
unitResult[sheetId]
|
|
43466
|
-
...unitResult[sheetId],
|
|
43467
|
-
...values
|
|
43468
|
-
};
|
|
43873
|
+
Object.assign(unitResult[sheetId] ??= Object.create(null), values);
|
|
43469
43874
|
});
|
|
43470
|
-
result[unitId] = unitResult;
|
|
43471
43875
|
});
|
|
43472
|
-
return result;
|
|
43473
43876
|
}
|
|
43474
43877
|
function hasDirtyData(dirtyData) {
|
|
43475
43878
|
return dirtyData.forceCalculation || dirtyData.dirtyRanges.length > 0 || hasNestedValue(dirtyData.dirtyNameMap) || hasNestedValue(dirtyData.dirtyDefinedNameMap) || hasNestedValue(dirtyData.dirtySuperTableMap) || hasNestedValue(dirtyData.dirtyUnitFeatureMap) || hasNestedValue(dirtyData.dirtyUnitOtherFormulaMap) || hasNestedValue(dirtyData.clearDependencyTreeCache);
|