@univerjs/engine-formula 1.0.0-rc.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/index.js
CHANGED
|
@@ -150,7 +150,185 @@ let FunctionType = /* @__PURE__ */ function(FunctionType) {
|
|
|
150
150
|
}({});
|
|
151
151
|
|
|
152
152
|
//#endregion
|
|
153
|
-
//#region
|
|
153
|
+
//#region src/basics/token.ts
|
|
154
|
+
/**
|
|
155
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
156
|
+
*
|
|
157
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
158
|
+
* you may not use this file except in compliance with the License.
|
|
159
|
+
* You may obtain a copy of the License at
|
|
160
|
+
*
|
|
161
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
162
|
+
*
|
|
163
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
164
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
165
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
166
|
+
* See the License for the specific language governing permissions and
|
|
167
|
+
* limitations under the License.
|
|
168
|
+
*/
|
|
169
|
+
let operatorToken = /* @__PURE__ */ function(operatorToken) {
|
|
170
|
+
operatorToken["PLUS"] = "+";
|
|
171
|
+
operatorToken["MINUS"] = "-";
|
|
172
|
+
operatorToken["MULTIPLY"] = "*";
|
|
173
|
+
operatorToken["DIVIDED"] = "/";
|
|
174
|
+
operatorToken["CONCATENATE"] = "&";
|
|
175
|
+
operatorToken["POWER"] = "^";
|
|
176
|
+
operatorToken["EQUALS"] = "=";
|
|
177
|
+
operatorToken["NOT_EQUAL"] = "<>";
|
|
178
|
+
operatorToken["GREATER_THAN"] = ">";
|
|
179
|
+
operatorToken["GREATER_THAN_OR_EQUAL"] = ">=";
|
|
180
|
+
operatorToken["LESS_THAN"] = "<";
|
|
181
|
+
operatorToken["LESS_THAN_OR_EQUAL"] = "<=";
|
|
182
|
+
return operatorToken;
|
|
183
|
+
}({});
|
|
184
|
+
let compareToken = /* @__PURE__ */ function(compareToken) {
|
|
185
|
+
compareToken["EQUALS"] = "=";
|
|
186
|
+
compareToken["NOT_EQUAL"] = "<>";
|
|
187
|
+
compareToken["GREATER_THAN"] = ">";
|
|
188
|
+
compareToken["GREATER_THAN_OR_EQUAL"] = ">=";
|
|
189
|
+
compareToken["LESS_THAN"] = "<";
|
|
190
|
+
compareToken["LESS_THAN_OR_EQUAL"] = "<=";
|
|
191
|
+
return compareToken;
|
|
192
|
+
}({});
|
|
193
|
+
const OPERATOR_TOKEN_PRIORITY = /* @__PURE__ */ new Map([
|
|
194
|
+
["<>", 4],
|
|
195
|
+
["<", 4],
|
|
196
|
+
[">=", 4],
|
|
197
|
+
["=", 4],
|
|
198
|
+
[">", 4],
|
|
199
|
+
["<=", 4],
|
|
200
|
+
["&", 3],
|
|
201
|
+
["+", 2],
|
|
202
|
+
["-", 2],
|
|
203
|
+
["/", 1],
|
|
204
|
+
["*", 1],
|
|
205
|
+
["^", 0]
|
|
206
|
+
]);
|
|
207
|
+
const OPERATOR_TOKEN_SET = new Set(OPERATOR_TOKEN_PRIORITY.keys());
|
|
208
|
+
const OPERATOR_TOKEN_COMPARE_SET = /* @__PURE__ */ new Set([
|
|
209
|
+
"=",
|
|
210
|
+
"<>",
|
|
211
|
+
">",
|
|
212
|
+
">=",
|
|
213
|
+
"<",
|
|
214
|
+
"<="
|
|
215
|
+
]);
|
|
216
|
+
let matchToken = /* @__PURE__ */ function(matchToken) {
|
|
217
|
+
matchToken["OPEN_BRACKET"] = "(";
|
|
218
|
+
matchToken["CLOSE_BRACKET"] = ")";
|
|
219
|
+
matchToken["COMMA"] = ",";
|
|
220
|
+
matchToken["SINGLE_QUOTATION"] = "'";
|
|
221
|
+
matchToken["DOUBLE_QUOTATION"] = "\"";
|
|
222
|
+
matchToken["OPEN_BRACES"] = "{";
|
|
223
|
+
matchToken["CLOSE_BRACES"] = "}";
|
|
224
|
+
matchToken["COLON"] = ":";
|
|
225
|
+
matchToken["OPEN_SQUARE_BRACKET"] = "[";
|
|
226
|
+
matchToken["CLOSE_SQUARE_BRACKET"] = "]";
|
|
227
|
+
return matchToken;
|
|
228
|
+
}({});
|
|
229
|
+
let suffixToken = /* @__PURE__ */ function(suffixToken) {
|
|
230
|
+
suffixToken["PERCENTAGE"] = "%";
|
|
231
|
+
suffixToken["POUND"] = "#";
|
|
232
|
+
return suffixToken;
|
|
233
|
+
}({});
|
|
234
|
+
const SUFFIX_TOKEN_SET = /* @__PURE__ */ new Set(["%", "#"]);
|
|
235
|
+
let prefixToken = /* @__PURE__ */ function(prefixToken) {
|
|
236
|
+
prefixToken["AT"] = "@";
|
|
237
|
+
prefixToken["MINUS"] = "-";
|
|
238
|
+
prefixToken["PLUS"] = "+";
|
|
239
|
+
return prefixToken;
|
|
240
|
+
}({});
|
|
241
|
+
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/engine/utils/compare.ts
|
|
244
|
+
function getCompare() {
|
|
245
|
+
if (Intl && Intl.Collator) return new Intl.Collator(void 0, { numeric: false }).compare;
|
|
246
|
+
return (a, b) => {
|
|
247
|
+
return a.localeCompare(b);
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function isWildcard(str) {
|
|
251
|
+
return str.indexOf("*") > -1 || str.indexOf("?") > -1;
|
|
252
|
+
}
|
|
253
|
+
const TEXT_LIGATURES = {
|
|
254
|
+
ß: "ss",
|
|
255
|
+
æ: "ae",
|
|
256
|
+
œ: "oe",
|
|
257
|
+
ff: "ff",
|
|
258
|
+
fi: "fi",
|
|
259
|
+
fl: "fl",
|
|
260
|
+
ffi: "ffi",
|
|
261
|
+
ffl: "ffl",
|
|
262
|
+
ſt: "st",
|
|
263
|
+
st: "st"
|
|
264
|
+
};
|
|
265
|
+
function normalizeTextForComparison(value) {
|
|
266
|
+
const lower = value.toLowerCase();
|
|
267
|
+
return /[\u0080-\uFFFF]/.test(lower) ? lower.normalize("NFC").replace(/[ßæœff-st]/g, (character) => TEXT_LIGATURES[character]) : lower;
|
|
268
|
+
}
|
|
269
|
+
function isMatchWildcard(currentValue, value) {
|
|
270
|
+
const pattern = escapeRegExpForWildcard(value).replace(/~?[*?]/g, (match) => {
|
|
271
|
+
if (match.startsWith("~")) return `\\${match.substring(1)}`;
|
|
272
|
+
if (match === "*") return ".*";
|
|
273
|
+
if (match === "?") return ".";
|
|
274
|
+
return match;
|
|
275
|
+
});
|
|
276
|
+
return new RegExp(`^${pattern}$`, "s").test(currentValue);
|
|
277
|
+
}
|
|
278
|
+
function replaceWildcard(value) {
|
|
279
|
+
return value.replace(/~?[*?]/g, (match) => {
|
|
280
|
+
if (match.startsWith("~")) return match.substring(1);
|
|
281
|
+
return " ";
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
function compareWithWildcard(currentValue, value, operator, isCaseSensitive = true) {
|
|
285
|
+
let currentText = currentValue;
|
|
286
|
+
let pattern = value;
|
|
287
|
+
if (!isCaseSensitive) {
|
|
288
|
+
const fold = (text) => {
|
|
289
|
+
if (!/[\u0080-\uFFFF]/.test(text)) return text.toLowerCase();
|
|
290
|
+
return text.replace(/[\s\S]/g, (character) => {
|
|
291
|
+
const lower = character.toLowerCase();
|
|
292
|
+
return lower.length === 1 ? lower : character;
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
currentText = fold(currentText);
|
|
296
|
+
pattern = fold(pattern);
|
|
297
|
+
}
|
|
298
|
+
let result = false;
|
|
299
|
+
switch (operator) {
|
|
300
|
+
case "=":
|
|
301
|
+
result = isMatchWildcard(currentText, pattern);
|
|
302
|
+
break;
|
|
303
|
+
case "<>":
|
|
304
|
+
result = !isMatchWildcard(currentText, pattern);
|
|
305
|
+
break;
|
|
306
|
+
case ">":
|
|
307
|
+
case ">=":
|
|
308
|
+
result = isMatchWildcard(currentText, pattern) || currentText > replaceWildcard(pattern);
|
|
309
|
+
break;
|
|
310
|
+
case "<":
|
|
311
|
+
case "<=": result = currentText < replaceWildcard(pattern);
|
|
312
|
+
}
|
|
313
|
+
return result;
|
|
314
|
+
}
|
|
315
|
+
function escapeRegExpForWildcard(str) {
|
|
316
|
+
return str.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
317
|
+
}
|
|
318
|
+
function getMatchModeValue(matchModeValue) {
|
|
319
|
+
switch (matchModeValue) {
|
|
320
|
+
case 1: return 2;
|
|
321
|
+
case 0: return 0;
|
|
322
|
+
case -1: return 1;
|
|
323
|
+
default: return 0;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function getSearchModeValue(searchModeValue) {
|
|
327
|
+
return searchModeValue === -2 ? 1 : 0;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
//#endregion
|
|
331
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
154
332
|
function _typeof(o) {
|
|
155
333
|
"@babel/helpers - typeof";
|
|
156
334
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -161,7 +339,7 @@ function _typeof(o) {
|
|
|
161
339
|
}
|
|
162
340
|
|
|
163
341
|
//#endregion
|
|
164
|
-
//#region \0@oxc-project+runtime@0.
|
|
342
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
165
343
|
function toPrimitive(t, r) {
|
|
166
344
|
if ("object" != _typeof(t) || !t) return t;
|
|
167
345
|
var e = t[Symbol.toPrimitive];
|
|
@@ -174,14 +352,14 @@ function toPrimitive(t, r) {
|
|
|
174
352
|
}
|
|
175
353
|
|
|
176
354
|
//#endregion
|
|
177
|
-
//#region \0@oxc-project+runtime@0.
|
|
355
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
178
356
|
function toPropertyKey(t) {
|
|
179
357
|
var i = toPrimitive(t, "string");
|
|
180
358
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
181
359
|
}
|
|
182
360
|
|
|
183
361
|
//#endregion
|
|
184
|
-
//#region \0@oxc-project+runtime@0.
|
|
362
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
185
363
|
function _defineProperty(e, r, t) {
|
|
186
364
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
187
365
|
value: t,
|
|
@@ -199,8 +377,8 @@ function normalizeValue(value) {
|
|
|
199
377
|
if (normalizedValueMap.has(value)) return normalizedValueMap.get(value);
|
|
200
378
|
let _value;
|
|
201
379
|
if (value === null || value === void 0 || value === "") _value = DEFAULT_EMPTY_CELL_KEY;
|
|
202
|
-
else if (isRealNum(value) && Number(value).toString() === value.toString()) _value = Number(value) === 0 ? 0 : Number(value);
|
|
203
|
-
else if (typeof value === "string") _value = value
|
|
380
|
+
else if (isRealNum(value) && Number.isFinite(Number(value)) && Number(value).toString() === value.toString()) _value = Number(value) === 0 ? 0 : Number(value);
|
|
381
|
+
else if (typeof value === "string") _value = normalizeTextForComparison(value);
|
|
204
382
|
else _value = value;
|
|
205
383
|
normalizedValueMap.set(value, _value);
|
|
206
384
|
return _value;
|
|
@@ -208,9 +386,11 @@ function normalizeValue(value) {
|
|
|
208
386
|
var InvertedIndexCache = class {
|
|
209
387
|
constructor() {
|
|
210
388
|
_defineProperty(this, "_cache", /* @__PURE__ */ new Map());
|
|
389
|
+
_defineProperty(this, "_rowValues", /* @__PURE__ */ new WeakMap());
|
|
211
390
|
_defineProperty(this, "_continueBuildingCache", /* @__PURE__ */ new Map());
|
|
212
391
|
}
|
|
213
392
|
set(unitId, sheetId, column, value, row, isForceUpdate = false) {
|
|
393
|
+
var _rowIndex$values;
|
|
214
394
|
if (!this.shouldContinueBuildingCache(unitId, sheetId, column, row) && !isForceUpdate) return;
|
|
215
395
|
let unitMap = this._cache.get(unitId);
|
|
216
396
|
if (unitMap == null) {
|
|
@@ -227,10 +407,28 @@ var InvertedIndexCache = class {
|
|
|
227
407
|
columnMap = /* @__PURE__ */ new Map();
|
|
228
408
|
sheetMap.set(column, columnMap);
|
|
229
409
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
410
|
+
let rowIndex = this._rowValues.get(columnMap);
|
|
411
|
+
if (rowIndex == null) {
|
|
412
|
+
rowIndex = { lastRow: -1 };
|
|
413
|
+
this._rowValues.set(columnMap, rowIndex);
|
|
414
|
+
}
|
|
415
|
+
if (!rowIndex.values && (isForceUpdate || row <= rowIndex.lastRow)) {
|
|
416
|
+
if (columnMap.size <= 32) {
|
|
417
|
+
for (const [key, rows] of columnMap) if (rows.delete(row)) {
|
|
418
|
+
if (rows.size === 0) columnMap.delete(key);
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
} else {
|
|
422
|
+
rowIndex.values = /* @__PURE__ */ new Map();
|
|
423
|
+
for (const [key, rows] of columnMap) for (const indexedRow of rows) rowIndex.values.set(indexedRow, key);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
if (rowIndex.values) {
|
|
427
|
+
const oldValue = rowIndex.values.get(row);
|
|
428
|
+
if (oldValue !== void 0) {
|
|
429
|
+
const oldRows = columnMap.get(oldValue);
|
|
430
|
+
oldRows.delete(row);
|
|
431
|
+
if (oldRows.size === 0) columnMap.delete(oldValue);
|
|
234
432
|
}
|
|
235
433
|
}
|
|
236
434
|
const _value = normalizeValue(value);
|
|
@@ -240,6 +438,8 @@ var InvertedIndexCache = class {
|
|
|
240
438
|
columnMap.set(_value, cellList);
|
|
241
439
|
}
|
|
242
440
|
cellList.add(row);
|
|
441
|
+
(_rowIndex$values = rowIndex.values) === null || _rowIndex$values === void 0 || _rowIndex$values.set(row, _value);
|
|
442
|
+
rowIndex.lastRow = Math.max(rowIndex.lastRow, row);
|
|
243
443
|
}
|
|
244
444
|
getCellValuePositions(unitId, sheetId, column) {
|
|
245
445
|
var _this$_cache$get;
|
|
@@ -364,96 +564,6 @@ var InvertedIndexCache = class {
|
|
|
364
564
|
};
|
|
365
565
|
const CELL_INVERTED_INDEX_CACHE = new InvertedIndexCache();
|
|
366
566
|
|
|
367
|
-
//#endregion
|
|
368
|
-
//#region src/basics/token.ts
|
|
369
|
-
/**
|
|
370
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
371
|
-
*
|
|
372
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
373
|
-
* you may not use this file except in compliance with the License.
|
|
374
|
-
* You may obtain a copy of the License at
|
|
375
|
-
*
|
|
376
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
377
|
-
*
|
|
378
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
379
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
380
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
381
|
-
* See the License for the specific language governing permissions and
|
|
382
|
-
* limitations under the License.
|
|
383
|
-
*/
|
|
384
|
-
let operatorToken = /* @__PURE__ */ function(operatorToken) {
|
|
385
|
-
operatorToken["PLUS"] = "+";
|
|
386
|
-
operatorToken["MINUS"] = "-";
|
|
387
|
-
operatorToken["MULTIPLY"] = "*";
|
|
388
|
-
operatorToken["DIVIDED"] = "/";
|
|
389
|
-
operatorToken["CONCATENATE"] = "&";
|
|
390
|
-
operatorToken["POWER"] = "^";
|
|
391
|
-
operatorToken["EQUALS"] = "=";
|
|
392
|
-
operatorToken["NOT_EQUAL"] = "<>";
|
|
393
|
-
operatorToken["GREATER_THAN"] = ">";
|
|
394
|
-
operatorToken["GREATER_THAN_OR_EQUAL"] = ">=";
|
|
395
|
-
operatorToken["LESS_THAN"] = "<";
|
|
396
|
-
operatorToken["LESS_THAN_OR_EQUAL"] = "<=";
|
|
397
|
-
return operatorToken;
|
|
398
|
-
}({});
|
|
399
|
-
let compareToken = /* @__PURE__ */ function(compareToken) {
|
|
400
|
-
compareToken["EQUALS"] = "=";
|
|
401
|
-
compareToken["NOT_EQUAL"] = "<>";
|
|
402
|
-
compareToken["GREATER_THAN"] = ">";
|
|
403
|
-
compareToken["GREATER_THAN_OR_EQUAL"] = ">=";
|
|
404
|
-
compareToken["LESS_THAN"] = "<";
|
|
405
|
-
compareToken["LESS_THAN_OR_EQUAL"] = "<=";
|
|
406
|
-
return compareToken;
|
|
407
|
-
}({});
|
|
408
|
-
const OPERATOR_TOKEN_PRIORITY = /* @__PURE__ */ new Map([
|
|
409
|
-
["<>", 4],
|
|
410
|
-
["<", 4],
|
|
411
|
-
[">=", 4],
|
|
412
|
-
["=", 4],
|
|
413
|
-
[">", 4],
|
|
414
|
-
["<=", 4],
|
|
415
|
-
["&", 3],
|
|
416
|
-
["+", 2],
|
|
417
|
-
["-", 2],
|
|
418
|
-
["/", 1],
|
|
419
|
-
["*", 1],
|
|
420
|
-
["^", 0]
|
|
421
|
-
]);
|
|
422
|
-
const OPERATOR_TOKEN_SET = new Set(OPERATOR_TOKEN_PRIORITY.keys());
|
|
423
|
-
const OPERATOR_TOKEN_COMPARE_SET = /* @__PURE__ */ new Set([
|
|
424
|
-
"=",
|
|
425
|
-
"<>",
|
|
426
|
-
">",
|
|
427
|
-
">=",
|
|
428
|
-
"<",
|
|
429
|
-
"<="
|
|
430
|
-
]);
|
|
431
|
-
let matchToken = /* @__PURE__ */ function(matchToken) {
|
|
432
|
-
matchToken["OPEN_BRACKET"] = "(";
|
|
433
|
-
matchToken["CLOSE_BRACKET"] = ")";
|
|
434
|
-
matchToken["COMMA"] = ",";
|
|
435
|
-
matchToken["SINGLE_QUOTATION"] = "'";
|
|
436
|
-
matchToken["DOUBLE_QUOTATION"] = "\"";
|
|
437
|
-
matchToken["OPEN_BRACES"] = "{";
|
|
438
|
-
matchToken["CLOSE_BRACES"] = "}";
|
|
439
|
-
matchToken["COLON"] = ":";
|
|
440
|
-
matchToken["OPEN_SQUARE_BRACKET"] = "[";
|
|
441
|
-
matchToken["CLOSE_SQUARE_BRACKET"] = "]";
|
|
442
|
-
return matchToken;
|
|
443
|
-
}({});
|
|
444
|
-
let suffixToken = /* @__PURE__ */ function(suffixToken) {
|
|
445
|
-
suffixToken["PERCENTAGE"] = "%";
|
|
446
|
-
suffixToken["POUND"] = "#";
|
|
447
|
-
return suffixToken;
|
|
448
|
-
}({});
|
|
449
|
-
const SUFFIX_TOKEN_SET = /* @__PURE__ */ new Set(["%", "#"]);
|
|
450
|
-
let prefixToken = /* @__PURE__ */ function(prefixToken) {
|
|
451
|
-
prefixToken["AT"] = "@";
|
|
452
|
-
prefixToken["MINUS"] = "-";
|
|
453
|
-
prefixToken["PLUS"] = "+";
|
|
454
|
-
return prefixToken;
|
|
455
|
-
}({});
|
|
456
|
-
|
|
457
567
|
//#endregion
|
|
458
568
|
//#region src/basics/match-token.ts
|
|
459
569
|
/**
|
|
@@ -552,7 +662,7 @@ const ABSOLUTE_SYMBOL = "$";
|
|
|
552
662
|
const RANGE_SYMBOL = "\\s*?:\\s*?";
|
|
553
663
|
const COLUMN_REGEX = "[A-Za-z]+";
|
|
554
664
|
const ROW_REGEX = "[1-9][0-9]*";
|
|
555
|
-
const UNIT_NAME_SHEET_NAME_REGEX = `'?(${UNIT_NAME_REGEX})?(${SHEET_NAME_REGEX})?'?`;
|
|
665
|
+
const UNIT_NAME_SHEET_NAME_REGEX = `(?:'(?:[^'\\[]|'')*[\\\\/]|'?)(${UNIT_NAME_REGEX})?(${SHEET_NAME_REGEX})?'?`;
|
|
556
666
|
const SIMPLE_SINGLE_RANGE_REGEX = `\\${"$"}?${COLUMN_REGEX}\\${"$"}?${ROW_REGEX}`;
|
|
557
667
|
const REFERENCE_MULTIPLE_RANGE_REGEX = `^(${"@"})?${UNIT_NAME_SHEET_NAME_REGEX}${SIMPLE_SINGLE_RANGE_REGEX}${RANGE_SYMBOL}${SIMPLE_SINGLE_RANGE_REGEX}$`;
|
|
558
668
|
const REFERENCE_MULTIPLE_RANGE_REGEX_PRECOMPILING = new RegExp(REFERENCE_MULTIPLE_RANGE_REGEX);
|
|
@@ -635,11 +745,11 @@ function isReferenceString(refString) {
|
|
|
635
745
|
//#endregion
|
|
636
746
|
//#region src/basics/runtime.ts
|
|
637
747
|
function convertUnitDataToRuntime(unitData) {
|
|
638
|
-
const arrayFormulaCellData =
|
|
748
|
+
const arrayFormulaCellData = Object.create(null);
|
|
639
749
|
Object.keys(unitData).forEach((unitId) => {
|
|
640
750
|
const sheetData = unitData[unitId];
|
|
641
751
|
if (sheetData == null) return true;
|
|
642
|
-
if (arrayFormulaCellData[unitId] == null) arrayFormulaCellData[unitId] =
|
|
752
|
+
if (arrayFormulaCellData[unitId] == null) arrayFormulaCellData[unitId] = Object.create(null);
|
|
643
753
|
Object.keys(sheetData).forEach((sheetId) => {
|
|
644
754
|
const cellData = sheetData[sheetId];
|
|
645
755
|
arrayFormulaCellData[unitId][sheetId] = new ObjectMatrix(cellData);
|
|
@@ -648,16 +758,16 @@ function convertUnitDataToRuntime(unitData) {
|
|
|
648
758
|
return arrayFormulaCellData;
|
|
649
759
|
}
|
|
650
760
|
function convertRuntimeToUnitData(unitData) {
|
|
651
|
-
const unitPrimitiveData =
|
|
652
|
-
for (const unitId
|
|
761
|
+
const unitPrimitiveData = Object.create(null);
|
|
762
|
+
for (const unitId of Object.keys(unitData)) {
|
|
653
763
|
const sheetData = unitData[unitId];
|
|
654
764
|
if (sheetData == null) continue;
|
|
655
|
-
if (unitPrimitiveData[unitId] == null) unitPrimitiveData[unitId] =
|
|
656
|
-
for (const sheetId
|
|
765
|
+
if (unitPrimitiveData[unitId] == null) unitPrimitiveData[unitId] = Object.create(null);
|
|
766
|
+
for (const sheetId of Object.keys(sheetData)) {
|
|
657
767
|
const cellData = sheetData[sheetId];
|
|
658
|
-
const primitiveData =
|
|
768
|
+
const primitiveData = Object.create(null);
|
|
659
769
|
cellData.forValue((row, column, value) => {
|
|
660
|
-
if (primitiveData[row] === void 0) primitiveData[row] =
|
|
770
|
+
if (primitiveData[row] === void 0) primitiveData[row] = Object.create(null);
|
|
661
771
|
primitiveData[row][column] = value;
|
|
662
772
|
});
|
|
663
773
|
unitPrimitiveData[unitId][sheetId] = primitiveData;
|
|
@@ -665,6 +775,12 @@ function convertRuntimeToUnitData(unitData) {
|
|
|
665
775
|
}
|
|
666
776
|
return unitPrimitiveData;
|
|
667
777
|
}
|
|
778
|
+
/** Copy the unit and sheet dictionaries without retaining inherited identifier keys. */
|
|
779
|
+
function copyUnitData(data) {
|
|
780
|
+
const result = Object.create(null);
|
|
781
|
+
for (const unitId of Object.keys(data)) if (data[unitId] != null) result[unitId] = Object.assign(Object.create(null), data[unitId]);
|
|
782
|
+
return result;
|
|
783
|
+
}
|
|
668
784
|
|
|
669
785
|
//#endregion
|
|
670
786
|
//#region src/basics/token-type.ts
|
|
@@ -830,6 +946,8 @@ function handleRefStringInfo(refString) {
|
|
|
830
946
|
if (unitIdMatch != null) {
|
|
831
947
|
unitQualifier = unitIdMatch[0].trim();
|
|
832
948
|
unitQualifier = unquoteSheetName(unitQualifier.slice(1, unitQualifier.length - 1));
|
|
949
|
+
const pathPrefix = refString.slice(0, unitIdMatch.index);
|
|
950
|
+
if (pathPrefix.startsWith("'") && /[\\/]$/.test(pathPrefix)) refString = `'${refString.slice(unitIdMatch.index)}`;
|
|
833
951
|
refString = refString.replace(UNIT_NAME_REGEX_PRECOMPILING, "");
|
|
834
952
|
}
|
|
835
953
|
const sheetNameIndex = refString.indexOf("!");
|
|
@@ -1068,7 +1186,7 @@ function splitTableStructuredRef(ref) {
|
|
|
1068
1186
|
}
|
|
1069
1187
|
|
|
1070
1188
|
//#endregion
|
|
1071
|
-
//#region \0@oxc-project+runtime@0.
|
|
1189
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
1072
1190
|
function __decorateParam(paramIndex, decorator) {
|
|
1073
1191
|
return function(target, key) {
|
|
1074
1192
|
decorator(target, key, paramIndex);
|
|
@@ -1076,7 +1194,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
1076
1194
|
}
|
|
1077
1195
|
|
|
1078
1196
|
//#endregion
|
|
1079
|
-
//#region \0@oxc-project+runtime@0.
|
|
1197
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
1080
1198
|
function __decorate(decorators, target, key, desc) {
|
|
1081
1199
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1082
1200
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1090,8 +1208,8 @@ let DefinedNamesService = class DefinedNamesService extends Disposable {
|
|
|
1090
1208
|
constructor(_univerInstanceService) {
|
|
1091
1209
|
super();
|
|
1092
1210
|
this._univerInstanceService = _univerInstanceService;
|
|
1093
|
-
_defineProperty(this, "_definedNameMap",
|
|
1094
|
-
_defineProperty(this, "_nameCacheMap",
|
|
1211
|
+
_defineProperty(this, "_definedNameMap", Object.create(null));
|
|
1212
|
+
_defineProperty(this, "_nameCacheMap", Object.create(null));
|
|
1095
1213
|
_defineProperty(this, "_definedNamesIsEmpty", true);
|
|
1096
1214
|
_defineProperty(this, "_update$", new Subject());
|
|
1097
1215
|
_defineProperty(this, "update$", this._update$.asObservable());
|
|
@@ -1112,8 +1230,8 @@ let DefinedNamesService = class DefinedNamesService extends Disposable {
|
|
|
1112
1230
|
}
|
|
1113
1231
|
dispose() {
|
|
1114
1232
|
super.dispose();
|
|
1115
|
-
this._definedNameMap =
|
|
1116
|
-
this._nameCacheMap =
|
|
1233
|
+
this._definedNameMap = Object.create(null);
|
|
1234
|
+
this._nameCacheMap = Object.create(null);
|
|
1117
1235
|
this._update$.complete();
|
|
1118
1236
|
this._currentRange$.complete();
|
|
1119
1237
|
this._focusRange$.complete();
|
|
@@ -1142,7 +1260,7 @@ let DefinedNamesService = class DefinedNamesService extends Disposable {
|
|
|
1142
1260
|
return serializeRange(this._currentRange.range);
|
|
1143
1261
|
}
|
|
1144
1262
|
registerDefinedNames(unitId, params) {
|
|
1145
|
-
this._definedNameMap[unitId] = params;
|
|
1263
|
+
this._definedNameMap[unitId] = Object.assign(Object.create(null), params);
|
|
1146
1264
|
this._updateCache(unitId);
|
|
1147
1265
|
const definedNames = Object.values(params);
|
|
1148
1266
|
this._update({
|
|
@@ -1153,7 +1271,7 @@ let DefinedNamesService = class DefinedNamesService extends Disposable {
|
|
|
1153
1271
|
if (definedNames.length > 0) this._definedNamesIsEmpty = false;
|
|
1154
1272
|
}
|
|
1155
1273
|
registerDefinedName(unitId, param) {
|
|
1156
|
-
if (this._definedNameMap[unitId] === void 0) this._definedNameMap[unitId] =
|
|
1274
|
+
if (this._definedNameMap[unitId] === void 0) this._definedNameMap[unitId] = Object.create(null);
|
|
1157
1275
|
this._definedNameMap[unitId][param.id] = param;
|
|
1158
1276
|
this._updateCache(unitId);
|
|
1159
1277
|
this._update({
|
|
@@ -1255,7 +1373,7 @@ let DefinedNamesService = class DefinedNamesService extends Disposable {
|
|
|
1255
1373
|
delete this._nameCacheMap[unitId];
|
|
1256
1374
|
return;
|
|
1257
1375
|
}
|
|
1258
|
-
this._nameCacheMap[unitId] =
|
|
1376
|
+
this._nameCacheMap[unitId] = Object.create(null);
|
|
1259
1377
|
for (const item of Object.values(nameMap)) {
|
|
1260
1378
|
const normalizedName = item.name.toLowerCase();
|
|
1261
1379
|
if (item.localSheetId === "AllDefaultWorkbook" || item.localSheetId == null || this._nameCacheMap[unitId][normalizedName] == null) this._nameCacheMap[unitId][normalizedName] = item;
|
|
@@ -2719,8 +2837,10 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
2719
2837
|
*/
|
|
2720
2838
|
while (parent) {
|
|
2721
2839
|
const token = parent.getToken();
|
|
2722
|
-
if (token !== "P_1" && token !== ":" && parent.getStartIndex() !== -1 && token.toUpperCase() !== "LAMBDA")
|
|
2723
|
-
|
|
2840
|
+
if (token !== "P_1" && token !== ":" && parent.getStartIndex() !== -1 && token.toUpperCase() !== "LAMBDA") {
|
|
2841
|
+
if (lastBracketCount === 0) bracketCount += 1;
|
|
2842
|
+
else lastBracketCount--;
|
|
2843
|
+
}
|
|
2724
2844
|
parent = parent.getParent();
|
|
2725
2845
|
}
|
|
2726
2846
|
return bracketCount;
|
|
@@ -2747,12 +2867,13 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
2747
2867
|
const sequenceGrid = deserializeRangeWithSheetWithCache(token);
|
|
2748
2868
|
if (sequenceGrid == null) continue;
|
|
2749
2869
|
const { range, sheetName, unitId } = sequenceGrid;
|
|
2870
|
+
const newRange = {
|
|
2871
|
+
...range,
|
|
2872
|
+
startAbsoluteRefType,
|
|
2873
|
+
endAbsoluteRefType
|
|
2874
|
+
};
|
|
2750
2875
|
const newToken = serializeRangeToRefString({
|
|
2751
|
-
range:
|
|
2752
|
-
...range,
|
|
2753
|
-
startAbsoluteRefType,
|
|
2754
|
-
endAbsoluteRefType
|
|
2755
|
-
},
|
|
2876
|
+
range: newRange,
|
|
2756
2877
|
unitId,
|
|
2757
2878
|
sheetName: sheetName || currentSheetName
|
|
2758
2879
|
});
|
|
@@ -2781,6 +2902,13 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
2781
2902
|
const newSequenceNodes = [];
|
|
2782
2903
|
for (let i = 0, len = sequenceNodes.length; i < len; i++) {
|
|
2783
2904
|
const node = sequenceNodes[i];
|
|
2905
|
+
if (typeof node !== "string" && node.nodeType === 2) {
|
|
2906
|
+
newSequenceNodes.push({
|
|
2907
|
+
...node,
|
|
2908
|
+
token: `"${node.token.slice(1, -1).replace(/"/g, "\"\"")}"`
|
|
2909
|
+
});
|
|
2910
|
+
continue;
|
|
2911
|
+
}
|
|
2784
2912
|
if (typeof node === "string" || node.nodeType !== 4) {
|
|
2785
2913
|
newSequenceNodes.push(node);
|
|
2786
2914
|
continue;
|
|
@@ -3511,35 +3639,36 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
3511
3639
|
}
|
|
3512
3640
|
this._resetSegment();
|
|
3513
3641
|
continue;
|
|
3514
|
-
} else if (currentString === "(" && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose())
|
|
3515
|
-
if (this.
|
|
3516
|
-
this.
|
|
3642
|
+
} else if (currentString === "(" && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose()) {
|
|
3643
|
+
if (this._segmentCount() > 0 || this.isLambdaOpen()) {
|
|
3644
|
+
if (this.isLambdaClose()) {
|
|
3645
|
+
this._newAndPushCurrentLexerNode(this._segment, cur);
|
|
3646
|
+
this._resetSegment();
|
|
3647
|
+
}
|
|
3648
|
+
this._openBracket(1);
|
|
3649
|
+
this._closeLambda();
|
|
3650
|
+
const nextCurrentString = formulaChars[cur + 1];
|
|
3651
|
+
if (nextCurrentString && nextCurrentString === ")") {
|
|
3652
|
+
if (!this._setParentCurrentLexerNode() && cur !== charsCount - 1) return "#VALUE!";
|
|
3653
|
+
/**
|
|
3654
|
+
* https://github.com/dream-num/univer/issues/1769
|
|
3655
|
+
* Formula example: =IF(TODAY()>1,"TRUE", "FALSE")
|
|
3656
|
+
* Copy or auto-fill at complex formula get error formula offset
|
|
3657
|
+
*/
|
|
3658
|
+
this._addSequenceArray(sequenceArray, currentString, cur);
|
|
3659
|
+
cur++;
|
|
3660
|
+
this._addSequenceArray(sequenceArray, nextCurrentString, cur);
|
|
3661
|
+
cur++;
|
|
3662
|
+
this._closeBracket();
|
|
3663
|
+
continue;
|
|
3664
|
+
} else if (nextCurrentString) this._newAndPushCurrentLexerNode("P_1", cur);
|
|
3665
|
+
} else {
|
|
3666
|
+
this._pushNodeToChildren(currentString);
|
|
3667
|
+
this._openBracket(0);
|
|
3668
|
+
this._openBracketNormalIndex();
|
|
3517
3669
|
this._resetSegment();
|
|
3518
3670
|
}
|
|
3519
|
-
|
|
3520
|
-
this._closeLambda();
|
|
3521
|
-
const nextCurrentString = formulaChars[cur + 1];
|
|
3522
|
-
if (nextCurrentString && nextCurrentString === ")") {
|
|
3523
|
-
if (!this._setParentCurrentLexerNode() && cur !== charsCount - 1) return "#VALUE!";
|
|
3524
|
-
/**
|
|
3525
|
-
* https://github.com/dream-num/univer/issues/1769
|
|
3526
|
-
* Formula example: =IF(TODAY()>1,"TRUE", "FALSE")
|
|
3527
|
-
* Copy or auto-fill at complex formula get error formula offset
|
|
3528
|
-
*/
|
|
3529
|
-
this._addSequenceArray(sequenceArray, currentString, cur);
|
|
3530
|
-
cur++;
|
|
3531
|
-
this._addSequenceArray(sequenceArray, nextCurrentString, cur);
|
|
3532
|
-
cur++;
|
|
3533
|
-
this._closeBracket();
|
|
3534
|
-
continue;
|
|
3535
|
-
} else if (nextCurrentString) this._newAndPushCurrentLexerNode("P_1", cur);
|
|
3536
|
-
} else {
|
|
3537
|
-
this._pushNodeToChildren(currentString);
|
|
3538
|
-
this._openBracket(0);
|
|
3539
|
-
this._openBracketNormalIndex();
|
|
3540
|
-
this._resetSegment();
|
|
3541
|
-
}
|
|
3542
|
-
else if (currentString === ")" && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose()) {
|
|
3671
|
+
} else if (currentString === ")" && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose()) {
|
|
3543
3672
|
if (this._formulaErrorLastTokenCheck(formulaChars, cur - 1)) this._formalErrorOccurred();
|
|
3544
3673
|
this._pushNodeToChildren(this._segment);
|
|
3545
3674
|
this._resetSegment();
|
|
@@ -3730,17 +3859,19 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
3730
3859
|
this._resetSegment();
|
|
3731
3860
|
cur++;
|
|
3732
3861
|
continue;
|
|
3733
|
-
} else if (this._unexpectedEndingToken(prevString))
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3862
|
+
} else if (this._unexpectedEndingToken(prevString)) {
|
|
3863
|
+
if (nextString === "+") {
|
|
3864
|
+
this._pushSegment("-");
|
|
3865
|
+
this._addSequenceArray(sequenceArray, currentString, cur);
|
|
3866
|
+
this._addSequenceArray(sequenceArray, "+", cur + 1);
|
|
3867
|
+
cur += 2;
|
|
3868
|
+
continue;
|
|
3869
|
+
} else {
|
|
3870
|
+
this._pushSegment("-");
|
|
3871
|
+
this._addSequenceArray(sequenceArray, currentString, cur);
|
|
3872
|
+
cur++;
|
|
3873
|
+
continue;
|
|
3874
|
+
}
|
|
3744
3875
|
}
|
|
3745
3876
|
} else if (this._segment.length > 0 && this._isScientificNotation(formulaChars, cur, currentString)) {
|
|
3746
3877
|
this._pushSegment(currentString);
|
|
@@ -4010,7 +4141,8 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
4010
4141
|
if (curNodeType === 8) {
|
|
4011
4142
|
const refNode = itemChildren[0];
|
|
4012
4143
|
if (refNode instanceof LexerNode) {
|
|
4013
|
-
|
|
4144
|
+
const refString = refNode.getToken().trim();
|
|
4145
|
+
if (isReferenceString(refString)) continue;
|
|
4014
4146
|
item = refNode;
|
|
4015
4147
|
}
|
|
4016
4148
|
}
|
|
@@ -4043,7 +4175,8 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
4043
4175
|
}
|
|
4044
4176
|
_getTableNameFromStructuredRef(token, getTable) {
|
|
4045
4177
|
const { tableName } = splitTableStructuredRef(token);
|
|
4046
|
-
|
|
4178
|
+
const isExplicitStructuredReference = token.includes("[") && (regexTestReferenceTableAllColumn(token) || regexTestReferenceTableSingleColumn(token) || regexTestReferenceTableMultipleColumn(token) || regexTestReferenceTableTitleOnlyAnyHash(token));
|
|
4179
|
+
if (getTable(this._currentUnitId, tableName) || isExplicitStructuredReference) return tableName;
|
|
4047
4180
|
return null;
|
|
4048
4181
|
}
|
|
4049
4182
|
_handleLambdaForExprTree(firstChild, newNode, hasFunction, getDefinedNameName, getTable) {
|
|
@@ -4168,17 +4301,17 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4168
4301
|
super();
|
|
4169
4302
|
this._univerInstanceService = _univerInstanceService;
|
|
4170
4303
|
this._lexerTreeBuilder = _lexerTreeBuilder;
|
|
4171
|
-
_defineProperty(this, "_formulaIdMapData",
|
|
4172
|
-
_defineProperty(this, "_arrayFormulaRange",
|
|
4173
|
-
_defineProperty(this, "_arrayFormulaCellData",
|
|
4174
|
-
_defineProperty(this, "_unitImageFormulaData",
|
|
4304
|
+
_defineProperty(this, "_formulaIdMapData", Object.create(null));
|
|
4305
|
+
_defineProperty(this, "_arrayFormulaRange", Object.create(null));
|
|
4306
|
+
_defineProperty(this, "_arrayFormulaCellData", Object.create(null));
|
|
4307
|
+
_defineProperty(this, "_unitImageFormulaData", Object.create(null));
|
|
4175
4308
|
}
|
|
4176
4309
|
dispose() {
|
|
4177
4310
|
super.dispose();
|
|
4178
|
-
this._formulaIdMapData =
|
|
4179
|
-
this._arrayFormulaRange =
|
|
4180
|
-
this._arrayFormulaCellData =
|
|
4181
|
-
this._unitImageFormulaData =
|
|
4311
|
+
this._formulaIdMapData = Object.create(null);
|
|
4312
|
+
this._arrayFormulaRange = Object.create(null);
|
|
4313
|
+
this._arrayFormulaCellData = Object.create(null);
|
|
4314
|
+
this._unitImageFormulaData = Object.create(null);
|
|
4182
4315
|
}
|
|
4183
4316
|
clearPreviousArrayFormulaCellData(clearArrayFormulaCellData) {
|
|
4184
4317
|
Object.keys(clearArrayFormulaCellData).forEach((unitId) => {
|
|
@@ -4210,8 +4343,8 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4210
4343
|
Object.keys(unitData).forEach((unitId) => {
|
|
4211
4344
|
const sheetData = unitData[unitId];
|
|
4212
4345
|
if (sheetData == null) return true;
|
|
4213
|
-
if (this._arrayFormulaRange[unitId] == null) this._arrayFormulaRange[unitId] =
|
|
4214
|
-
if (this._arrayFormulaCellData[unitId] == null) this._arrayFormulaCellData[unitId] =
|
|
4346
|
+
if (this._arrayFormulaRange[unitId] == null) this._arrayFormulaRange[unitId] = Object.create(null);
|
|
4347
|
+
if (this._arrayFormulaCellData[unitId] == null) this._arrayFormulaCellData[unitId] = Object.create(null);
|
|
4215
4348
|
Object.keys(sheetData).forEach((sheetId) => {
|
|
4216
4349
|
var _this$_arrayFormulaRa2, _this$_arrayFormulaCe3;
|
|
4217
4350
|
const cellMatrixData = sheetData[sheetId];
|
|
@@ -4235,12 +4368,12 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4235
4368
|
});
|
|
4236
4369
|
}
|
|
4237
4370
|
getFormulaData() {
|
|
4238
|
-
const formulaData =
|
|
4371
|
+
const formulaData = Object.create(null);
|
|
4239
4372
|
const allSheets = this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET);
|
|
4240
4373
|
for (let i = 0; i < allSheets.length; i++) {
|
|
4241
4374
|
const workbook = allSheets[i];
|
|
4242
4375
|
const unitId = workbook.getUnitId();
|
|
4243
|
-
formulaData[unitId] =
|
|
4376
|
+
formulaData[unitId] = Object.create(null);
|
|
4244
4377
|
const worksheets = workbook.getSheets();
|
|
4245
4378
|
for (let j = 0; j < worksheets.length; j++) {
|
|
4246
4379
|
const worksheet = worksheets[j];
|
|
@@ -4255,12 +4388,12 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4255
4388
|
const base = allBases[i];
|
|
4256
4389
|
const snapshot = base.getSnapshot();
|
|
4257
4390
|
const unitId = base.getUnitId();
|
|
4258
|
-
formulaData[unitId] =
|
|
4391
|
+
formulaData[unitId] = Object.create(null);
|
|
4259
4392
|
const tables = Object.values(snapshot.tables);
|
|
4260
4393
|
const formulaTableNames = createBaseFormulaTableNameMap(snapshot);
|
|
4261
4394
|
for (let j = 0; j < tables.length; j++) {
|
|
4262
4395
|
const table = tables[j];
|
|
4263
|
-
const tableFormulaData =
|
|
4396
|
+
const tableFormulaData = Object.create(null);
|
|
4264
4397
|
const normalizedFormulaByFieldId = /* @__PURE__ */ new Map();
|
|
4265
4398
|
const recordOrder = table.recordOrder;
|
|
4266
4399
|
if (!recordOrder) {
|
|
@@ -4282,7 +4415,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4282
4415
|
normalizedFormula = normalizeBaseFormulaForEngine(formula, table, snapshot, formulaTableNames);
|
|
4283
4416
|
normalizedFormulaByFieldId.set(field.id, normalizedFormula);
|
|
4284
4417
|
}
|
|
4285
|
-
tableFormulaData[row] ??=
|
|
4418
|
+
tableFormulaData[row] ??= Object.create(null);
|
|
4286
4419
|
tableFormulaData[row][col] = {
|
|
4287
4420
|
f: normalizedFormula,
|
|
4288
4421
|
si: field.id
|
|
@@ -4296,7 +4429,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4296
4429
|
}
|
|
4297
4430
|
initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix) {
|
|
4298
4431
|
const result = buildSheetFormulaData(formulaData, unitId, sheetId, cellMatrix);
|
|
4299
|
-
if (!this._formulaIdMapData[unitId]) this._formulaIdMapData[unitId] =
|
|
4432
|
+
if (!this._formulaIdMapData[unitId]) this._formulaIdMapData[unitId] = Object.create(null);
|
|
4300
4433
|
this._formulaIdMapData[unitId][sheetId] = result.formulaIdMap;
|
|
4301
4434
|
return result.formulaData;
|
|
4302
4435
|
}
|
|
@@ -4311,10 +4444,10 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4311
4444
|
if (Object.keys(unitFormulaIdMap).length === 0) delete this._formulaIdMapData[unitId];
|
|
4312
4445
|
}
|
|
4313
4446
|
getSheetFormulaData(unitId, sheetId) {
|
|
4314
|
-
const formulaData =
|
|
4447
|
+
const formulaData = Object.create(null);
|
|
4315
4448
|
const workbook = this._univerInstanceService.getUnit(unitId);
|
|
4316
4449
|
if (workbook == null) return {};
|
|
4317
|
-
formulaData[unitId] =
|
|
4450
|
+
formulaData[unitId] = Object.create(null);
|
|
4318
4451
|
const worksheet = workbook.getSheetBySheetId(sheetId);
|
|
4319
4452
|
if (worksheet == null) return {};
|
|
4320
4453
|
const cellMatrix = worksheet.getCellMatrix();
|
|
@@ -4326,25 +4459,25 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4326
4459
|
return this._arrayFormulaRange;
|
|
4327
4460
|
}
|
|
4328
4461
|
setArrayFormulaRange(value) {
|
|
4329
|
-
this._arrayFormulaRange = value;
|
|
4462
|
+
this._arrayFormulaRange = copyUnitData(value);
|
|
4330
4463
|
}
|
|
4331
4464
|
getArrayFormulaCellData() {
|
|
4332
4465
|
return this._arrayFormulaCellData;
|
|
4333
4466
|
}
|
|
4334
4467
|
setArrayFormulaCellData(value) {
|
|
4335
|
-
this._arrayFormulaCellData = value;
|
|
4468
|
+
this._arrayFormulaCellData = copyUnitData(value);
|
|
4336
4469
|
}
|
|
4337
4470
|
getUnitImageFormulaData() {
|
|
4338
4471
|
return this._unitImageFormulaData;
|
|
4339
4472
|
}
|
|
4340
4473
|
setUnitImageFormulaData(value) {
|
|
4341
|
-
this._unitImageFormulaData = value;
|
|
4474
|
+
this._unitImageFormulaData = copyUnitData(value);
|
|
4342
4475
|
}
|
|
4343
4476
|
mergeArrayFormulaRange(formulaData) {
|
|
4344
4477
|
Object.keys(formulaData).forEach((unitId) => {
|
|
4345
4478
|
const sheetData = formulaData[unitId];
|
|
4346
4479
|
if (sheetData == null) return true;
|
|
4347
|
-
if (!this._arrayFormulaRange[unitId]) this._arrayFormulaRange[unitId] =
|
|
4480
|
+
if (!this._arrayFormulaRange[unitId]) this._arrayFormulaRange[unitId] = Object.create(null);
|
|
4348
4481
|
Object.keys(sheetData).forEach((sheetId) => {
|
|
4349
4482
|
var _this$_arrayFormulaRa3;
|
|
4350
4483
|
const arrayFormula = new ObjectMatrix(sheetData[sheetId]);
|
|
@@ -4362,7 +4495,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4362
4495
|
const unitId = unitIds[i];
|
|
4363
4496
|
const sheetData = formulaData[unitId];
|
|
4364
4497
|
if (!sheetData) continue;
|
|
4365
|
-
if (!this._unitImageFormulaData[unitId]) this._unitImageFormulaData[unitId] =
|
|
4498
|
+
if (!this._unitImageFormulaData[unitId]) this._unitImageFormulaData[unitId] = Object.create(null);
|
|
4366
4499
|
const sheetIds = Object.keys(sheetData);
|
|
4367
4500
|
for (let j = 0; j < sheetIds.length; j++) {
|
|
4368
4501
|
const sheetId = sheetIds[j];
|
|
@@ -4387,10 +4520,10 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4387
4520
|
}
|
|
4388
4521
|
getCalculateData() {
|
|
4389
4522
|
const unitAllSheet = this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET);
|
|
4390
|
-
const allUnitData =
|
|
4391
|
-
const unitStylesData =
|
|
4392
|
-
const unitSheetNameMap =
|
|
4393
|
-
const unitNameMap =
|
|
4523
|
+
const allUnitData = Object.create(null);
|
|
4524
|
+
const unitStylesData = Object.create(null);
|
|
4525
|
+
const unitSheetNameMap = Object.create(null);
|
|
4526
|
+
const unitNameMap = Object.create(null);
|
|
4394
4527
|
for (const workbook of unitAllSheet) {
|
|
4395
4528
|
const unitId = workbook.getUnitId();
|
|
4396
4529
|
unitNameMap[unitId] = {
|
|
@@ -4398,8 +4531,8 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4398
4531
|
unitType: UniverInstanceType.UNIVER_SHEET
|
|
4399
4532
|
};
|
|
4400
4533
|
const sheets = workbook.getSheets();
|
|
4401
|
-
const sheetData =
|
|
4402
|
-
const sheetNameMap =
|
|
4534
|
+
const sheetData = Object.create(null);
|
|
4535
|
+
const sheetNameMap = Object.create(null);
|
|
4403
4536
|
for (const sheet of sheets) {
|
|
4404
4537
|
const sheetId = sheet.getSheetId();
|
|
4405
4538
|
const sheetConfig = sheet.getConfig();
|
|
@@ -4426,8 +4559,8 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4426
4559
|
name: snapshot.name,
|
|
4427
4560
|
unitType: UniverInstanceType.UNIVER_BASE
|
|
4428
4561
|
};
|
|
4429
|
-
const baseData =
|
|
4430
|
-
const tableNameMap =
|
|
4562
|
+
const baseData = Object.create(null);
|
|
4563
|
+
const tableNameMap = Object.create(null);
|
|
4431
4564
|
const formulaTableNames = createBaseFormulaTableNameMap(snapshot);
|
|
4432
4565
|
for (const table of Object.values(snapshot.tables)) {
|
|
4433
4566
|
var _table$recordOrder;
|
|
@@ -4458,18 +4591,21 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4458
4591
|
*/
|
|
4459
4592
|
getHiddenRowsFiltered() {
|
|
4460
4593
|
const unitAllSheet = this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET);
|
|
4461
|
-
const rowData =
|
|
4594
|
+
const rowData = Object.create(null);
|
|
4462
4595
|
for (const workbook of unitAllSheet) {
|
|
4463
4596
|
const unitId = workbook.getUnitId();
|
|
4464
4597
|
const sheets = workbook.getSheets();
|
|
4465
|
-
rowData[unitId] =
|
|
4598
|
+
rowData[unitId] = Object.create(null);
|
|
4466
4599
|
for (const sheet of sheets) {
|
|
4467
4600
|
const sheetId = sheet.getSheetId();
|
|
4468
|
-
rowData[unitId][sheetId] =
|
|
4601
|
+
rowData[unitId][sheetId] = Object.create(null);
|
|
4469
4602
|
const startRow = 0;
|
|
4470
4603
|
const endRow = sheet.getRowCount() - 1;
|
|
4471
|
-
const sheetRowData =
|
|
4472
|
-
for (let i = startRow; i <= endRow; i++) if (!sheet.getRowVisible(i)) sheetRowData[i] = {
|
|
4604
|
+
const sheetRowData = Object.create(null);
|
|
4605
|
+
for (let i = startRow; i <= endRow; i++) if (!sheet.getRowVisible(i)) sheetRowData[i] = {
|
|
4606
|
+
hd: BooleanNumber.TRUE,
|
|
4607
|
+
...sheet.getRowFiltered(i) ? { filtered: true } : {}
|
|
4608
|
+
};
|
|
4473
4609
|
rowData[unitId][sheetId] = sheetRowData;
|
|
4474
4610
|
}
|
|
4475
4611
|
}
|
|
@@ -4496,7 +4632,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4496
4632
|
}
|
|
4497
4633
|
});
|
|
4498
4634
|
if (affectedFormulaIds.size === 0) return newSheetFormulaDataMatrix.getMatrix();
|
|
4499
|
-
const formulaIdMap =
|
|
4635
|
+
const formulaIdMap = Object.create(null);
|
|
4500
4636
|
const sharedFormulaCellMatrix = new ObjectMatrix();
|
|
4501
4637
|
worksheetCellMatrix === null || worksheetCellMatrix === void 0 || worksheetCellMatrix.forValue((r, c, cell) => {
|
|
4502
4638
|
const formulaId = cell === null || cell === void 0 ? void 0 : cell.si;
|
|
@@ -4513,7 +4649,8 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4513
4649
|
const sheetFormulaDataMatrix = new ObjectMatrix(((_formulaData$unitId = formulaData[unitId]) === null || _formulaData$unitId === void 0 ? void 0 : _formulaData$unitId[sheetId]) ?? {});
|
|
4514
4650
|
cellMatrix.forValue((r, c, cell) => {
|
|
4515
4651
|
var _worksheetCellMatrix$;
|
|
4516
|
-
|
|
4652
|
+
const currentFormulaId = worksheetCellMatrix === null || worksheetCellMatrix === void 0 || (_worksheetCellMatrix$ = worksheetCellMatrix.getValue(r, c)) === null || _worksheetCellMatrix$ === void 0 ? void 0 : _worksheetCellMatrix$.si;
|
|
4653
|
+
if (!isFormulaId(currentFormulaId) && !isFormulaId(cell === null || cell === void 0 ? void 0 : cell.si)) return;
|
|
4517
4654
|
updateFormulaDataByCellValue(sheetFormulaDataMatrix, newSheetFormulaDataMatrix, formulaIdMap, deleteFormulaIdMap, r, c, cell);
|
|
4518
4655
|
});
|
|
4519
4656
|
this._rebindSharedFormulaData(sheetFormulaDataMatrix, newSheetFormulaDataMatrix, formulaIdMap, deleteFormulaIdMap);
|
|
@@ -4661,7 +4798,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4661
4798
|
if (!sheet) continue;
|
|
4662
4799
|
const sheetInstance = workbookInstance.getSheetBySheetId(sheetId);
|
|
4663
4800
|
if (!sheetInstance) continue;
|
|
4664
|
-
const columnRanges =
|
|
4801
|
+
const columnRanges = Object.create(null);
|
|
4665
4802
|
for (const rowStr of Object.keys(sheet)) {
|
|
4666
4803
|
const row = Number(rowStr);
|
|
4667
4804
|
for (const columnStr in sheet[row]) {
|
|
@@ -4719,8 +4856,8 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4719
4856
|
const { range } = deserializeRangeWithSheet(ref);
|
|
4720
4857
|
if (!Number.isFinite(range.startRow) || !Number.isFinite(range.startColumn) || !Number.isFinite(range.endRow) || !Number.isFinite(range.endColumn)) return true;
|
|
4721
4858
|
if (range.startRow === row && range.endRow === row && range.startColumn === column && range.endColumn === column && !isArrayConstantFormula(formula)) return true;
|
|
4722
|
-
if (!this._arrayFormulaRange[unitId]) this._arrayFormulaRange[unitId] =
|
|
4723
|
-
if (!this._arrayFormulaCellData[unitId]) this._arrayFormulaCellData[unitId] =
|
|
4859
|
+
if (!this._arrayFormulaRange[unitId]) this._arrayFormulaRange[unitId] = Object.create(null);
|
|
4860
|
+
if (!this._arrayFormulaCellData[unitId]) this._arrayFormulaCellData[unitId] = Object.create(null);
|
|
4724
4861
|
arrayFormulaRangeMatrix ??= new ObjectMatrix((_this$_arrayFormulaRa7 = this._arrayFormulaRange[unitId]) === null || _this$_arrayFormulaRa7 === void 0 ? void 0 : _this$_arrayFormulaRa7[sheetId]);
|
|
4725
4862
|
arrayFormulaCellDataMatrix ??= new ObjectMatrix((_this$_arrayFormulaCe5 = this._arrayFormulaCellData[unitId]) === null || _this$_arrayFormulaCe5 === void 0 ? void 0 : _this$_arrayFormulaCe5[sheetId]);
|
|
4726
4863
|
if (arrayFormulaRangeMatrix.getValue(row, column) == null) arrayFormulaRangeMatrix.setValue(row, column, range);
|
|
@@ -4736,10 +4873,16 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
4736
4873
|
};
|
|
4737
4874
|
FormulaDataModel = __decorate([__decorateParam(0, IUniverInstanceService), __decorateParam(1, Inject(LexerTreeBuilder))], FormulaDataModel);
|
|
4738
4875
|
function buildSheetFormulaData(formulaData, unitId, sheetId, cellMatrix) {
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4876
|
+
const unitData = Object.assign(Object.create(null), Object.prototype.hasOwnProperty.call(formulaData, unitId) ? formulaData[unitId] : void 0);
|
|
4877
|
+
Object.defineProperty(formulaData, unitId, {
|
|
4878
|
+
value: unitData,
|
|
4879
|
+
writable: true,
|
|
4880
|
+
configurable: true,
|
|
4881
|
+
enumerable: true
|
|
4882
|
+
});
|
|
4883
|
+
if (!unitData[sheetId]) unitData[sheetId] = Object.create(null);
|
|
4884
|
+
const formulaIdMap = Object.create(null);
|
|
4885
|
+
const sheetFormulaDataMatrix = new ObjectMatrix(unitData[sheetId]);
|
|
4743
4886
|
cellMatrix.forValue((r, c, cell) => {
|
|
4744
4887
|
const formulaString = (cell === null || cell === void 0 ? void 0 : cell.f) || "";
|
|
4745
4888
|
const formulaId = (cell === null || cell === void 0 ? void 0 : cell.si) || "";
|
|
@@ -4979,32 +5122,22 @@ function resolveBaseFormulaTable(tableName, currentTable, snapshot, formulaTable
|
|
|
4979
5122
|
|
|
4980
5123
|
//#endregion
|
|
4981
5124
|
//#region src/services/sheet-row-filtered.service.ts
|
|
4982
|
-
/**
|
|
4983
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
4984
|
-
*
|
|
4985
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4986
|
-
* you may not use this file except in compliance with the License.
|
|
4987
|
-
* You may obtain a copy of the License at
|
|
4988
|
-
*
|
|
4989
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4990
|
-
*
|
|
4991
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
4992
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4993
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4994
|
-
* See the License for the specific language governing permissions and
|
|
4995
|
-
* limitations under the License.
|
|
4996
|
-
*/
|
|
4997
5125
|
var SheetRowFilteredService = class extends Disposable {
|
|
4998
5126
|
constructor(..._args) {
|
|
4999
5127
|
super(..._args);
|
|
5000
|
-
_defineProperty(this, "
|
|
5128
|
+
_defineProperty(this, "_getRowFilteredCallbacks", /* @__PURE__ */ new Set());
|
|
5001
5129
|
}
|
|
5002
5130
|
register(callback) {
|
|
5003
|
-
this.
|
|
5131
|
+
this._getRowFilteredCallbacks.add(callback);
|
|
5132
|
+
return toDisposable(() => this._getRowFilteredCallbacks.delete(callback));
|
|
5004
5133
|
}
|
|
5005
5134
|
getRowFiltered(unitId, subUnitId, row) {
|
|
5006
|
-
|
|
5007
|
-
return
|
|
5135
|
+
for (const callback of this._getRowFilteredCallbacks) if (callback(unitId, subUnitId, row)) return true;
|
|
5136
|
+
return false;
|
|
5137
|
+
}
|
|
5138
|
+
dispose() {
|
|
5139
|
+
this._getRowFilteredCallbacks.clear();
|
|
5140
|
+
super.dispose();
|
|
5008
5141
|
}
|
|
5009
5142
|
};
|
|
5010
5143
|
const ISheetRowFilteredService = createIdentifier("univer.formula.sheet-row-filtered.service");
|
|
@@ -5018,47 +5151,49 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
|
|
|
5018
5151
|
this._localeService = _localeService;
|
|
5019
5152
|
this._formulaDataModel = _formulaDataModel;
|
|
5020
5153
|
this._sheetRowFilteredService = _sheetRowFilteredService;
|
|
5021
|
-
_defineProperty(this, "_unitData",
|
|
5022
|
-
_defineProperty(this, "_unitStylesData",
|
|
5023
|
-
_defineProperty(this, "_arrayFormulaCellData",
|
|
5024
|
-
_defineProperty(this, "_arrayFormulaRange",
|
|
5025
|
-
_defineProperty(this, "_formulaData",
|
|
5026
|
-
_defineProperty(this, "_sheetNameMap",
|
|
5027
|
-
_defineProperty(this, "_unitNameMap",
|
|
5028
|
-
_defineProperty(this, "_externalReferences",
|
|
5154
|
+
_defineProperty(this, "_unitData", Object.create(null));
|
|
5155
|
+
_defineProperty(this, "_unitStylesData", Object.create(null));
|
|
5156
|
+
_defineProperty(this, "_arrayFormulaCellData", Object.create(null));
|
|
5157
|
+
_defineProperty(this, "_arrayFormulaRange", Object.create(null));
|
|
5158
|
+
_defineProperty(this, "_formulaData", Object.create(null));
|
|
5159
|
+
_defineProperty(this, "_sheetNameMap", Object.create(null));
|
|
5160
|
+
_defineProperty(this, "_unitNameMap", Object.create(null));
|
|
5161
|
+
_defineProperty(this, "_externalReferences", Object.create(null));
|
|
5162
|
+
_defineProperty(this, "_calculationRowData", Object.create(null));
|
|
5029
5163
|
_defineProperty(this, "_calculationGeneration", 0);
|
|
5030
5164
|
_defineProperty(this, "_forceCalculate", false);
|
|
5031
|
-
_defineProperty(this, "_clearDependencyTreeCache",
|
|
5165
|
+
_defineProperty(this, "_clearDependencyTreeCache", Object.create(null));
|
|
5032
5166
|
_defineProperty(this, "_dirtyRanges", []);
|
|
5033
|
-
_defineProperty(this, "_dirtyNameMap",
|
|
5034
|
-
_defineProperty(this, "_dirtyDefinedNameMap",
|
|
5035
|
-
_defineProperty(this, "_dirtySuperTableMap",
|
|
5036
|
-
_defineProperty(this, "_dirtyUnitFeatureMap",
|
|
5037
|
-
_defineProperty(this, "_dirtyUnitOtherFormulaMap",
|
|
5167
|
+
_defineProperty(this, "_dirtyNameMap", Object.create(null));
|
|
5168
|
+
_defineProperty(this, "_dirtyDefinedNameMap", Object.create(null));
|
|
5169
|
+
_defineProperty(this, "_dirtySuperTableMap", Object.create(null));
|
|
5170
|
+
_defineProperty(this, "_dirtyUnitFeatureMap", Object.create(null));
|
|
5171
|
+
_defineProperty(this, "_dirtyUnitOtherFormulaMap", Object.create(null));
|
|
5038
5172
|
_defineProperty(this, "_excludedCell", void 0);
|
|
5039
|
-
_defineProperty(this, "_sheetIdToNameMap",
|
|
5173
|
+
_defineProperty(this, "_sheetIdToNameMap", Object.create(null));
|
|
5040
5174
|
_defineProperty(this, "_executeUnitId", "");
|
|
5041
5175
|
_defineProperty(this, "_executeSubUnitId", "");
|
|
5042
5176
|
}
|
|
5043
5177
|
dispose() {
|
|
5044
5178
|
super.dispose();
|
|
5045
|
-
this._unitData =
|
|
5046
|
-
this._unitStylesData =
|
|
5047
|
-
this._arrayFormulaCellData =
|
|
5048
|
-
this._arrayFormulaRange =
|
|
5049
|
-
this._formulaData =
|
|
5050
|
-
this._sheetNameMap =
|
|
5051
|
-
this._unitNameMap =
|
|
5052
|
-
this._externalReferences =
|
|
5053
|
-
this.
|
|
5179
|
+
this._unitData = Object.create(null);
|
|
5180
|
+
this._unitStylesData = Object.create(null);
|
|
5181
|
+
this._arrayFormulaCellData = Object.create(null);
|
|
5182
|
+
this._arrayFormulaRange = Object.create(null);
|
|
5183
|
+
this._formulaData = Object.create(null);
|
|
5184
|
+
this._sheetNameMap = Object.create(null);
|
|
5185
|
+
this._unitNameMap = Object.create(null);
|
|
5186
|
+
this._externalReferences = Object.create(null);
|
|
5187
|
+
this._calculationRowData = Object.create(null);
|
|
5188
|
+
this._clearDependencyTreeCache = Object.create(null);
|
|
5054
5189
|
this._dirtyRanges = [];
|
|
5055
|
-
this._dirtyNameMap =
|
|
5056
|
-
this._dirtyDefinedNameMap =
|
|
5057
|
-
this._dirtySuperTableMap =
|
|
5058
|
-
this._dirtyUnitFeatureMap =
|
|
5059
|
-
this._dirtyUnitOtherFormulaMap =
|
|
5060
|
-
this._excludedCell =
|
|
5061
|
-
this._sheetIdToNameMap =
|
|
5190
|
+
this._dirtyNameMap = Object.create(null);
|
|
5191
|
+
this._dirtyDefinedNameMap = Object.create(null);
|
|
5192
|
+
this._dirtySuperTableMap = Object.create(null);
|
|
5193
|
+
this._dirtyUnitFeatureMap = Object.create(null);
|
|
5194
|
+
this._dirtyUnitOtherFormulaMap = Object.create(null);
|
|
5195
|
+
this._excludedCell = Object.create(null);
|
|
5196
|
+
this._sheetIdToNameMap = Object.create(null);
|
|
5062
5197
|
}
|
|
5063
5198
|
getExecuteUnitId() {
|
|
5064
5199
|
return this._executeUnitId;
|
|
@@ -5128,7 +5263,7 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
|
|
|
5128
5263
|
return this._sheetIdToNameMap[unitId][sheetId] || "";
|
|
5129
5264
|
}
|
|
5130
5265
|
setSheetNameMap(sheetIdToNameMap) {
|
|
5131
|
-
this._sheetIdToNameMap = sheetIdToNameMap;
|
|
5266
|
+
this._sheetIdToNameMap = copyUnitData(sheetIdToNameMap);
|
|
5132
5267
|
}
|
|
5133
5268
|
getClearDependencyTreeCache() {
|
|
5134
5269
|
return this._clearDependencyTreeCache;
|
|
@@ -5173,21 +5308,25 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
|
|
|
5173
5308
|
}
|
|
5174
5309
|
getFilteredOutRows(unitId, sheetId, startRow, endRow) {
|
|
5175
5310
|
const filteredOutRows = [];
|
|
5176
|
-
for (let r = startRow; r <= endRow; r++)
|
|
5311
|
+
for (let r = startRow; r <= endRow; r++) {
|
|
5312
|
+
var _this$_calculationRow;
|
|
5313
|
+
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);
|
|
5314
|
+
}
|
|
5177
5315
|
return filteredOutRows;
|
|
5178
5316
|
}
|
|
5179
5317
|
load(config) {
|
|
5180
5318
|
this._calculationGeneration++;
|
|
5319
|
+
this._calculationRowData = Object.create(null);
|
|
5181
5320
|
if (config.allUnitData && config.unitSheetNameMap && config.unitStylesData) {
|
|
5182
|
-
this._unitData = config.allUnitData;
|
|
5321
|
+
this._unitData = copyUnitData(config.allUnitData);
|
|
5183
5322
|
this._unitStylesData = config.unitStylesData;
|
|
5184
|
-
this._sheetNameMap = config.unitSheetNameMap;
|
|
5323
|
+
this._sheetNameMap = copyUnitData(config.unitSheetNameMap);
|
|
5185
5324
|
this._unitNameMap = config.unitNameMap || {};
|
|
5186
5325
|
} else {
|
|
5187
5326
|
const { allUnitData, unitNameMap, unitSheetNameMap, unitStylesData } = this._loadSheetData();
|
|
5188
|
-
this._unitData = allUnitData;
|
|
5327
|
+
this._unitData = copyUnitData(allUnitData);
|
|
5189
5328
|
this._unitStylesData = unitStylesData;
|
|
5190
|
-
this._sheetNameMap = unitSheetNameMap;
|
|
5329
|
+
this._sheetNameMap = copyUnitData(unitSheetNameMap);
|
|
5191
5330
|
this._unitNameMap = unitNameMap;
|
|
5192
5331
|
}
|
|
5193
5332
|
if (config.rowData) this._applyUnitRowData(config.rowData);
|
|
@@ -5208,9 +5347,9 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
|
|
|
5208
5347
|
}
|
|
5209
5348
|
loadDataLite(rowData) {
|
|
5210
5349
|
const { allUnitData, unitNameMap, unitSheetNameMap, unitStylesData } = this._loadSheetData();
|
|
5211
|
-
this._unitData = allUnitData;
|
|
5350
|
+
this._unitData = copyUnitData(allUnitData);
|
|
5212
5351
|
this._unitStylesData = unitStylesData;
|
|
5213
|
-
this._sheetNameMap = unitSheetNameMap;
|
|
5352
|
+
this._sheetNameMap = copyUnitData(unitSheetNameMap);
|
|
5214
5353
|
this._unitNameMap = unitNameMap;
|
|
5215
5354
|
this._formulaData = this._formulaDataModel.getFormulaData();
|
|
5216
5355
|
this._arrayFormulaCellData = convertUnitDataToRuntime(this._formulaDataModel.getArrayFormulaCellData());
|
|
@@ -5236,16 +5375,16 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
|
|
|
5236
5375
|
/**
|
|
5237
5376
|
* Mark dirty for expansion of array formulas, need to clear the worksheet's dirty flag.
|
|
5238
5377
|
*/
|
|
5239
|
-
this._dirtyNameMap =
|
|
5378
|
+
this._dirtyNameMap = Object.create(null);
|
|
5240
5379
|
}
|
|
5241
5380
|
registerUnitData(unitData) {
|
|
5242
|
-
this._unitData = unitData;
|
|
5381
|
+
this._unitData = copyUnitData(unitData);
|
|
5243
5382
|
}
|
|
5244
5383
|
registerFormulaData(formulaData) {
|
|
5245
5384
|
this._formulaData = formulaData;
|
|
5246
5385
|
}
|
|
5247
5386
|
registerSheetNameMap(sheetNameMap) {
|
|
5248
|
-
this._sheetNameMap = sheetNameMap;
|
|
5387
|
+
this._sheetNameMap = copyUnitData(sheetNameMap);
|
|
5249
5388
|
}
|
|
5250
5389
|
registerUnitNameMap(unitNameMap) {
|
|
5251
5390
|
this._unitNameMap = unitNameMap;
|
|
@@ -5253,14 +5392,14 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
|
|
|
5253
5392
|
_mergeNameMap(unitSheetNameMap, dirtyNameMap) {
|
|
5254
5393
|
Object.keys(dirtyNameMap).forEach((unitId) => {
|
|
5255
5394
|
if (dirtyNameMap[unitId]) Object.keys(dirtyNameMap[unitId]).forEach((sheetId) => {
|
|
5256
|
-
if (unitSheetNameMap[unitId] == null) unitSheetNameMap[unitId] =
|
|
5395
|
+
if (unitSheetNameMap[unitId] == null) unitSheetNameMap[unitId] = Object.create(null);
|
|
5257
5396
|
unitSheetNameMap[unitId][dirtyNameMap[unitId][sheetId]] = sheetId;
|
|
5258
5397
|
});
|
|
5259
5398
|
});
|
|
5260
|
-
this._sheetIdToNameMap =
|
|
5399
|
+
this._sheetIdToNameMap = Object.create(null);
|
|
5261
5400
|
Object.keys(unitSheetNameMap).forEach((unitId) => {
|
|
5262
5401
|
Object.keys(unitSheetNameMap[unitId]).forEach((sheetName) => {
|
|
5263
|
-
if (this._sheetIdToNameMap[unitId] == null) this._sheetIdToNameMap[unitId] =
|
|
5402
|
+
if (this._sheetIdToNameMap[unitId] == null) this._sheetIdToNameMap[unitId] = Object.create(null);
|
|
5264
5403
|
this._sheetIdToNameMap[unitId][unitSheetNameMap[unitId][sheetName]] = sheetName;
|
|
5265
5404
|
});
|
|
5266
5405
|
});
|
|
@@ -5279,11 +5418,12 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
|
|
|
5279
5418
|
* @param rowData
|
|
5280
5419
|
*/
|
|
5281
5420
|
_applyUnitRowData(rowData) {
|
|
5282
|
-
|
|
5421
|
+
this._calculationRowData = rowData;
|
|
5422
|
+
for (const unitId of Object.keys(rowData)) {
|
|
5283
5423
|
if (rowData[unitId] == null) continue;
|
|
5284
|
-
for (const sheetId
|
|
5424
|
+
for (const sheetId of Object.keys(rowData[unitId])) {
|
|
5285
5425
|
if (rowData[unitId][sheetId] == null) continue;
|
|
5286
|
-
if (this._unitData[unitId] == null) this._unitData[unitId] =
|
|
5426
|
+
if (this._unitData[unitId] == null) this._unitData[unitId] = Object.create(null);
|
|
5287
5427
|
if (this._unitData[unitId][sheetId] == null) this._unitData[unitId][sheetId] = {
|
|
5288
5428
|
cellData: new ObjectMatrix({}),
|
|
5289
5429
|
rowCount: 0,
|
|
@@ -5567,9 +5707,10 @@ var BaseValueObject = class extends ObjectClassType {
|
|
|
5567
5707
|
}
|
|
5568
5708
|
concatenate(value, concatenateType = 0) {
|
|
5569
5709
|
let currentValue = formatValueForFormulaText(this.getValue());
|
|
5570
|
-
if (typeof value === "string")
|
|
5571
|
-
|
|
5572
|
-
|
|
5710
|
+
if (typeof value === "string") {
|
|
5711
|
+
if (concatenateType === 0) currentValue = value + currentValue;
|
|
5712
|
+
else currentValue += value;
|
|
5713
|
+
} else if (typeof value === "number") {
|
|
5573
5714
|
const numberString = formatNumberForFormulaText(value);
|
|
5574
5715
|
if (concatenateType === 0) currentValue = numberString + currentValue;
|
|
5575
5716
|
else currentValue += numberString;
|
|
@@ -6163,68 +6304,6 @@ function getRuntimeFeatureCell(row, column, sheetId, unitId, runtimeFeatureCellD
|
|
|
6163
6304
|
}
|
|
6164
6305
|
}
|
|
6165
6306
|
|
|
6166
|
-
//#endregion
|
|
6167
|
-
//#region src/engine/utils/compare.ts
|
|
6168
|
-
function getCompare() {
|
|
6169
|
-
if (Intl && Intl.Collator) return new Intl.Collator(void 0, { numeric: false }).compare;
|
|
6170
|
-
return (a, b) => {
|
|
6171
|
-
return a.localeCompare(b);
|
|
6172
|
-
};
|
|
6173
|
-
}
|
|
6174
|
-
function isWildcard(str) {
|
|
6175
|
-
return str.indexOf("*") > -1 || str.indexOf("?") > -1;
|
|
6176
|
-
}
|
|
6177
|
-
function isMatchWildcard(currentValue, value) {
|
|
6178
|
-
const pattern = escapeRegExpForWildcard(value).replace(/~?[*?]/g, (match) => {
|
|
6179
|
-
if (match.startsWith("~")) return `\\${match.substring(1)}`;
|
|
6180
|
-
if (match === "*") return ".*";
|
|
6181
|
-
if (match === "?") return ".";
|
|
6182
|
-
return match;
|
|
6183
|
-
});
|
|
6184
|
-
return new RegExp(`^${pattern}$`).test(currentValue);
|
|
6185
|
-
}
|
|
6186
|
-
function replaceWildcard(value) {
|
|
6187
|
-
return value.replace(/~?[*?]/g, (match) => {
|
|
6188
|
-
if (match.startsWith("~")) return match.substring(1);
|
|
6189
|
-
return " ";
|
|
6190
|
-
});
|
|
6191
|
-
}
|
|
6192
|
-
function compareWithWildcard(currentValue, value, operator) {
|
|
6193
|
-
let result = false;
|
|
6194
|
-
switch (operator) {
|
|
6195
|
-
case "=":
|
|
6196
|
-
result = isMatchWildcard(currentValue, value);
|
|
6197
|
-
break;
|
|
6198
|
-
case "<>":
|
|
6199
|
-
result = !isMatchWildcard(currentValue, value);
|
|
6200
|
-
break;
|
|
6201
|
-
case ">":
|
|
6202
|
-
case ">=":
|
|
6203
|
-
result = isMatchWildcard(currentValue, value) || currentValue > replaceWildcard(value);
|
|
6204
|
-
break;
|
|
6205
|
-
case "<":
|
|
6206
|
-
case "<=":
|
|
6207
|
-
result = currentValue < replaceWildcard(value);
|
|
6208
|
-
break;
|
|
6209
|
-
default: break;
|
|
6210
|
-
}
|
|
6211
|
-
return result;
|
|
6212
|
-
}
|
|
6213
|
-
function escapeRegExpForWildcard(str) {
|
|
6214
|
-
return str.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
6215
|
-
}
|
|
6216
|
-
function getMatchModeValue(matchModeValue) {
|
|
6217
|
-
switch (matchModeValue) {
|
|
6218
|
-
case 1: return 2;
|
|
6219
|
-
case 0: return 0;
|
|
6220
|
-
case -1: return 1;
|
|
6221
|
-
default: return 0;
|
|
6222
|
-
}
|
|
6223
|
-
}
|
|
6224
|
-
function getSearchModeValue(searchModeValue) {
|
|
6225
|
-
return searchModeValue === -2 ? 1 : 0;
|
|
6226
|
-
}
|
|
6227
|
-
|
|
6228
6307
|
//#endregion
|
|
6229
6308
|
//#region src/engine/utils/numfmt-kit.ts
|
|
6230
6309
|
/**
|
|
@@ -6347,9 +6426,7 @@ function reverseCompareOperator(operator) {
|
|
|
6347
6426
|
case "<=":
|
|
6348
6427
|
result = ">=";
|
|
6349
6428
|
break;
|
|
6350
|
-
case "<>":
|
|
6351
|
-
result = "<>";
|
|
6352
|
-
break;
|
|
6429
|
+
case "<>": result = "<>";
|
|
6353
6430
|
}
|
|
6354
6431
|
return result;
|
|
6355
6432
|
}
|
|
@@ -6567,6 +6644,39 @@ function getFractionalPart(num) {
|
|
|
6567
6644
|
* See the License for the specific language governing permissions and
|
|
6568
6645
|
* limitations under the License.
|
|
6569
6646
|
*/
|
|
6647
|
+
function parseCompactEnglishMonthYear(rawValue, dateSystem) {
|
|
6648
|
+
const match = rawValue.trim().match(/^([A-Za-z]{3,9})(\d{4})$/);
|
|
6649
|
+
if (!match) return null;
|
|
6650
|
+
const month = {
|
|
6651
|
+
jan: 0,
|
|
6652
|
+
january: 0,
|
|
6653
|
+
feb: 1,
|
|
6654
|
+
february: 1,
|
|
6655
|
+
mar: 2,
|
|
6656
|
+
march: 2,
|
|
6657
|
+
apr: 3,
|
|
6658
|
+
april: 3,
|
|
6659
|
+
may: 4,
|
|
6660
|
+
jun: 5,
|
|
6661
|
+
june: 5,
|
|
6662
|
+
jul: 6,
|
|
6663
|
+
july: 6,
|
|
6664
|
+
aug: 7,
|
|
6665
|
+
august: 7,
|
|
6666
|
+
sep: 8,
|
|
6667
|
+
sept: 8,
|
|
6668
|
+
september: 8,
|
|
6669
|
+
oct: 9,
|
|
6670
|
+
october: 9,
|
|
6671
|
+
nov: 10,
|
|
6672
|
+
november: 10,
|
|
6673
|
+
dec: 11,
|
|
6674
|
+
december: 11
|
|
6675
|
+
}[match[1].toLowerCase()];
|
|
6676
|
+
const year = Number(match[2]);
|
|
6677
|
+
if (month === void 0 || year < 1900 || year > 9999) return null;
|
|
6678
|
+
return excelDateSerial(new Date(Date.UTC(year, month, 1)), dateSystem);
|
|
6679
|
+
}
|
|
6570
6680
|
var NullValueObject = class NullValueObject extends BaseValueObject {
|
|
6571
6681
|
static create() {
|
|
6572
6682
|
this._instance = this._instance || new NullValueObject();
|
|
@@ -7285,9 +7395,7 @@ var NumberValueObject = class NumberValueObject extends BaseValueObject {
|
|
|
7285
7395
|
case "<=":
|
|
7286
7396
|
result = currentValue <= value;
|
|
7287
7397
|
break;
|
|
7288
|
-
case "<>":
|
|
7289
|
-
result = currentValue !== value;
|
|
7290
|
-
break;
|
|
7398
|
+
case "<>": result = currentValue !== value;
|
|
7291
7399
|
}
|
|
7292
7400
|
return result;
|
|
7293
7401
|
}
|
|
@@ -7372,12 +7480,12 @@ var StringValueObject = class StringValueObject extends BaseValueObject {
|
|
|
7372
7480
|
let currentValue = this.getValue();
|
|
7373
7481
|
let result = false;
|
|
7374
7482
|
if (typeof value === "string") {
|
|
7483
|
+
if (isWildcard(value)) return this._checkWildcard(value, operator, isCaseSensitive);
|
|
7375
7484
|
let _value = value;
|
|
7376
7485
|
if (!isCaseSensitive) {
|
|
7377
|
-
currentValue = currentValue
|
|
7378
|
-
_value = _value
|
|
7486
|
+
currentValue = normalizeTextForComparison(currentValue);
|
|
7487
|
+
_value = normalizeTextForComparison(_value);
|
|
7379
7488
|
}
|
|
7380
|
-
if (isWildcard(_value)) return this._checkWildcard(_value, operator);
|
|
7381
7489
|
result = this._compareString(currentValue, _value, operator);
|
|
7382
7490
|
} else if (typeof value === "number") result = this._compareNumber(operator);
|
|
7383
7491
|
else if (typeof value === "boolean") result = this._compareBoolean(operator);
|
|
@@ -7419,13 +7527,15 @@ var StringValueObject = class StringValueObject extends BaseValueObject {
|
|
|
7419
7527
|
if (rawValue.trim() === "") return ErrorValueObject.create("#VALUE!");
|
|
7420
7528
|
const parseData = getNumfmtParseValueFilter(rawValue, { dateSystem: this.getDateSystem() });
|
|
7421
7529
|
if (parseData && parseData.z) return createNumberValueObjectByRawValue(parseData.v, parseData.z).withDateSystem(this.getDateSystem());
|
|
7530
|
+
const compactMonthYear = parseCompactEnglishMonthYear(rawValue, this.getDateSystem());
|
|
7531
|
+
if (compactMonthYear !== null) return createNumberValueObjectByRawValue(compactMonthYear).withDateSystem(this.getDateSystem());
|
|
7422
7532
|
return createNumberValueObjectByRawValue(rawValue).withDateSystem(this.getDateSystem());
|
|
7423
7533
|
}
|
|
7424
7534
|
convertToBooleanObjectValue() {
|
|
7425
7535
|
return BooleanValueObject.create(true);
|
|
7426
7536
|
}
|
|
7427
|
-
_checkWildcard(value, operator) {
|
|
7428
|
-
const result = compareWithWildcard(this.getValue()
|
|
7537
|
+
_checkWildcard(value, operator, isCaseSensitive) {
|
|
7538
|
+
const result = compareWithWildcard(this.getValue(), value, operator, isCaseSensitive);
|
|
7429
7539
|
return BooleanValueObject.create(result);
|
|
7430
7540
|
}
|
|
7431
7541
|
};
|
|
@@ -8438,51 +8548,50 @@ var ArrayValueObject = class ArrayValueObject extends BaseValueObject {
|
|
|
8438
8548
|
__batchOperatorRowValue(valueObject, column, result, batchOperatorType, r, unitId, sheetId, startRow, startColumn, operator, isCaseSensitive) {
|
|
8439
8549
|
const currentValue = this.getValueOrDefault(r, column);
|
|
8440
8550
|
if (result[r] == null) result[r] = [];
|
|
8441
|
-
if (currentValue && valueObject)
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8450
|
-
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
|
|
8460
|
-
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8482
|
-
result[r][column] = currentValue.ceil(valueObject);
|
|
8483
|
-
|
|
8484
|
-
}
|
|
8485
|
-
else result[r][column] = ErrorValueObject.create("#N/A");
|
|
8551
|
+
if (currentValue && valueObject) {
|
|
8552
|
+
if (currentValue.isError()) result[r][column] = currentValue;
|
|
8553
|
+
else if (valueObject.isError()) result[r][column] = valueObject;
|
|
8554
|
+
else switch (batchOperatorType) {
|
|
8555
|
+
case 1:
|
|
8556
|
+
result[r][column] = currentValue.plus(valueObject);
|
|
8557
|
+
break;
|
|
8558
|
+
case 0:
|
|
8559
|
+
result[r][column] = currentValue.minus(valueObject);
|
|
8560
|
+
break;
|
|
8561
|
+
case 2:
|
|
8562
|
+
result[r][column] = currentValue.multiply(valueObject);
|
|
8563
|
+
break;
|
|
8564
|
+
case 3:
|
|
8565
|
+
result[r][column] = currentValue.divided(valueObject);
|
|
8566
|
+
break;
|
|
8567
|
+
case 4:
|
|
8568
|
+
result[r][column] = currentValue.mod(valueObject);
|
|
8569
|
+
break;
|
|
8570
|
+
case 5:
|
|
8571
|
+
if (!operator) result[r][column] = ErrorValueObject.create("#VALUE!");
|
|
8572
|
+
else result[r][column] = currentValue.compare(valueObject, operator, isCaseSensitive);
|
|
8573
|
+
break;
|
|
8574
|
+
case 6:
|
|
8575
|
+
result[r][column] = currentValue.concatenateFront(valueObject);
|
|
8576
|
+
break;
|
|
8577
|
+
case 7:
|
|
8578
|
+
result[r][column] = currentValue.concatenateBack(valueObject);
|
|
8579
|
+
break;
|
|
8580
|
+
case 8:
|
|
8581
|
+
result[r][column] = currentValue.pow(valueObject);
|
|
8582
|
+
break;
|
|
8583
|
+
case 9:
|
|
8584
|
+
result[r][column] = currentValue.round(valueObject);
|
|
8585
|
+
break;
|
|
8586
|
+
case 10:
|
|
8587
|
+
result[r][column] = currentValue.floor(valueObject);
|
|
8588
|
+
break;
|
|
8589
|
+
case 12:
|
|
8590
|
+
result[r][column] = currentValue.atan2(valueObject);
|
|
8591
|
+
break;
|
|
8592
|
+
case 11: result[r][column] = currentValue.ceil(valueObject);
|
|
8593
|
+
}
|
|
8594
|
+
} else result[r][column] = ErrorValueObject.create("#N/A");
|
|
8486
8595
|
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);
|
|
8487
8596
|
}
|
|
8488
8597
|
_batchOperatorArray(valueObject, batchOperatorType, operator, isCaseSensitive) {
|
|
@@ -8506,51 +8615,50 @@ var ArrayValueObject = class ArrayValueObject extends BaseValueObject {
|
|
|
8506
8615
|
else if (opCalculateType === 1) opValue = valueObject.getValueOrDefault(0, c);
|
|
8507
8616
|
else if (opCalculateType === 2) opValue = valueObject.getValueOrDefault(r, 0);
|
|
8508
8617
|
else opValue = valueObject.getValueOrDefault(r, c);
|
|
8509
|
-
if (currentValue && opValue)
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
rowList[c] = currentValue.ceil(opValue);
|
|
8551
|
-
|
|
8552
|
-
}
|
|
8553
|
-
else rowList[c] = ErrorValueObject.create("#N/A");
|
|
8618
|
+
if (currentValue && opValue) {
|
|
8619
|
+
if (currentValue.isError()) rowList[c] = currentValue;
|
|
8620
|
+
else if (opValue.isError()) rowList[c] = opValue;
|
|
8621
|
+
else switch (batchOperatorType) {
|
|
8622
|
+
case 1:
|
|
8623
|
+
rowList[c] = currentValue.plus(opValue);
|
|
8624
|
+
break;
|
|
8625
|
+
case 0:
|
|
8626
|
+
rowList[c] = currentValue.minus(opValue);
|
|
8627
|
+
break;
|
|
8628
|
+
case 2:
|
|
8629
|
+
rowList[c] = currentValue.multiply(opValue);
|
|
8630
|
+
break;
|
|
8631
|
+
case 3:
|
|
8632
|
+
rowList[c] = currentValue.divided(opValue);
|
|
8633
|
+
break;
|
|
8634
|
+
case 4:
|
|
8635
|
+
rowList[c] = currentValue.mod(opValue);
|
|
8636
|
+
break;
|
|
8637
|
+
case 5:
|
|
8638
|
+
if (!operator) rowList[c] = ErrorValueObject.create("#VALUE!");
|
|
8639
|
+
else rowList[c] = currentValue.compare(opValue, operator, isCaseSensitive);
|
|
8640
|
+
break;
|
|
8641
|
+
case 6:
|
|
8642
|
+
rowList[c] = currentValue.concatenateFront(opValue);
|
|
8643
|
+
break;
|
|
8644
|
+
case 7:
|
|
8645
|
+
rowList[c] = currentValue.concatenateBack(opValue);
|
|
8646
|
+
break;
|
|
8647
|
+
case 8:
|
|
8648
|
+
rowList[c] = currentValue.pow(opValue);
|
|
8649
|
+
break;
|
|
8650
|
+
case 9:
|
|
8651
|
+
rowList[c] = currentValue.round(opValue);
|
|
8652
|
+
break;
|
|
8653
|
+
case 12:
|
|
8654
|
+
rowList[c] = currentValue.atan2(opValue);
|
|
8655
|
+
break;
|
|
8656
|
+
case 10:
|
|
8657
|
+
rowList[c] = currentValue.floor(opValue);
|
|
8658
|
+
break;
|
|
8659
|
+
case 11: rowList[c] = currentValue.ceil(opValue);
|
|
8660
|
+
}
|
|
8661
|
+
} else rowList[c] = ErrorValueObject.create("#N/A");
|
|
8554
8662
|
}
|
|
8555
8663
|
result.push(rowList);
|
|
8556
8664
|
}
|
|
@@ -8934,7 +9042,7 @@ var BaseReferenceObject = class extends ObjectClassType {
|
|
|
8934
9042
|
getCellValueObject(cell) {
|
|
8935
9043
|
const value = getCellValue(cell);
|
|
8936
9044
|
const cellValueType = Number(cell.t);
|
|
8937
|
-
if (ERROR_TYPE_SET.has(value)) return ErrorValueObject.create(value);
|
|
9045
|
+
if (cellValueType !== CellValueType.FORCE_STRING && ERROR_TYPE_SET.has(value)) return ErrorValueObject.create(value);
|
|
8938
9046
|
if (cellValueType === CellValueType.NUMBER) {
|
|
8939
9047
|
const pattern = this._getPatternByCell(cell);
|
|
8940
9048
|
if (isTextFormat(pattern)) return StringValueObject.create(value.toString()).withDateSystem(this._dateSystem);
|
|
@@ -9377,6 +9485,14 @@ function createNewArray(result, rowCount, columnCount, unitId = "", sheetId = ""
|
|
|
9377
9485
|
|
|
9378
9486
|
//#endregion
|
|
9379
9487
|
//#region src/engine/utils/object-compare.ts
|
|
9488
|
+
function createCriteriaValueObject(content, dateSystem) {
|
|
9489
|
+
if (isRealNum(content)) {
|
|
9490
|
+
const number = Number(content);
|
|
9491
|
+
if (!/^ *[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)? *$/i.test(content) || !Number.isFinite(number)) return StringValueObject.create(content);
|
|
9492
|
+
return NumberValueObject.create(Math.abs(number) < 2 ** -1022 ? 0 : number);
|
|
9493
|
+
}
|
|
9494
|
+
return ValueObjectFactory.create(content, false, dateSystem);
|
|
9495
|
+
}
|
|
9380
9496
|
function findCompareToken(str, dateSystem) {
|
|
9381
9497
|
const comparisonTokens = [
|
|
9382
9498
|
"=",
|
|
@@ -9386,11 +9502,14 @@ function findCompareToken(str, dateSystem) {
|
|
|
9386
9502
|
"<=",
|
|
9387
9503
|
"<"
|
|
9388
9504
|
];
|
|
9505
|
+
let operator = "=";
|
|
9506
|
+
let content = str;
|
|
9389
9507
|
for (const token of comparisonTokens) if (str.startsWith(token)) {
|
|
9390
|
-
|
|
9391
|
-
|
|
9508
|
+
operator = token;
|
|
9509
|
+
content = str.substring(token.length);
|
|
9510
|
+
break;
|
|
9392
9511
|
}
|
|
9393
|
-
return [
|
|
9512
|
+
return [operator, createCriteriaValueObject(content, dateSystem)];
|
|
9394
9513
|
}
|
|
9395
9514
|
/**
|
|
9396
9515
|
* When it contains both comparison characters and wildcard characters
|
|
@@ -9399,11 +9518,13 @@ function findCompareToken(str, dateSystem) {
|
|
|
9399
9518
|
* 3. <apple*: normal value, <=apple: obtains the same effect as <apple*
|
|
9400
9519
|
*/
|
|
9401
9520
|
function valueObjectCompare(range, criteria, operator, isCaseSensitive) {
|
|
9402
|
-
if (!operator)
|
|
9403
|
-
|
|
9404
|
-
|
|
9405
|
-
|
|
9406
|
-
|
|
9521
|
+
if (!operator) {
|
|
9522
|
+
if (criteria.isString()) {
|
|
9523
|
+
const [token, criteriaStringObject] = findCompareToken(`${criteria.getValue()}`, criteria.getDateSystem());
|
|
9524
|
+
operator = token;
|
|
9525
|
+
criteria = criteriaStringObject;
|
|
9526
|
+
} else operator = "=";
|
|
9527
|
+
}
|
|
9407
9528
|
return range.compare(criteria, operator, isCaseSensitive);
|
|
9408
9529
|
}
|
|
9409
9530
|
/**
|
|
@@ -9488,7 +9609,7 @@ function objectValueToCellValue(objectValue) {
|
|
|
9488
9609
|
};
|
|
9489
9610
|
if (vo.isString()) return {
|
|
9490
9611
|
v,
|
|
9491
|
-
t: CellValueType.STRING,
|
|
9612
|
+
t: ERROR_TYPE_SET.has(v) ? CellValueType.FORCE_STRING : CellValueType.STRING,
|
|
9492
9613
|
...cellWithStyle,
|
|
9493
9614
|
...cellWithCustomData
|
|
9494
9615
|
};
|
|
@@ -9514,13 +9635,15 @@ function calculateMaxDimensions(variants) {
|
|
|
9514
9635
|
let maxRowLength = 0;
|
|
9515
9636
|
let maxColumnLength = 0;
|
|
9516
9637
|
variants.forEach((variant, i) => {
|
|
9517
|
-
if (i % 2 === 1)
|
|
9518
|
-
|
|
9519
|
-
|
|
9520
|
-
|
|
9521
|
-
|
|
9522
|
-
|
|
9523
|
-
|
|
9638
|
+
if (i % 2 === 1) {
|
|
9639
|
+
if (variant.isArray()) {
|
|
9640
|
+
const arrayValue = variant;
|
|
9641
|
+
maxRowLength = Math.max(maxRowLength, arrayValue.getRowCount());
|
|
9642
|
+
maxColumnLength = Math.max(maxColumnLength, arrayValue.getColumnCount());
|
|
9643
|
+
} else {
|
|
9644
|
+
maxRowLength = Math.max(maxRowLength, 1);
|
|
9645
|
+
maxColumnLength = Math.max(maxColumnLength, 1);
|
|
9646
|
+
}
|
|
9524
9647
|
}
|
|
9525
9648
|
});
|
|
9526
9649
|
return {
|
|
@@ -9697,17 +9820,18 @@ function filterSameValueObjectResult(array, range, criteria) {
|
|
|
9697
9820
|
if (criteriaObject.isString() && criteriaObject.getValue() !== "" && (operator === "<" || operator === "<=") && (rangeValueObject == null || rangeValueObject.isNull())) return BooleanValueObject.create(false);
|
|
9698
9821
|
if (criteriaObject.isString() && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString()) && (operator === "<" || operator === "<=") && isSameLowerBoundBucket(rangeValueObject.getValue(), criteriaObject.getValue())) return BooleanValueObject.create(false);
|
|
9699
9822
|
if ((rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isNumber()) && criteriaObject.isString()) {
|
|
9700
|
-
const criteriaNumber = criteriaObject.
|
|
9823
|
+
const criteriaNumber = createCriteriaValueObject(`${criteriaObject.getValue()}`, criteriaObject.getDateSystem());
|
|
9701
9824
|
if (criteriaNumber.isNumber()) return rangeValueObject.compare(criteriaNumber, operator);
|
|
9702
9825
|
}
|
|
9703
|
-
if (criteriaObject.isNumber() && criteriaObject.isDateFormat() && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString())) {
|
|
9826
|
+
if (operator !== "<>" && criteriaObject.isNumber() && criteriaObject.isDateFormat() && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString())) {
|
|
9704
9827
|
const rangeNumber = rangeValueObject.convertToNumberObjectValue();
|
|
9705
9828
|
if (rangeNumber.isNumber()) return rangeNumber.compare(criteriaObject, operator);
|
|
9706
9829
|
}
|
|
9707
9830
|
if (rangeValueObject && isSameValueObjectType(rangeValueObject, criteriaObject)) return valueObject;
|
|
9708
9831
|
if ((rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isError()) && criteriaObject.isError() && rangeValueObject.getValue() === criteriaObject.getValue()) return BooleanValueObject.create(true);
|
|
9709
9832
|
/**
|
|
9710
|
-
*
|
|
9833
|
+
* Equality criteria coerce numeric text; numeric inequality criteria
|
|
9834
|
+
* retain the distinction between text cells and numeric cells.
|
|
9711
9835
|
* Other operators require both valueObjects to be of the same type.
|
|
9712
9836
|
* For example:
|
|
9713
9837
|
* | A1 | B1 |
|
|
@@ -9719,8 +9843,8 @@ function filterSameValueObjectResult(array, range, criteria) {
|
|
|
9719
9843
|
* =COUNTIF(A1:B1, '<=123') will return 1
|
|
9720
9844
|
*/
|
|
9721
9845
|
if (operator === "=" || operator === "<>") {
|
|
9722
|
-
if (criteriaObject.isNumber() && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString())) {
|
|
9723
|
-
const rangeNumber = rangeValueObject.
|
|
9846
|
+
if (operator === "=" && criteriaObject.isNumber() && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString())) {
|
|
9847
|
+
const rangeNumber = createCriteriaValueObject(`${rangeValueObject.getValue()}`, rangeValueObject.getDateSystem());
|
|
9724
9848
|
if (rangeNumber.isNumber()) return rangeNumber.compare(criteriaObject, operator);
|
|
9725
9849
|
}
|
|
9726
9850
|
if (operator === "=") return BooleanValueObject.create(false);
|
|
@@ -9758,9 +9882,7 @@ function getReferenceObjectFromCache(trimToken, type) {
|
|
|
9758
9882
|
case 2:
|
|
9759
9883
|
referenceObject = new RowReferenceObject(trimToken);
|
|
9760
9884
|
break;
|
|
9761
|
-
default:
|
|
9762
|
-
referenceObject = new CellReferenceObject(trimToken);
|
|
9763
|
-
break;
|
|
9885
|
+
default: referenceObject = new CellReferenceObject(trimToken);
|
|
9764
9886
|
}
|
|
9765
9887
|
return referenceObject;
|
|
9766
9888
|
}
|
|
@@ -9786,10 +9908,12 @@ let HyperlinkEngineFormulaService = class HyperlinkEngineFormulaService extends
|
|
|
9786
9908
|
if (url.startsWith("#") && isReferenceString(url.slice(1))) {
|
|
9787
9909
|
const { unitId, sheetName, range } = deserializeRangeWithSheet(url.slice(1));
|
|
9788
9910
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
9789
|
-
if (unitId === "" || unitId === workbook.getUnitId())
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
9911
|
+
if (unitId === "" || unitId === workbook.getUnitId()) {
|
|
9912
|
+
if (sheetName === "") payload = `#gid=${workbook.getActiveSheet().getSheetId()}&range=${serializeRange(range)}`;
|
|
9913
|
+
else {
|
|
9914
|
+
const worksheet = workbook.getSheetBySheetName(sheetName);
|
|
9915
|
+
if (worksheet) payload = `#gid=${worksheet.getSheetId()}&range=${serializeRange(range)}`;
|
|
9916
|
+
}
|
|
9793
9917
|
}
|
|
9794
9918
|
} else if (Tools.isLegalUrl(url)) payload = Tools.normalizeUrl(url);
|
|
9795
9919
|
return { p: RichTextBuilder.create().insertLink(label, payload).getData() };
|
|
@@ -9830,6 +9954,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
9830
9954
|
this._hyperlinkEngineFormulaService = _hyperlinkEngineFormulaService;
|
|
9831
9955
|
_defineProperty(this, "_formulaExecuteStage", 0);
|
|
9832
9956
|
_defineProperty(this, "_stopState", false);
|
|
9957
|
+
_defineProperty(this, "_externalReferenceUnavailable", false);
|
|
9833
9958
|
_defineProperty(this, "_currentRow", -1);
|
|
9834
9959
|
_defineProperty(this, "_currentColumn", -1);
|
|
9835
9960
|
_defineProperty(this, "_currentRowCount", Number.NEGATIVE_INFINITY);
|
|
@@ -9837,14 +9962,14 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
9837
9962
|
_defineProperty(this, "_functionRefInfoOverrideStack", []);
|
|
9838
9963
|
_defineProperty(this, "_currentSubUnitId", "");
|
|
9839
9964
|
_defineProperty(this, "_currentUnitId", "");
|
|
9840
|
-
_defineProperty(this, "_runtimeData",
|
|
9841
|
-
_defineProperty(this, "_runtimeOtherData",
|
|
9842
|
-
_defineProperty(this, "_unitArrayFormulaRange",
|
|
9843
|
-
_defineProperty(this, "_unitArrayFormulaEmbeddedMap",
|
|
9844
|
-
_defineProperty(this, "_runtimeArrayFormulaCellData",
|
|
9845
|
-
_defineProperty(this, "_runtimeClearArrayFormulaCellData",
|
|
9846
|
-
_defineProperty(this, "_runtimeFeatureRange",
|
|
9847
|
-
_defineProperty(this, "_runtimeFeatureCellData",
|
|
9965
|
+
_defineProperty(this, "_runtimeData", Object.create(null));
|
|
9966
|
+
_defineProperty(this, "_runtimeOtherData", Object.create(null));
|
|
9967
|
+
_defineProperty(this, "_unitArrayFormulaRange", Object.create(null));
|
|
9968
|
+
_defineProperty(this, "_unitArrayFormulaEmbeddedMap", Object.create(null));
|
|
9969
|
+
_defineProperty(this, "_runtimeArrayFormulaCellData", Object.create(null));
|
|
9970
|
+
_defineProperty(this, "_runtimeClearArrayFormulaCellData", Object.create(null));
|
|
9971
|
+
_defineProperty(this, "_runtimeFeatureRange", Object.create(null));
|
|
9972
|
+
_defineProperty(this, "_runtimeFeatureCellData", Object.create(null));
|
|
9848
9973
|
_defineProperty(this, "_runtimeImageFormulaData", []);
|
|
9849
9974
|
_defineProperty(this, "_functionsExecutedState", 0);
|
|
9850
9975
|
_defineProperty(this, "_functionDefinitionPrivacyVar", /* @__PURE__ */ new Map());
|
|
@@ -9879,8 +10004,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
9879
10004
|
dispose() {
|
|
9880
10005
|
super.dispose();
|
|
9881
10006
|
this.reset();
|
|
9882
|
-
this._runtimeFeatureCellData =
|
|
9883
|
-
this._runtimeFeatureRange =
|
|
10007
|
+
this._runtimeFeatureCellData = Object.create(null);
|
|
10008
|
+
this._runtimeFeatureRange = Object.create(null);
|
|
9884
10009
|
this.clearReferenceAndNumberformatCache();
|
|
9885
10010
|
}
|
|
9886
10011
|
enableCycleDependency() {
|
|
@@ -9949,12 +10074,12 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
9949
10074
|
}
|
|
9950
10075
|
reset() {
|
|
9951
10076
|
this._formulaExecuteStage = 0;
|
|
9952
|
-
this._runtimeData =
|
|
9953
|
-
this._runtimeOtherData =
|
|
9954
|
-
this._unitArrayFormulaRange =
|
|
9955
|
-
this._unitArrayFormulaEmbeddedMap =
|
|
9956
|
-
this._runtimeArrayFormulaCellData =
|
|
9957
|
-
this._runtimeClearArrayFormulaCellData =
|
|
10077
|
+
this._runtimeData = Object.create(null);
|
|
10078
|
+
this._runtimeOtherData = Object.create(null);
|
|
10079
|
+
this._unitArrayFormulaRange = Object.create(null);
|
|
10080
|
+
this._unitArrayFormulaEmbeddedMap = Object.create(null);
|
|
10081
|
+
this._runtimeArrayFormulaCellData = Object.create(null);
|
|
10082
|
+
this._runtimeClearArrayFormulaCellData = Object.create(null);
|
|
9958
10083
|
this._runtimeImageFormulaData = [];
|
|
9959
10084
|
this._functionDefinitionPrivacyVar.clear();
|
|
9960
10085
|
this.markedAsInitialFunctionsExecuted();
|
|
@@ -9971,6 +10096,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
9971
10096
|
clearReferenceToRangeCache();
|
|
9972
10097
|
}
|
|
9973
10098
|
setCurrent(row, column, rowCount, columnCount, sheetId, unitId) {
|
|
10099
|
+
this._externalReferenceUnavailable = false;
|
|
9974
10100
|
this._currentRow = row;
|
|
9975
10101
|
this._currentColumn = column;
|
|
9976
10102
|
this._currentRowCount = rowCount;
|
|
@@ -10002,9 +10128,9 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10002
10128
|
setRuntimeOtherData(formulaId, x, y, functionVariant) {
|
|
10003
10129
|
const subUnitId = this._currentSubUnitId;
|
|
10004
10130
|
const unitId = this._currentUnitId;
|
|
10005
|
-
if (this._runtimeOtherData[unitId] === void 0) this._runtimeOtherData[unitId] =
|
|
10131
|
+
if (this._runtimeOtherData[unitId] === void 0) this._runtimeOtherData[unitId] = Object.create(null);
|
|
10006
10132
|
const unitData = this._runtimeOtherData[unitId];
|
|
10007
|
-
if (unitData[subUnitId] === void 0 || unitData[subUnitId] === null) unitData[subUnitId] =
|
|
10133
|
+
if (unitData[subUnitId] === void 0 || unitData[subUnitId] === null) unitData[subUnitId] = Object.create(null);
|
|
10008
10134
|
const subComponentData = unitData[subUnitId];
|
|
10009
10135
|
let cellDatas = [];
|
|
10010
10136
|
if (functionVariant.isReferenceObject() || functionVariant.isValueObject() && functionVariant.isArray()) {
|
|
@@ -10018,30 +10144,39 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10018
10144
|
cellDatas[row][column] = value;
|
|
10019
10145
|
});
|
|
10020
10146
|
} else cellDatas = [[this._getValueObjectOfRuntimeData(functionVariant)]];
|
|
10021
|
-
if (subComponentData[formulaId] === void 0 || subComponentData[formulaId] === null) subComponentData[formulaId] =
|
|
10022
|
-
if (subComponentData[formulaId][y] === void 0 || subComponentData[formulaId][y] === null) subComponentData[formulaId][y] =
|
|
10147
|
+
if (subComponentData[formulaId] === void 0 || subComponentData[formulaId] === null) subComponentData[formulaId] = Object.create(null);
|
|
10148
|
+
if (subComponentData[formulaId][y] === void 0 || subComponentData[formulaId][y] === null) subComponentData[formulaId][y] = Object.create(null);
|
|
10023
10149
|
subComponentData[formulaId][y][x] = cellDatas;
|
|
10024
10150
|
}
|
|
10151
|
+
markExternalReferenceUnavailable() {
|
|
10152
|
+
this._externalReferenceUnavailable = true;
|
|
10153
|
+
}
|
|
10025
10154
|
setRuntimeData(functionVariant) {
|
|
10155
|
+
if (this._externalReferenceUnavailable) {
|
|
10156
|
+
var _this$_currentConfigS, _this$_currentConfigS2;
|
|
10157
|
+
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);
|
|
10158
|
+
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;
|
|
10159
|
+
if ((cell === null || cell === void 0 ? void 0 : cell.f) && cell.v != null && (formula == null || formula === cell.f)) return;
|
|
10160
|
+
}
|
|
10026
10161
|
const row = this._currentRow;
|
|
10027
10162
|
const column = this._currentColumn;
|
|
10028
10163
|
const rowCount = this._currentRowCount;
|
|
10029
10164
|
const columnCount = this.currentColumnCount;
|
|
10030
10165
|
const sheetId = this._currentSubUnitId;
|
|
10031
10166
|
const unitId = this._currentUnitId;
|
|
10032
|
-
if (this._runtimeData[unitId] == null) this._runtimeData[unitId] =
|
|
10167
|
+
if (this._runtimeData[unitId] == null) this._runtimeData[unitId] = Object.create(null);
|
|
10033
10168
|
const unitData = this._runtimeData[unitId];
|
|
10034
10169
|
if (unitData[sheetId] == null) unitData[sheetId] = new ObjectMatrix();
|
|
10035
10170
|
const sheetData = unitData[sheetId];
|
|
10036
|
-
if (this._unitArrayFormulaRange[unitId] == null) this._unitArrayFormulaRange[unitId] =
|
|
10171
|
+
if (this._unitArrayFormulaRange[unitId] == null) this._unitArrayFormulaRange[unitId] = Object.create(null);
|
|
10037
10172
|
const arrayFormulaRange = this._unitArrayFormulaRange[unitId];
|
|
10038
|
-
if (arrayFormulaRange[sheetId] === null || arrayFormulaRange[sheetId] === void 0) arrayFormulaRange[sheetId] =
|
|
10173
|
+
if (arrayFormulaRange[sheetId] === null || arrayFormulaRange[sheetId] === void 0) arrayFormulaRange[sheetId] = Object.create(null);
|
|
10039
10174
|
const arrayData = new ObjectMatrix(arrayFormulaRange[sheetId]);
|
|
10040
|
-
if (this._runtimeArrayFormulaCellData[unitId] === void 0) this._runtimeArrayFormulaCellData[unitId] =
|
|
10175
|
+
if (this._runtimeArrayFormulaCellData[unitId] === void 0) this._runtimeArrayFormulaCellData[unitId] = Object.create(null);
|
|
10041
10176
|
const runtimeArrayFormulaCellData = this._runtimeArrayFormulaCellData[unitId];
|
|
10042
10177
|
if (runtimeArrayFormulaCellData[sheetId] == null) runtimeArrayFormulaCellData[sheetId] = new ObjectMatrix();
|
|
10043
10178
|
const runtimeArrayUnitData = runtimeArrayFormulaCellData[sheetId];
|
|
10044
|
-
if (this._runtimeClearArrayFormulaCellData[unitId] === void 0) this._runtimeClearArrayFormulaCellData[unitId] =
|
|
10179
|
+
if (this._runtimeClearArrayFormulaCellData[unitId] === void 0) this._runtimeClearArrayFormulaCellData[unitId] = Object.create(null);
|
|
10045
10180
|
const clearArrayFormulaCellData = this._runtimeClearArrayFormulaCellData[unitId];
|
|
10046
10181
|
if (clearArrayFormulaCellData[sheetId] == null) clearArrayFormulaCellData[sheetId] = new ObjectMatrix();
|
|
10047
10182
|
const clearArrayUnitData = clearArrayFormulaCellData[sheetId];
|
|
@@ -10079,7 +10214,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10079
10214
|
const hasDataInArrayFormulaRange = this._checkIfArrayFormulaRangeHasData(unitId, sheetId, row, column, arrayRange);
|
|
10080
10215
|
const isArrayFormulaExceeded = this._checkIfArrayFormulaExceeded(rowCount, columnCount, arrayRange);
|
|
10081
10216
|
if (hasDataInArrayFormulaRange || isArrayFormulaExceeded) {
|
|
10082
|
-
var _this$
|
|
10217
|
+
var _this$_currentConfigS3;
|
|
10083
10218
|
const errorObject = this._getValueObjectOfRuntimeData(ErrorValueObject.create("#SPILL!"));
|
|
10084
10219
|
sheetData.setValue(row, column, errorObject);
|
|
10085
10220
|
clearArrayUnitData.setValue(row, column, errorObject);
|
|
@@ -10090,7 +10225,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10090
10225
|
*/
|
|
10091
10226
|
const unitData = this._currentConfigService.getUnitData();
|
|
10092
10227
|
const arrayData = this._currentConfigService.getArrayFormulaCellData();
|
|
10093
|
-
const previousArrayFormulaRange = (_this$
|
|
10228
|
+
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];
|
|
10094
10229
|
objectValueRefOrArray.iterator((_, rowIndex, columnIndex) => {
|
|
10095
10230
|
var _unitData$unitId, _arrayData$unitId;
|
|
10096
10231
|
const currentRow = rowIndex - startRow + row;
|
|
@@ -10108,7 +10243,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10108
10243
|
} else {
|
|
10109
10244
|
const spillError = ErrorValueObject.create("#SPILL!");
|
|
10110
10245
|
objectValueRefOrArray.iterator((valueObject, rowIndex, columnIndex) => {
|
|
10111
|
-
CELL_INVERTED_INDEX_CACHE.set(unitId, sheetId, column - startColumn + columnIndex,
|
|
10246
|
+
CELL_INVERTED_INDEX_CACHE.set(unitId, sheetId, column - startColumn + columnIndex, valueObject == null || valueObject.isNull() ? null : valueObject.getValue(), row - startRow + rowIndex, true);
|
|
10112
10247
|
const value = this._getValueObjectOfRuntimeData(valueObject);
|
|
10113
10248
|
if (rowIndex === startRow && columnIndex === startColumn) {
|
|
10114
10249
|
/**
|
|
@@ -10140,7 +10275,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10140
10275
|
column
|
|
10141
10276
|
});
|
|
10142
10277
|
}
|
|
10143
|
-
CELL_INVERTED_INDEX_CACHE.set(unitId, sheetId, column, functionVariant.getValue(), row, true);
|
|
10278
|
+
CELL_INVERTED_INDEX_CACHE.set(unitId, sheetId, column, functionVariant.isNull() ? null : functionVariant.getValue(), row, true);
|
|
10144
10279
|
clearArrayUnitData.setValue(row, column, valueObject);
|
|
10145
10280
|
}
|
|
10146
10281
|
}
|
|
@@ -10163,9 +10298,9 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10163
10298
|
const rowIndex = this._currentRow;
|
|
10164
10299
|
const columnIndex = this._currentColumn;
|
|
10165
10300
|
const arrayFormulaEmbeddedMap = this._unitArrayFormulaEmbeddedMap;
|
|
10166
|
-
if (arrayFormulaEmbeddedMap[unitId] == null) arrayFormulaEmbeddedMap[unitId] =
|
|
10167
|
-
if (arrayFormulaEmbeddedMap[unitId][sheetId] == null) arrayFormulaEmbeddedMap[unitId][sheetId] =
|
|
10168
|
-
if (arrayFormulaEmbeddedMap[unitId][sheetId][rowIndex] == null) arrayFormulaEmbeddedMap[unitId][sheetId][rowIndex] =
|
|
10301
|
+
if (arrayFormulaEmbeddedMap[unitId] == null) arrayFormulaEmbeddedMap[unitId] = Object.create(null);
|
|
10302
|
+
if (arrayFormulaEmbeddedMap[unitId][sheetId] == null) arrayFormulaEmbeddedMap[unitId][sheetId] = Object.create(null);
|
|
10303
|
+
if (arrayFormulaEmbeddedMap[unitId][sheetId][rowIndex] == null) arrayFormulaEmbeddedMap[unitId][sheetId][rowIndex] = Object.create(null);
|
|
10169
10304
|
arrayFormulaEmbeddedMap[unitId][sheetId][rowIndex][columnIndex] = true;
|
|
10170
10305
|
}
|
|
10171
10306
|
getRuntimeOtherData() {
|
|
@@ -10227,11 +10362,11 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10227
10362
|
FORMULA_REF_TO_ARRAY_CACHE.clear();
|
|
10228
10363
|
}
|
|
10229
10364
|
_checkIfArrayFormulaRangeHasData(formulaUnitId, formulaSheetId, formulaRow, formulaColumn, arrayRange) {
|
|
10230
|
-
var _this$
|
|
10365
|
+
var _this$_currentConfigS4;
|
|
10231
10366
|
const { startRow, startColumn, endRow, endColumn } = arrayRange;
|
|
10232
10367
|
const unitData = this._currentConfigService.getUnitData();
|
|
10233
10368
|
const arrayData = this._currentConfigService.getArrayFormulaCellData();
|
|
10234
|
-
const previousArrayFormulaRange = (_this$
|
|
10369
|
+
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];
|
|
10235
10370
|
for (let r = startRow; r <= endRow; r++) for (let c = startColumn; c <= endColumn; c++) {
|
|
10236
10371
|
var _this$_runtimeData, _arrayData$formulaUni, _unitData$formulaUnit;
|
|
10237
10372
|
if (r === formulaRow && formulaColumn === c) continue;
|
|
@@ -10267,8 +10402,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10267
10402
|
* @returns
|
|
10268
10403
|
*/
|
|
10269
10404
|
_isInOtherArrayFormulaRange(formulaUnitId, formulaSheetId, formulaRow, formulaColumn, r, c) {
|
|
10270
|
-
var _this$
|
|
10271
|
-
const arrayFormulaRange = (_this$
|
|
10405
|
+
var _this$_currentConfigS5;
|
|
10406
|
+
const arrayFormulaRange = (_this$_currentConfigS5 = this._currentConfigService.getArrayFormulaRange()[formulaUnitId]) === null || _this$_currentConfigS5 === void 0 ? void 0 : _this$_currentConfigS5[formulaSheetId];
|
|
10272
10407
|
if (arrayFormulaRange == null) return false;
|
|
10273
10408
|
let isCellOverlapping = false;
|
|
10274
10409
|
new ObjectMatrix(arrayFormulaRange).forValue((rangeRow, rangeCol, range) => {
|
|
@@ -10281,8 +10416,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10281
10416
|
return isCellOverlapping;
|
|
10282
10417
|
}
|
|
10283
10418
|
_isCurrentSingleCellArrayFormulaRange(unitId, sheetId, row, column) {
|
|
10284
|
-
var _this$
|
|
10285
|
-
const range = (_this$
|
|
10419
|
+
var _this$_currentConfigS6;
|
|
10420
|
+
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];
|
|
10286
10421
|
return range != null && range.startRow === range.endRow && range.startColumn === range.endColumn;
|
|
10287
10422
|
}
|
|
10288
10423
|
_isInArrayFormulaRange(range, r, c) {
|
|
@@ -10292,7 +10427,9 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10292
10427
|
return false;
|
|
10293
10428
|
}
|
|
10294
10429
|
_isSameCellValue(cell, arrayDataCell) {
|
|
10295
|
-
|
|
10430
|
+
if ((cell === null || cell === void 0 ? void 0 : cell.t) !== (arrayDataCell === null || arrayDataCell === void 0 ? void 0 : arrayDataCell.t)) return false;
|
|
10431
|
+
if ((cell === null || cell === void 0 ? void 0 : cell.v) === (arrayDataCell === null || arrayDataCell === void 0 ? void 0 : arrayDataCell.v)) return true;
|
|
10432
|
+
return (cell === null || cell === void 0 ? void 0 : cell.t) === CellValueType.NUMBER && isRealNum(cell.v) && isRealNum(arrayDataCell === null || arrayDataCell === void 0 ? void 0 : arrayDataCell.v) && Number(cell.v) === Number(arrayDataCell === null || arrayDataCell === void 0 ? void 0 : arrayDataCell.v);
|
|
10296
10433
|
}
|
|
10297
10434
|
_checkIfArrayFormulaExceeded(rowCount, columnCount, arrayRange) {
|
|
10298
10435
|
if (arrayRange.endRow >= rowCount || arrayRange.endColumn >= columnCount) return true;
|
|
@@ -10383,7 +10520,7 @@ let FormulaUnitReferenceResolver = class FormulaUnitReferenceResolver {
|
|
|
10383
10520
|
constructor(_currentConfigService) {
|
|
10384
10521
|
this._currentConfigService = _currentConfigService;
|
|
10385
10522
|
}
|
|
10386
|
-
resolve({ hostUnitId, qualifier, referenceKind }) {
|
|
10523
|
+
resolve({ hostUnitId, qualifier, referenceKind, onUnavailable }) {
|
|
10387
10524
|
const unitNameMap = this._currentConfigService.getUnitNameMap();
|
|
10388
10525
|
const unitData = this._currentConfigService.getUnitData();
|
|
10389
10526
|
const address = qualifier || hostUnitId;
|
|
@@ -10397,7 +10534,10 @@ let FormulaUnitReferenceResolver = class FormulaUnitReferenceResolver {
|
|
|
10397
10534
|
const normalizedQualifier = qualifier.toLowerCase();
|
|
10398
10535
|
const exactMatches = namedUnits.filter(([, item]) => item.name.toLowerCase() === normalizedQualifier);
|
|
10399
10536
|
const matches = exactMatches.length > 0 ? exactMatches : namedUnits.filter(([, item]) => normalizeFormulaUnitName(item.name) === normalizeFormulaUnitName(qualifier));
|
|
10400
|
-
if (matches.length !== 1)
|
|
10537
|
+
if (matches.length !== 1) {
|
|
10538
|
+
if (matches.length === 0) onUnavailable === null || onUnavailable === void 0 || onUnavailable();
|
|
10539
|
+
return "#REF!";
|
|
10540
|
+
}
|
|
10401
10541
|
const [unitId, item] = matches[0];
|
|
10402
10542
|
return this._validateReferenceKind(hostUnitId, referenceKind, {
|
|
10403
10543
|
unitId,
|
|
@@ -10418,16 +10558,21 @@ FormulaUnitReferenceResolver = __decorate([__decorateParam(0, IFormulaCurrentCon
|
|
|
10418
10558
|
//#endregion
|
|
10419
10559
|
//#region src/engine/ast-node/prefix-node.ts
|
|
10420
10560
|
var PrefixNode = class extends BaseAstNode {
|
|
10561
|
+
getReferenceRanges() {
|
|
10562
|
+
return this._referenceRanges;
|
|
10563
|
+
}
|
|
10421
10564
|
constructor(_runtimeService, _operatorString, _functionExecutor) {
|
|
10422
10565
|
super(_operatorString);
|
|
10423
10566
|
this._runtimeService = _runtimeService;
|
|
10424
10567
|
this._operatorString = _operatorString;
|
|
10425
10568
|
this._functionExecutor = _functionExecutor;
|
|
10569
|
+
_defineProperty(this, "_referenceRanges", null);
|
|
10426
10570
|
}
|
|
10427
10571
|
get nodeType() {
|
|
10428
10572
|
return 11;
|
|
10429
10573
|
}
|
|
10430
10574
|
execute(dateSystem = DateSystem.Date1900) {
|
|
10575
|
+
this._referenceRanges = null;
|
|
10431
10576
|
let value = this.getChildren()[0].getValue();
|
|
10432
10577
|
let result;
|
|
10433
10578
|
if (value == null) {
|
|
@@ -10446,7 +10591,8 @@ var PrefixNode = class extends BaseAstNode {
|
|
|
10446
10591
|
if (value instanceof ArrayValueObject) return value.get(0, 0) ?? ErrorValueObject.create("#VALUE!");
|
|
10447
10592
|
if (!value.isReferenceObject()) return value;
|
|
10448
10593
|
const currentValue = value;
|
|
10449
|
-
|
|
10594
|
+
this._referenceRanges = [];
|
|
10595
|
+
if (currentValue.isCell()) return this._getReferencedCell(currentValue);
|
|
10450
10596
|
if (this._preserveAtRangeForFormula2LookupArray()) return currentValue;
|
|
10451
10597
|
const runtimeService = this._runtimeService;
|
|
10452
10598
|
const currentRow = runtimeService.currentRow || 0;
|
|
@@ -10454,11 +10600,27 @@ var PrefixNode = class extends BaseAstNode {
|
|
|
10454
10600
|
const { startRow, startColumn, endRow, endColumn } = currentValue.getRangePosition();
|
|
10455
10601
|
if (endColumn !== startColumn && endRow !== startRow) return ErrorValueObject.create("#VALUE!");
|
|
10456
10602
|
if (startRow === endRow && startColumn === endColumn) return ErrorValueObject.create("#VALUE!");
|
|
10457
|
-
if (endRow === startRow && currentColumn >= startColumn && currentColumn <= endColumn) return
|
|
10458
|
-
else if (startColumn === endColumn && currentRow >= startRow && currentRow <= endRow) return
|
|
10459
|
-
if (currentValue.isTable()) return
|
|
10603
|
+
if (endRow === startRow && currentColumn >= startColumn && currentColumn <= endColumn) return this._getReferencedCell(currentValue, void 0, currentColumn);
|
|
10604
|
+
else if (startColumn === endColumn && currentRow >= startRow && currentRow <= endRow) return this._getReferencedCell(currentValue, currentRow);
|
|
10605
|
+
if (currentValue.isTable()) return this._getReferencedCell(currentValue, currentRow);
|
|
10460
10606
|
return ErrorValueObject.create("#VALUE!");
|
|
10461
10607
|
}
|
|
10608
|
+
_getReferencedCell(reference, row, column) {
|
|
10609
|
+
const position = reference.getRangePosition();
|
|
10610
|
+
const selectedRow = row ?? position.startRow;
|
|
10611
|
+
const selectedColumn = column ?? position.startColumn;
|
|
10612
|
+
this._referenceRanges = reference.toUnitRanges().map((range) => ({
|
|
10613
|
+
unitId: range.unitId,
|
|
10614
|
+
sheetId: range.sheetId,
|
|
10615
|
+
range: {
|
|
10616
|
+
startRow: selectedRow,
|
|
10617
|
+
endRow: selectedRow,
|
|
10618
|
+
startColumn: selectedColumn,
|
|
10619
|
+
endColumn: selectedColumn
|
|
10620
|
+
}
|
|
10621
|
+
}));
|
|
10622
|
+
return reference.getCellByPosition(selectedRow, selectedColumn);
|
|
10623
|
+
}
|
|
10462
10624
|
_preserveAtRangeForFormula2LookupArray() {
|
|
10463
10625
|
let node = this;
|
|
10464
10626
|
let parent = node.getParent();
|
|
@@ -10798,7 +10960,8 @@ let FunctionNodeFactory = class FunctionNodeFactory extends BaseAstNodeFactory {
|
|
|
10798
10960
|
}
|
|
10799
10961
|
checkAndCreateNodeType(param) {
|
|
10800
10962
|
if (typeof param === "string") return;
|
|
10801
|
-
const
|
|
10963
|
+
const token = param.getToken();
|
|
10964
|
+
const { tokenTrim, minusPrefixNode, atPrefixNode } = prefixHandler(token.trim(), this._functionService, this._runtimeService);
|
|
10802
10965
|
const isColon = this._isParentUnionNode(param);
|
|
10803
10966
|
if (!Number.isNaN(Number(tokenTrim)) && !isColon) return ErrorNode.create("#VALUE!");
|
|
10804
10967
|
const tokenTrimUpper = normalizeFunctionToken(tokenTrim.toUpperCase());
|
|
@@ -11576,7 +11739,6 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11576
11739
|
default:
|
|
11577
11740
|
startRow = dataStartRow;
|
|
11578
11741
|
endRow = dataEndRow;
|
|
11579
|
-
break;
|
|
11580
11742
|
}
|
|
11581
11743
|
this.setRangeData({
|
|
11582
11744
|
startColumn,
|
|
@@ -11797,7 +11959,7 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11797
11959
|
}
|
|
11798
11960
|
/** Column title → column index; returns -1 if not found (caller should handle as parse error) */
|
|
11799
11961
|
_titleToIndex(name, titleMap) {
|
|
11800
|
-
const key = name.trim();
|
|
11962
|
+
const key = this._unescapeColumnName(name.trim());
|
|
11801
11963
|
const hit = titleMap.get(key);
|
|
11802
11964
|
if (hit !== void 0) return hit;
|
|
11803
11965
|
const keyNorm = key.replace(/\u3000/g, " ").trim();
|
|
@@ -11807,6 +11969,9 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11807
11969
|
for (const [title, index] of titleMap.entries()) if (title.replace(/\u3000/g, " ").trim().replace(/\r\n?/g, "\n") === lineBreakNorm) return index;
|
|
11808
11970
|
return -1;
|
|
11809
11971
|
}
|
|
11972
|
+
_unescapeColumnName(name) {
|
|
11973
|
+
return name.replace(/'(['#\[\]@])/g, "$1");
|
|
11974
|
+
}
|
|
11810
11975
|
/** Resolve #This Row's row number; takes first data row (tableStartRow+1) when no context available */
|
|
11811
11976
|
_resolveThisRow(dataStartRow, dataEndRow) {
|
|
11812
11977
|
this._isCurrentRowForRange = true;
|
|
@@ -11844,7 +12009,8 @@ var ReferenceNode = class extends BaseAstNode {
|
|
|
11844
12009
|
const resolution = this._unitReferenceResolver.resolve({
|
|
11845
12010
|
hostUnitId: runtimeService.currentUnitId,
|
|
11846
12011
|
qualifier: unitQualifier,
|
|
11847
|
-
referenceKind: "table"
|
|
12012
|
+
referenceKind: "table",
|
|
12013
|
+
onUnavailable: () => runtimeService.markExternalReferenceUnavailable()
|
|
11848
12014
|
});
|
|
11849
12015
|
if (typeof resolution === "string") {
|
|
11850
12016
|
this.setValue(ErrorValueObject.create(resolution));
|
|
@@ -11866,7 +12032,8 @@ var ReferenceNode = class extends BaseAstNode {
|
|
|
11866
12032
|
const resolution = this._unitReferenceResolver.resolve({
|
|
11867
12033
|
hostUnitId: runtimeService.currentUnitId,
|
|
11868
12034
|
qualifier: unitQualifier,
|
|
11869
|
-
referenceKind: "a1"
|
|
12035
|
+
referenceKind: "a1",
|
|
12036
|
+
onUnavailable: () => runtimeService.markExternalReferenceUnavailable()
|
|
11870
12037
|
});
|
|
11871
12038
|
if (typeof resolution === "string") {
|
|
11872
12039
|
this.setValue(ErrorValueObject.create(resolution));
|
|
@@ -11890,7 +12057,8 @@ var ReferenceNode = class extends BaseAstNode {
|
|
|
11890
12057
|
const resolution = this._unitReferenceResolver.resolve({
|
|
11891
12058
|
hostUnitId,
|
|
11892
12059
|
qualifier: unitQualifier,
|
|
11893
|
-
referenceKind
|
|
12060
|
+
referenceKind,
|
|
12061
|
+
onUnavailable: () => this._runtimeService.markExternalReferenceUnavailable()
|
|
11894
12062
|
});
|
|
11895
12063
|
if (typeof resolution === "string") {
|
|
11896
12064
|
this.setValue(ErrorValueObject.create(resolution));
|
|
@@ -11909,6 +12077,7 @@ var ReferenceNode = class extends BaseAstNode {
|
|
|
11909
12077
|
resolution
|
|
11910
12078
|
});
|
|
11911
12079
|
if (error) {
|
|
12080
|
+
if (error === "#N/A") this._runtimeService.markExternalReferenceUnavailable();
|
|
11912
12081
|
this.setValue(ErrorValueObject.create(error));
|
|
11913
12082
|
return 1;
|
|
11914
12083
|
}
|
|
@@ -12009,11 +12178,9 @@ let ReferenceNodeFactory = class ReferenceNodeFactory extends BaseAstNodeFactory
|
|
|
12009
12178
|
return this._getTableReferenceNode(tokenTrim, isPrepareMerge, false);
|
|
12010
12179
|
}
|
|
12011
12180
|
_getTableReferenceNode(tokenTrim, isPrepareMerge, isSuperTableDirectly = false) {
|
|
12012
|
-
if (!this._checkTokenIsTableReference(tokenTrim) && !isSuperTableDirectly) return;
|
|
12181
|
+
if ((!tokenTrim.includes("[") || !this._checkTokenIsTableReference(tokenTrim)) && !isSuperTableDirectly) return;
|
|
12013
12182
|
const { unitQualifier, tableName, columnStruct } = splitTableStructuredRef(tokenTrim);
|
|
12014
|
-
|
|
12015
|
-
const hasLocalTable = Array.from((tableMap === null || tableMap === void 0 ? void 0 : tableMap.keys()) || []).some((name) => name.toLocaleLowerCase() === tableName.toLocaleLowerCase());
|
|
12016
|
-
if (unitQualifier || hasLocalTable) return new ReferenceNode(this._currentConfigService, this._formulaRuntimeService, tokenTrim, 1, this._unitReferenceResolver, this._superTableService, this._externalReferenceDataLoader, isPrepareMerge, {
|
|
12183
|
+
return new ReferenceNode(this._currentConfigService, this._formulaRuntimeService, tokenTrim, 1, this._unitReferenceResolver, this._superTableService, this._externalReferenceDataLoader, isPrepareMerge, {
|
|
12017
12184
|
unitQualifier,
|
|
12018
12185
|
tableName,
|
|
12019
12186
|
columnStruct
|
|
@@ -12684,9 +12851,7 @@ let AstTreeBuilder = class AstTreeBuilder extends Disposable {
|
|
|
12684
12851
|
case 11:
|
|
12685
12852
|
calculateStack.push(astNode);
|
|
12686
12853
|
break;
|
|
12687
|
-
case 12:
|
|
12688
|
-
calculateStack.push(astNode);
|
|
12689
|
-
break;
|
|
12854
|
+
case 12: calculateStack.push(astNode);
|
|
12690
12855
|
}
|
|
12691
12856
|
}
|
|
12692
12857
|
const calculateStackCount = calculateStack.length;
|
|
@@ -13210,11 +13375,11 @@ const IFeatureCalculationManagerService = createIdentifier("univer.formula.featu
|
|
|
13210
13375
|
var OtherFormulaManagerService = class extends Disposable {
|
|
13211
13376
|
constructor(..._args) {
|
|
13212
13377
|
super(..._args);
|
|
13213
|
-
_defineProperty(this, "_otherFormulaData",
|
|
13378
|
+
_defineProperty(this, "_otherFormulaData", Object.create(null));
|
|
13214
13379
|
}
|
|
13215
13380
|
dispose() {
|
|
13216
13381
|
super.dispose();
|
|
13217
|
-
this._otherFormulaData =
|
|
13382
|
+
this._otherFormulaData = Object.create(null);
|
|
13218
13383
|
}
|
|
13219
13384
|
remove(searchParam) {
|
|
13220
13385
|
var _this$_otherFormulaDa;
|
|
@@ -13233,8 +13398,8 @@ var OtherFormulaManagerService = class extends Disposable {
|
|
|
13233
13398
|
}
|
|
13234
13399
|
register(insertParam) {
|
|
13235
13400
|
const { unitId, subUnitId, formulaId, item } = insertParam;
|
|
13236
|
-
if (!this._otherFormulaData[unitId]) this._otherFormulaData[unitId] =
|
|
13237
|
-
if (!this._otherFormulaData[unitId][subUnitId]) this._otherFormulaData[unitId][subUnitId] =
|
|
13401
|
+
if (!this._otherFormulaData[unitId]) this._otherFormulaData[unitId] = Object.create(null);
|
|
13402
|
+
if (!this._otherFormulaData[unitId][subUnitId]) this._otherFormulaData[unitId][subUnitId] = Object.create(null);
|
|
13238
13403
|
this._otherFormulaData[unitId][subUnitId][formulaId] = item;
|
|
13239
13404
|
}
|
|
13240
13405
|
batchRegister(formulaData) {
|
|
@@ -13760,7 +13925,8 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
|
|
|
13760
13925
|
}
|
|
13761
13926
|
_getFeatureFormulaTree(featureId, treeId, params) {
|
|
13762
13927
|
const { unitId, subUnitId, dependencyRanges, getDirtyData } = params;
|
|
13763
|
-
const
|
|
13928
|
+
const treeIdNum = treeId || generateRandomDependencyTreeId(this._dependencyManagerService);
|
|
13929
|
+
const FDtree = new FormulaDependencyTree(treeIdNum);
|
|
13764
13930
|
FDtree.unitId = unitId;
|
|
13765
13931
|
FDtree.subUnitId = subUnitId;
|
|
13766
13932
|
FDtree.rangeList = dependencyRanges;
|
|
@@ -13771,7 +13937,7 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
|
|
|
13771
13937
|
FDtree.type = 2;
|
|
13772
13938
|
this._dependencyManagerService.addFeatureFormulaDependency(unitId, subUnitId, featureId, FDtree);
|
|
13773
13939
|
this._dependencyTreeCache.set(FDtree.treeId, FDtree);
|
|
13774
|
-
if (
|
|
13940
|
+
if (treeId != null) FDtree.isCache = true;
|
|
13775
13941
|
return FDtree;
|
|
13776
13942
|
}
|
|
13777
13943
|
_registerOtherFormulas(otherFormulaData, otherFormulaDataKeys, treeList) {
|
|
@@ -13796,7 +13962,8 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
|
|
|
13796
13962
|
if (hasOtherFormula) isCache = true;
|
|
13797
13963
|
const { firstRow, firstColumn } = this._getFirstCellOfRange(ranges);
|
|
13798
13964
|
const treeMatrix = this._dependencyManagerService.getOtherFormulaDependency(unitId, subUnitId, subFormulaDataId);
|
|
13799
|
-
const
|
|
13965
|
+
const firstTreeId = (treeMatrix === null || treeMatrix === void 0 ? void 0 : treeMatrix.getValue(0, 0)) ?? generateRandomDependencyTreeId(this._dependencyManagerService);
|
|
13966
|
+
const firstFDtree = new FormulaDependencyTree(firstTreeId);
|
|
13800
13967
|
for (let i = 0; i < ranges.length; i++) {
|
|
13801
13968
|
const range = ranges[i];
|
|
13802
13969
|
const { startRow, startColumn } = range;
|
|
@@ -14191,6 +14358,14 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
|
|
|
14191
14358
|
const node = preCalculateNodeList[i];
|
|
14192
14359
|
const value = await this._executeNode(node, refOffsetX, refOffsetY);
|
|
14193
14360
|
if (value != null) rangeList.push(...value.toUnitRanges());
|
|
14361
|
+
else if (node.nodeType === 11) {
|
|
14362
|
+
const intersectionRanges = node.getReferenceRanges();
|
|
14363
|
+
rangeList.push(...intersectionRanges ?? await this._getRangeListByNode({
|
|
14364
|
+
node,
|
|
14365
|
+
refOffsetX,
|
|
14366
|
+
refOffsetY
|
|
14367
|
+
}));
|
|
14368
|
+
}
|
|
14194
14369
|
node.setValue(null);
|
|
14195
14370
|
}
|
|
14196
14371
|
return rangeList;
|
|
@@ -14636,7 +14811,7 @@ let CalculateFormulaService = class CalculateFormulaService extends Disposable {
|
|
|
14636
14811
|
}
|
|
14637
14812
|
_getArrayFormulaDirtyRangeAndExcludedRange(arrayFormulaRange, runtimeFeatureRange) {
|
|
14638
14813
|
const dirtyRanges = [];
|
|
14639
|
-
const excludedCell =
|
|
14814
|
+
const excludedCell = Object.create(null);
|
|
14640
14815
|
Object.keys(arrayFormulaRange).forEach((unitId) => {
|
|
14641
14816
|
const sheetArrayFormulaRange = arrayFormulaRange[unitId];
|
|
14642
14817
|
if (sheetArrayFormulaRange == null) return true;
|
|
@@ -14652,7 +14827,7 @@ let CalculateFormulaService = class CalculateFormulaService extends Disposable {
|
|
|
14652
14827
|
range
|
|
14653
14828
|
});
|
|
14654
14829
|
});
|
|
14655
|
-
if (excludedCell[unitId] == null) excludedCell[unitId] =
|
|
14830
|
+
if (excludedCell[unitId] == null) excludedCell[unitId] = Object.create(null);
|
|
14656
14831
|
excludedCell[unitId][sheetId] = newCellData;
|
|
14657
14832
|
});
|
|
14658
14833
|
});
|
|
@@ -14757,21 +14932,21 @@ let CalculateFormulaService = class CalculateFormulaService extends Disposable {
|
|
|
14757
14932
|
this._currentConfigService.loadDataLite(rowData);
|
|
14758
14933
|
const unitData = this._currentConfigService.getUnitData();
|
|
14759
14934
|
this._runtimeService.reset();
|
|
14760
|
-
const result =
|
|
14935
|
+
const result = Object.create(null);
|
|
14761
14936
|
for (const unitId of Object.keys(formulas)) {
|
|
14762
14937
|
const sheetFormulas = formulas[unitId];
|
|
14763
14938
|
if (sheetFormulas == null) continue;
|
|
14764
|
-
result[unitId] =
|
|
14939
|
+
result[unitId] = Object.create(null);
|
|
14765
14940
|
for (const sheetId of Object.keys(sheetFormulas)) {
|
|
14766
14941
|
var _unitData$unitId;
|
|
14767
14942
|
const rowFormulas = sheetFormulas[sheetId];
|
|
14768
14943
|
if (rowFormulas == null) continue;
|
|
14769
14944
|
const sheetItem = (_unitData$unitId = unitData[unitId]) === null || _unitData$unitId === void 0 ? void 0 : _unitData$unitId[sheetId];
|
|
14770
14945
|
if (sheetItem == null) continue;
|
|
14771
|
-
result[unitId][sheetId] =
|
|
14946
|
+
result[unitId][sheetId] = Object.create(null);
|
|
14772
14947
|
for (const rowString of Object.keys(rowFormulas)) {
|
|
14773
14948
|
const row = Number.parseInt(rowString);
|
|
14774
|
-
result[unitId][sheetId][row] =
|
|
14949
|
+
result[unitId][sheetId][row] = Object.create(null);
|
|
14775
14950
|
const cellData = rowFormulas[row];
|
|
14776
14951
|
if (!cellData) continue;
|
|
14777
14952
|
for (const columnString of Object.keys(cellData)) {
|
|
@@ -14965,7 +15140,7 @@ let CalculateController = class CalculateController extends Disposable {
|
|
|
14965
15140
|
case 3:
|
|
14966
15141
|
this._applyResult(data);
|
|
14967
15142
|
break;
|
|
14968
|
-
case 0:
|
|
15143
|
+
case 0:
|
|
14969
15144
|
}
|
|
14970
15145
|
this._commandService.executeCommand(SetFormulaCalculationNotificationMutation.id, { functionsExecutedState }, { onlyLocal: true });
|
|
14971
15146
|
});
|
|
@@ -16411,12 +16586,13 @@ var BaseFunction = class {
|
|
|
16411
16586
|
}
|
|
16412
16587
|
createReferenceObject(reference, range) {
|
|
16413
16588
|
const unitId = reference.getForcedUnitId() || reference.getDefaultUnitId() || "";
|
|
16414
|
-
const sheetId = reference.getForcedSheetId() || reference.
|
|
16415
|
-
const
|
|
16589
|
+
const sheetId = reference.getForcedSheetId() || reference.getDefaultSheetId() || "";
|
|
16590
|
+
const gridRangeName = {
|
|
16416
16591
|
unitId,
|
|
16417
16592
|
sheetName: reference.getForcedSheetName(),
|
|
16418
16593
|
range
|
|
16419
|
-
}
|
|
16594
|
+
};
|
|
16595
|
+
const token = serializeRangeToRefString(gridRangeName);
|
|
16420
16596
|
let referenceObject;
|
|
16421
16597
|
if (regexTestSingeRange(token)) referenceObject = new CellReferenceObject(token);
|
|
16422
16598
|
else if (regexTestSingleRow(token)) referenceObject = new RowReferenceObject(token);
|
|
@@ -16837,7 +17013,7 @@ let BESSEL;
|
|
|
16837
17013
|
.39894228
|
|
16838
17014
|
];
|
|
16839
17015
|
function bessel0(x) {
|
|
16840
|
-
if (x <= 3.75) return _horner(b0_a, x * x /
|
|
17016
|
+
if (x <= 3.75) return _horner(b0_a, x * x / 14.0625);
|
|
16841
17017
|
return Math.exp(Math.abs(x)) / Math.sqrt(Math.abs(x)) * _horner(b0_b, 3.75 / Math.abs(x));
|
|
16842
17018
|
}
|
|
16843
17019
|
const b1_a = [
|
|
@@ -16861,7 +17037,7 @@ let BESSEL;
|
|
|
16861
17037
|
.39894228
|
|
16862
17038
|
];
|
|
16863
17039
|
function bessel1(x) {
|
|
16864
|
-
if (x < 3.75) return x * _horner(b1_a, x * x /
|
|
17040
|
+
if (x < 3.75) return x * _horner(b1_a, x * x / 14.0625);
|
|
16865
17041
|
return (x < 0 ? -1 : 1) * Math.exp(Math.abs(x)) / Math.sqrt(Math.abs(x)) * _horner(b1_b, 3.75 / Math.abs(x));
|
|
16866
17042
|
}
|
|
16867
17043
|
return function besseli(x, n) {
|
|
@@ -17081,22 +17257,9 @@ function calculateMdeterm(matrix) {
|
|
|
17081
17257
|
return det === 0 ? 0 : det;
|
|
17082
17258
|
}
|
|
17083
17259
|
function calculateMinverse(matrix) {
|
|
17084
|
-
const
|
|
17085
|
-
if (
|
|
17086
|
-
|
|
17087
|
-
return adjoint(matrix).map((row) => row.map((value) => value / det));
|
|
17088
|
-
}
|
|
17089
|
-
function minor(matrix, row, col) {
|
|
17090
|
-
return matrix.filter((_, r) => r !== row).map((row) => row.filter((_, c) => c !== col));
|
|
17091
|
-
}
|
|
17092
|
-
function adjoint(matrix) {
|
|
17093
|
-
const n = matrix.length;
|
|
17094
|
-
const adj = Array.from({ length: n }, () => new Array(n).fill(0));
|
|
17095
|
-
for (let i = 0; i < n; i++) for (let j = 0; j < n; j++) {
|
|
17096
|
-
const res = ((i + j) % 2 === 0 ? 1 : -1) * calculateMdeterm(minor(matrix, i, j));
|
|
17097
|
-
adj[j][i] = res === 0 ? 0 : res;
|
|
17098
|
-
}
|
|
17099
|
-
return adj;
|
|
17260
|
+
const { smallPivotDetected, luMatrix, permutation } = performLUDecomposition(matrix, false, Number.EPSILON);
|
|
17261
|
+
if (smallPivotDetected) return null;
|
|
17262
|
+
return transformMatrix(luMatrix, permutation);
|
|
17100
17263
|
}
|
|
17101
17264
|
function calculateMmult(matrix1, matrix2) {
|
|
17102
17265
|
return matrix1.map((row) => matrix2[0].map((_, colIndex) => row.reduce((sum, element, rowIndex) => sum + element * matrix2[rowIndex][colIndex], 0)));
|
|
@@ -17109,8 +17272,8 @@ function inverseMatrixByLUD(matrix) {
|
|
|
17109
17272
|
if (smallPivotDetected) return null;
|
|
17110
17273
|
return transformMatrix(luMatrix, permutation);
|
|
17111
17274
|
}
|
|
17112
|
-
function performLUDecomposition(matrix) {
|
|
17113
|
-
const decomposedMatrix = matrixTranspose(matrix);
|
|
17275
|
+
function performLUDecomposition(matrix, transpose = true, minimumPivot = 1e-11) {
|
|
17276
|
+
const decomposedMatrix = transpose ? matrixTranspose(matrix) : matrix.map((row) => [...row]);
|
|
17114
17277
|
const numRows = decomposedMatrix.length;
|
|
17115
17278
|
const numCols = decomposedMatrix[0].length;
|
|
17116
17279
|
let isRowSwap = true;
|
|
@@ -17135,7 +17298,8 @@ function performLUDecomposition(matrix) {
|
|
|
17135
17298
|
pivotRow = r;
|
|
17136
17299
|
}
|
|
17137
17300
|
}
|
|
17138
|
-
|
|
17301
|
+
const pivot = Math.abs(luMatrix[pivotRow][c]);
|
|
17302
|
+
if (!Number.isFinite(pivot) || pivot <= minimumPivot) {
|
|
17139
17303
|
smallPivotDetected = true;
|
|
17140
17304
|
break;
|
|
17141
17305
|
}
|
|
@@ -18104,6 +18268,53 @@ function getSlopeAndInterceptOfConstbIsFalse(knownXsValues, knownYsValues) {
|
|
|
18104
18268
|
intercept: 0
|
|
18105
18269
|
};
|
|
18106
18270
|
}
|
|
18271
|
+
function solveLeastSquaresByQR(matrix, values) {
|
|
18272
|
+
var _matrix$;
|
|
18273
|
+
const rows = matrix.length;
|
|
18274
|
+
const columns = ((_matrix$ = matrix[0]) === null || _matrix$ === void 0 ? void 0 : _matrix$.length) ?? 0;
|
|
18275
|
+
if (!columns || rows < columns || values.length !== rows || matrix.some((row) => row.length !== columns)) return null;
|
|
18276
|
+
const qr = matrix.map((row) => [...row]);
|
|
18277
|
+
const scales = [];
|
|
18278
|
+
for (let column = 0; column < columns; column++) {
|
|
18279
|
+
let sumSquares = 0;
|
|
18280
|
+
for (let row = 0; row < rows; row++) sumSquares += qr[row][column] ** 2;
|
|
18281
|
+
const scale = Math.sqrt(sumSquares);
|
|
18282
|
+
if (!Number.isFinite(scale) || scale === 0) return null;
|
|
18283
|
+
scales.push(scale);
|
|
18284
|
+
for (let row = 0; row < rows; row++) qr[row][column] /= scale;
|
|
18285
|
+
}
|
|
18286
|
+
const transformed = [...values];
|
|
18287
|
+
for (let pivot = 0; pivot < columns; pivot++) {
|
|
18288
|
+
let sumSquares = 0;
|
|
18289
|
+
for (let row = pivot; row < rows; row++) sumSquares += qr[row][pivot] ** 2;
|
|
18290
|
+
const norm = Math.sqrt(sumSquares);
|
|
18291
|
+
if (!Number.isFinite(norm) || norm <= Number.EPSILON * rows) return null;
|
|
18292
|
+
const alpha = qr[pivot][pivot] >= 0 ? -norm : norm;
|
|
18293
|
+
const reflector = Array.from({ length: rows - pivot }, (_, offset) => qr[pivot + offset][pivot]);
|
|
18294
|
+
reflector[0] -= alpha;
|
|
18295
|
+
const reflectorNorm = reflector.reduce((sum, value) => sum + value ** 2, 0);
|
|
18296
|
+
if (!Number.isFinite(reflectorNorm) || reflectorNorm === 0) return null;
|
|
18297
|
+
for (let column = pivot; column < columns; column++) {
|
|
18298
|
+
let projection = 0;
|
|
18299
|
+
for (let offset = 0; offset < reflector.length; offset++) projection += reflector[offset] * qr[pivot + offset][column];
|
|
18300
|
+
const factor = 2 * projection / reflectorNorm;
|
|
18301
|
+
for (let offset = 0; offset < reflector.length; offset++) qr[pivot + offset][column] -= factor * reflector[offset];
|
|
18302
|
+
}
|
|
18303
|
+
let projection = 0;
|
|
18304
|
+
for (let offset = 0; offset < reflector.length; offset++) projection += reflector[offset] * transformed[pivot + offset];
|
|
18305
|
+
const factor = 2 * projection / reflectorNorm;
|
|
18306
|
+
for (let offset = 0; offset < reflector.length; offset++) transformed[pivot + offset] -= factor * reflector[offset];
|
|
18307
|
+
}
|
|
18308
|
+
const coefficients = new Array(columns).fill(0);
|
|
18309
|
+
for (let row = columns - 1; row >= 0; row--) {
|
|
18310
|
+
const diagonal = qr[row][row];
|
|
18311
|
+
if (!Number.isFinite(diagonal) || Math.abs(diagonal) <= Number.EPSILON * rows) return null;
|
|
18312
|
+
let remainder = 0;
|
|
18313
|
+
for (let column = row + 1; column < columns; column++) remainder += qr[row][column] * coefficients[column];
|
|
18314
|
+
coefficients[row] = (transformed[row] - remainder) / diagonal;
|
|
18315
|
+
}
|
|
18316
|
+
return coefficients.map((coefficient, index) => coefficient / scales[index]);
|
|
18317
|
+
}
|
|
18107
18318
|
function getKnownsArrayCoefficients(knownYsValues, knownXsValues, newXsValues, constb, isExponentialTransform) {
|
|
18108
18319
|
const isOneRow = knownYsValues.length === 1 && knownYsValues[0].length > 1;
|
|
18109
18320
|
let Y = knownYsValues;
|
|
@@ -18118,15 +18329,14 @@ function getKnownsArrayCoefficients(knownYsValues, knownXsValues, newXsValues, c
|
|
|
18118
18329
|
if (constb) X = X.map((row) => [...row, 1]);
|
|
18119
18330
|
const XT = matrixTranspose(X);
|
|
18120
18331
|
const XTX = calculateMmult(XT, X);
|
|
18121
|
-
const XTY = calculateMmult(XT, Y);
|
|
18122
18332
|
let XTXInverse = inverseMatrixByLUD(XTX);
|
|
18123
18333
|
if (!XTXInverse) {
|
|
18124
18334
|
XTXInverse = inverseMatrixByUSV(XTX);
|
|
18125
18335
|
if (!XTXInverse) return ErrorValueObject.create("#N/A");
|
|
18126
18336
|
}
|
|
18127
|
-
|
|
18128
|
-
|
|
18129
|
-
|
|
18337
|
+
const solved = solveLeastSquaresByQR(X, Y.map((row) => row[0]));
|
|
18338
|
+
const coefficients = solved ? [solved] : matrixTranspose(calculateMmult(XTXInverse, calculateMmult(XT, Y)));
|
|
18339
|
+
if (!constb) coefficients[0].push(0);
|
|
18130
18340
|
const pop = coefficients[0].pop();
|
|
18131
18341
|
coefficients[0].reverse();
|
|
18132
18342
|
coefficients[0].push(pop);
|
|
@@ -18149,9 +18359,10 @@ function parseAggregateDataRefs(refs) {
|
|
|
18149
18359
|
let isError = false;
|
|
18150
18360
|
for (let i = 0; i < refs.length; i++) {
|
|
18151
18361
|
const ref = refs[i];
|
|
18152
|
-
if (ref.isReferenceObject())
|
|
18153
|
-
|
|
18154
|
-
|
|
18362
|
+
if (ref.isReferenceObject()) {
|
|
18363
|
+
if (ref.isMultiArea()) multiAreaRefs.push(ref);
|
|
18364
|
+
else normalRefs.push(ref);
|
|
18365
|
+
} else {
|
|
18155
18366
|
isError = true;
|
|
18156
18367
|
break;
|
|
18157
18368
|
}
|
|
@@ -18169,6 +18380,7 @@ function isRowHidden(rowData, rowIndex) {
|
|
|
18169
18380
|
}
|
|
18170
18381
|
const NESTED_AGGREGATE_FORMULA_CACHE = /* @__PURE__ */ new WeakMap();
|
|
18171
18382
|
function isNestedAggregateOrSubtotal(cellData, rowIndex, columnIndex, sheetId, unitId, formulaDataModel) {
|
|
18383
|
+
if (!cellData) return false;
|
|
18172
18384
|
const cellValue = cellData.getValue(rowIndex, columnIndex);
|
|
18173
18385
|
if (!(cellValue === null || cellValue === void 0 ? void 0 : cellValue.f) && !(cellValue === null || cellValue === void 0 ? void 0 : cellValue.si)) return false;
|
|
18174
18386
|
if (typeof cellValue.f === "string") return hasNestedAggregateFormula(cellValue.f);
|
|
@@ -19257,7 +19469,8 @@ var PercentileInc = class extends BaseFunction {
|
|
|
19257
19469
|
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(k);
|
|
19258
19470
|
if (isError) return errorObject;
|
|
19259
19471
|
const [kObject] = variants;
|
|
19260
|
-
|
|
19472
|
+
const kValue = +kObject.getValue();
|
|
19473
|
+
return getPercentileIncResult(array, kValue);
|
|
19261
19474
|
}
|
|
19262
19475
|
};
|
|
19263
19476
|
|
|
@@ -19295,8 +19508,10 @@ var PercentrankInc = class extends BaseFunction {
|
|
|
19295
19508
|
const significanceValue = Math.floor(+significanceObject.getValue());
|
|
19296
19509
|
const n = array.length;
|
|
19297
19510
|
if (n === 0 || xValue < array[0] || xValue > array[n - 1]) return ErrorValueObject.create("#N/A");
|
|
19298
|
-
if (n === 1)
|
|
19299
|
-
|
|
19511
|
+
if (n === 1) {
|
|
19512
|
+
if (xValue === array[0]) return NumberValueObject.create(1);
|
|
19513
|
+
else return ErrorValueObject.create("#N/A");
|
|
19514
|
+
}
|
|
19300
19515
|
let result = 0;
|
|
19301
19516
|
let match = false;
|
|
19302
19517
|
let i = 0;
|
|
@@ -19393,7 +19608,8 @@ var QuartileInc = class extends BaseFunction {
|
|
|
19393
19608
|
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(quart);
|
|
19394
19609
|
if (isError) return errorObject;
|
|
19395
19610
|
const [quartObject] = variants;
|
|
19396
|
-
|
|
19611
|
+
const quartValue = Math.floor(+quartObject.getValue());
|
|
19612
|
+
return getQuartileIncResult(array, quartValue);
|
|
19397
19613
|
}
|
|
19398
19614
|
};
|
|
19399
19615
|
|
|
@@ -19804,7 +20020,8 @@ var ZTest = class extends BaseFunction {
|
|
|
19804
20020
|
sigmaValue = Math.sqrt((sumSquare - 2 * mean * sum + n * mean ** 2) / (n - 1));
|
|
19805
20021
|
}
|
|
19806
20022
|
if (sigmaValue <= 0) return ErrorValueObject.create("#NUM!");
|
|
19807
|
-
const
|
|
20023
|
+
const z = (sum / n - xValue) / (sigmaValue / Math.sqrt(n));
|
|
20024
|
+
const result = 1 - normalCDF(z, 0, 1);
|
|
19808
20025
|
if (Number.isNaN(result) || !Number.isFinite(result)) return ErrorValueObject.create("#NUM!");
|
|
19809
20026
|
return NumberValueObject.create(result);
|
|
19810
20027
|
}
|
|
@@ -20072,7 +20289,8 @@ var Normsdist = class extends BaseFunction {
|
|
|
20072
20289
|
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(zObject);
|
|
20073
20290
|
if (isError) return errorObject;
|
|
20074
20291
|
const [_zObject] = variants;
|
|
20075
|
-
const
|
|
20292
|
+
const zValue = +_zObject.getValue();
|
|
20293
|
+
const result = normalCDF(zValue, 0, 1);
|
|
20076
20294
|
return NumberValueObject.create(result);
|
|
20077
20295
|
}
|
|
20078
20296
|
};
|
|
@@ -21009,8 +21227,10 @@ function getWeekendArray(weekend) {
|
|
|
21009
21227
|
if (!isValidWeekend(weekend)) return [];
|
|
21010
21228
|
if (typeof weekend === "string" && /^[0|1]{7}/.test(weekend)) {
|
|
21011
21229
|
const result = [];
|
|
21012
|
-
for (let i = 1; i <= weekend.length; i++) if (`${weekend[i - 1]}` === "1")
|
|
21013
|
-
|
|
21230
|
+
for (let i = 1; i <= weekend.length; i++) if (`${weekend[i - 1]}` === "1") {
|
|
21231
|
+
if (i === weekend.length) result.push(0);
|
|
21232
|
+
else result.push(i);
|
|
21233
|
+
}
|
|
21014
21234
|
return result;
|
|
21015
21235
|
}
|
|
21016
21236
|
return weekendNumberMap[Number(weekend)] || [];
|
|
@@ -21111,12 +21331,14 @@ function getDaysByNASD(startDateSerialNumber, endDateSerialNumber, dateSystem) {
|
|
|
21111
21331
|
if (startIsLastDayOfFebruary) startDay = 30;
|
|
21112
21332
|
else if (startDay === 31) startDay = 30;
|
|
21113
21333
|
if (endMonth === 2 && endDay === getDaysInMonth(endYear, endMonth - 1) && startIsLastDayOfFebruary) endDay = 30;
|
|
21114
|
-
else if (endDay === 31)
|
|
21115
|
-
|
|
21116
|
-
|
|
21117
|
-
|
|
21118
|
-
|
|
21119
|
-
|
|
21334
|
+
else if (endDay === 31) {
|
|
21335
|
+
if (startDay < 30) {
|
|
21336
|
+
endDateDate = excelSerialToDate(endDateSerialNumber + 1, dateSystem);
|
|
21337
|
+
endYear = endDateDate.getUTCFullYear();
|
|
21338
|
+
endMonth = endDateDate.getUTCMonth() + 1;
|
|
21339
|
+
endDay = endDateDate.getUTCDate();
|
|
21340
|
+
} else endDay = 30;
|
|
21341
|
+
}
|
|
21120
21342
|
const daysInYears = (endYear - startYear) * 360;
|
|
21121
21343
|
const daysInStartMonth = endDateSerialNumber >= startDateSerialNumber ? 30 - startDay : -startDay;
|
|
21122
21344
|
const daysInEndMonth = endDateSerialNumber >= startDateSerialNumber ? endDay : endDay - 30;
|
|
@@ -21280,7 +21502,8 @@ var DateFunction = class extends BaseFunction {
|
|
|
21280
21502
|
const dayValue = Math.floor(+_dayObject.getValue());
|
|
21281
21503
|
if (yearValue < 0 || yearValue > 9999) return ErrorValueObject.create("#NUM!");
|
|
21282
21504
|
if (yearValue >= 0 && yearValue < 1899) yearValue += 1900;
|
|
21283
|
-
const
|
|
21505
|
+
const firstDateOfMonth = new Date(Date.UTC(yearValue, monthValue - 1, 1));
|
|
21506
|
+
const currentSerial = excelDateSerial(firstDateOfMonth, this.getDateSystem()) + dayValue - 1;
|
|
21284
21507
|
if (currentSerial < 0) return ErrorValueObject.create("#NUM!");
|
|
21285
21508
|
return NumberValueObject.create(currentSerial, DEFAULT_DATE_FORMAT);
|
|
21286
21509
|
});
|
|
@@ -21489,7 +21712,8 @@ var Days360 = class extends BaseFunction {
|
|
|
21489
21712
|
if (typeof endDateSerialNumber !== "number") return endDateSerialNumber;
|
|
21490
21713
|
if (methodObject.isString()) methodObject = methodObject.convertToNumberObjectValue();
|
|
21491
21714
|
if (methodObject.isError()) return methodObject;
|
|
21492
|
-
const
|
|
21715
|
+
const methodValue = +methodObject.getValue();
|
|
21716
|
+
const { days } = getTwoDateDaysByBasis(startDateSerialNumber, endDateSerialNumber, !methodValue ? 0 : 4, this.getDateSystem());
|
|
21493
21717
|
const result = endDateSerialNumber >= startDateSerialNumber ? days : -days;
|
|
21494
21718
|
return NumberValueObject.create(result);
|
|
21495
21719
|
});
|
|
@@ -21529,7 +21753,8 @@ var Edate = class extends BaseFunction {
|
|
|
21529
21753
|
const month = _startDate.getUTCMonth() + monthsValue;
|
|
21530
21754
|
const day = _startDate.getUTCDate();
|
|
21531
21755
|
const lastDayOfTargetMonth = new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
|
|
21532
|
-
const
|
|
21756
|
+
const resultDate = new Date(Date.UTC(year, month, Math.min(day, lastDayOfTargetMonth)));
|
|
21757
|
+
const currentSerial = excelDateSerial(resultDate, this.getDateSystem());
|
|
21533
21758
|
return NumberValueObject.create(currentSerial, DEFAULT_DATE_FORMAT);
|
|
21534
21759
|
});
|
|
21535
21760
|
}
|
|
@@ -21569,7 +21794,8 @@ var Eomonth = class extends BaseFunction {
|
|
|
21569
21794
|
const startMonth = isDate1900SerialZero ? 0 : startDateDate.getUTCMonth();
|
|
21570
21795
|
const monthsValue = Math.floor(+_months.getValue());
|
|
21571
21796
|
if (Number.isNaN(monthsValue)) return ErrorValueObject.create("#VALUE!");
|
|
21572
|
-
const
|
|
21797
|
+
const targetDate = new Date(Date.UTC(startYear, startMonth + monthsValue + 1, 0));
|
|
21798
|
+
const result = excelDateSerial(targetDate, this.getDateSystem());
|
|
21573
21799
|
return NumberValueObject.create(result);
|
|
21574
21800
|
}
|
|
21575
21801
|
};
|
|
@@ -21934,7 +22160,8 @@ var Now = class extends BaseFunction {
|
|
|
21934
22160
|
}
|
|
21935
22161
|
calculate() {
|
|
21936
22162
|
const now = /* @__PURE__ */ new Date();
|
|
21937
|
-
const
|
|
22163
|
+
const utcNow = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds()));
|
|
22164
|
+
const currentSerial = excelDateTimeSerial(utcNow, this.getDateSystem());
|
|
21938
22165
|
return NumberValueObject.create(currentSerial, DEFAULT_NOW_FORMAT);
|
|
21939
22166
|
}
|
|
21940
22167
|
};
|
|
@@ -22027,7 +22254,8 @@ var Timevalue = class extends BaseFunction {
|
|
|
22027
22254
|
_handleSingleObject(timeTextObject) {
|
|
22028
22255
|
if (timeTextObject.isError()) return timeTextObject;
|
|
22029
22256
|
if (timeTextObject.isString()) {
|
|
22030
|
-
const
|
|
22257
|
+
const value = `${timeTextObject.getValue()}`;
|
|
22258
|
+
const parsedTime = getNumfmtParseValueFilter(value, { dateSystem: this.getDateSystem() });
|
|
22031
22259
|
if (parsedTime) {
|
|
22032
22260
|
let { v, z } = parsedTime;
|
|
22033
22261
|
if (z && isDate(z)) {
|
|
@@ -22091,7 +22319,8 @@ var Today = class extends BaseFunction {
|
|
|
22091
22319
|
}
|
|
22092
22320
|
calculate() {
|
|
22093
22321
|
const now = /* @__PURE__ */ new Date();
|
|
22094
|
-
const
|
|
22322
|
+
const utcNow = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()));
|
|
22323
|
+
const currentSerial = excelDateSerial(utcNow, this.getDateSystem());
|
|
22095
22324
|
return NumberValueObject.create(currentSerial, DEFAULT_DATE_FORMAT);
|
|
22096
22325
|
}
|
|
22097
22326
|
};
|
|
@@ -22992,13 +23221,15 @@ var Complex$1 = class Complex$1 {
|
|
|
22992
23221
|
this._isError = true;
|
|
22993
23222
|
return;
|
|
22994
23223
|
}
|
|
22995
|
-
if (plus >= 0)
|
|
22996
|
-
|
|
22997
|
-
|
|
23224
|
+
if (plus >= 0) {
|
|
23225
|
+
if (Number.isNaN(+inumberStr.substring(0, plus)) || Number.isNaN(+inumberStr.substring(plus + 1, inumberStr.length - 1))) this._isError = true;
|
|
23226
|
+
else this._realNum = +inumberStr.substring(0, plus);
|
|
23227
|
+
} else if (Number.isNaN(+inumberStr.substring(0, minus)) || Number.isNaN(+inumberStr.substring(minus + 1, inumberStr.length - 1))) this._isError = true;
|
|
22998
23228
|
else this._realNum = +inumberStr.substring(0, minus);
|
|
22999
|
-
} else if (unit)
|
|
23000
|
-
|
|
23001
|
-
|
|
23229
|
+
} else if (unit) {
|
|
23230
|
+
if (Number.isNaN(+inumberStr.substring(0, inumberStr.length - 1))) this._isError = true;
|
|
23231
|
+
else this._realNum = 0;
|
|
23232
|
+
} else if (Number.isNaN(+inumberStr)) this._isError = true;
|
|
23002
23233
|
else this._realNum = +inumberStr;
|
|
23003
23234
|
}
|
|
23004
23235
|
_getImAginary() {
|
|
@@ -23024,13 +23255,15 @@ var Complex$1 = class Complex$1 {
|
|
|
23024
23255
|
this._isError = true;
|
|
23025
23256
|
return;
|
|
23026
23257
|
}
|
|
23027
|
-
if (plus >= 0)
|
|
23028
|
-
|
|
23029
|
-
|
|
23258
|
+
if (plus >= 0) {
|
|
23259
|
+
if (Number.isNaN(+inumberStr.substring(0, plus)) || Number.isNaN(+inumberStr.substring(plus + 1, inumberStr.length - 1))) this._isError = true;
|
|
23260
|
+
else this._iNum = +inumberStr.substring(plus + 1, inumberStr.length - 1);
|
|
23261
|
+
} else if (Number.isNaN(+inumberStr.substring(0, minus)) || Number.isNaN(+inumberStr.substring(minus + 1, inumberStr.length - 1))) this._isError = true;
|
|
23030
23262
|
else this._iNum = -+inumberStr.substring(minus + 1, inumberStr.length - 1);
|
|
23031
|
-
} else if (unit)
|
|
23032
|
-
|
|
23033
|
-
|
|
23263
|
+
} else if (unit) {
|
|
23264
|
+
if (Number.isNaN(+inumberStr.substring(0, inumberStr.length - 1))) this._isError = true;
|
|
23265
|
+
else this._iNum = +inumberStr.substring(0, inumberStr.length - 1);
|
|
23266
|
+
} else if (Number.isNaN(+inumberStr)) this._isError = true;
|
|
23034
23267
|
else this._iNum = 0;
|
|
23035
23268
|
}
|
|
23036
23269
|
_getImSuffix() {
|
|
@@ -23186,10 +23419,12 @@ var Complex$1 = class Complex$1 {
|
|
|
23186
23419
|
return Complex$1.getComplex(realNum, iNum, this._suffix);
|
|
23187
23420
|
}
|
|
23188
23421
|
Power(number) {
|
|
23189
|
-
if (this._realNum === 0 && this._iNum === 0)
|
|
23190
|
-
|
|
23191
|
-
|
|
23192
|
-
|
|
23422
|
+
if (this._realNum === 0 && this._iNum === 0) {
|
|
23423
|
+
if (number > 0) return Complex$1.getComplex(this._realNum, this._iNum, this._suffix);
|
|
23424
|
+
else {
|
|
23425
|
+
this._isError = true;
|
|
23426
|
+
return "";
|
|
23427
|
+
}
|
|
23193
23428
|
}
|
|
23194
23429
|
let power = Decimal.sqrt(Decimal.pow(this._realNum, 2).add(Decimal.pow(this._iNum, 2)));
|
|
23195
23430
|
let phi = Decimal.acos(new Decimal(this._realNum).div(power));
|
|
@@ -23327,7 +23562,8 @@ var Complex = class extends BaseFunction {
|
|
|
23327
23562
|
_defineProperty(this, "maxParams", 3);
|
|
23328
23563
|
}
|
|
23329
23564
|
calculate(realNum, iNum, suffix) {
|
|
23330
|
-
const
|
|
23565
|
+
const _suffix = suffix ?? StringValueObject.create("i");
|
|
23566
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(realNum, iNum, _suffix);
|
|
23331
23567
|
if (isError) return errorObject;
|
|
23332
23568
|
const [realNumObject, iNumObject, suffixObject] = variants;
|
|
23333
23569
|
const realNumValue = +realNumObject.getValue();
|
|
@@ -24869,10 +25105,8 @@ var Convert = class extends BaseFunction {
|
|
|
24869
25105
|
if (from === null || to === null) return ErrorValueObject.create("#N/A");
|
|
24870
25106
|
if (from[3] !== to[3]) return ErrorValueObject.create("#N/A");
|
|
24871
25107
|
let result;
|
|
24872
|
-
if (from[3] === "temperature")
|
|
24873
|
-
|
|
24874
|
-
result = +result.toFixed(2);
|
|
24875
|
-
} else result = numberValue * from[6] * fromMultiplier / (to[6] * toMultiplier);
|
|
25108
|
+
if (from[3] === "temperature") result = this._getTemperatureConversion(numberValue, from[1], to[1]);
|
|
25109
|
+
else result = numberValue * from[6] * fromMultiplier / (to[6] * toMultiplier);
|
|
24876
25110
|
return NumberValueObject.create(result);
|
|
24877
25111
|
}
|
|
24878
25112
|
_lookupFromAndToUnits(fromUnitValue, toUnitValue) {
|
|
@@ -25127,7 +25361,8 @@ var Delta = class extends BaseFunction {
|
|
|
25127
25361
|
_defineProperty(this, "maxParams", 2);
|
|
25128
25362
|
}
|
|
25129
25363
|
calculate(number1, number2) {
|
|
25130
|
-
const
|
|
25364
|
+
const _number2 = number2 ?? NumberValueObject.create(0);
|
|
25365
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(number1, _number2);
|
|
25131
25366
|
if (isError) return errorObject;
|
|
25132
25367
|
const [number1Object, number2Object] = variants;
|
|
25133
25368
|
const number1Value = +number1Object.getValue();
|
|
@@ -25235,7 +25470,8 @@ var Gestep = class extends BaseFunction {
|
|
|
25235
25470
|
}
|
|
25236
25471
|
calculate(number, step) {
|
|
25237
25472
|
if (number.isNull()) return ErrorValueObject.create("#N/A");
|
|
25238
|
-
const
|
|
25473
|
+
const _step = step ?? NumberValueObject.create(0);
|
|
25474
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(number, _step);
|
|
25239
25475
|
if (isError) return errorObject;
|
|
25240
25476
|
const [numberObject, stepObject] = variants;
|
|
25241
25477
|
const numberValue = +numberObject.getValue();
|
|
@@ -25359,7 +25595,8 @@ var Imabs = class extends BaseFunction {
|
|
|
25359
25595
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25360
25596
|
if (isError) return errorObject;
|
|
25361
25597
|
const [inumberObject] = variants;
|
|
25362
|
-
const
|
|
25598
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25599
|
+
const complex = new Complex$1(inumberValue);
|
|
25363
25600
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25364
25601
|
const result = complex.Abs();
|
|
25365
25602
|
return NumberValueObject.create(result);
|
|
@@ -25378,7 +25615,8 @@ var Imaginary = class extends BaseFunction {
|
|
|
25378
25615
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25379
25616
|
if (isError) return errorObject;
|
|
25380
25617
|
const [inumberObject] = variants;
|
|
25381
|
-
const
|
|
25618
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25619
|
+
const complex = new Complex$1(inumberValue);
|
|
25382
25620
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25383
25621
|
const result = complex.getINum();
|
|
25384
25622
|
return NumberValueObject.create(result);
|
|
@@ -25397,7 +25635,8 @@ var Imargument = class extends BaseFunction {
|
|
|
25397
25635
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25398
25636
|
if (isError) return errorObject;
|
|
25399
25637
|
const [inumberObject] = variants;
|
|
25400
|
-
const
|
|
25638
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25639
|
+
const complex = new Complex$1(inumberValue);
|
|
25401
25640
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25402
25641
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return ErrorValueObject.create("#DIV/0!");
|
|
25403
25642
|
const result = complex.Argument();
|
|
@@ -25417,7 +25656,8 @@ var Imconjugate = class extends BaseFunction {
|
|
|
25417
25656
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25418
25657
|
if (isError) return errorObject;
|
|
25419
25658
|
const [inumberObject] = variants;
|
|
25420
|
-
const
|
|
25659
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25660
|
+
const complex = new Complex$1(inumberValue);
|
|
25421
25661
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25422
25662
|
const result = complex.Conjugate();
|
|
25423
25663
|
if (typeof result === "number" || isRealNum(result)) return NumberValueObject.create(+result);
|
|
@@ -25437,7 +25677,8 @@ var Imcos = class extends BaseFunction {
|
|
|
25437
25677
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25438
25678
|
if (isError) return errorObject;
|
|
25439
25679
|
const [inumberObject] = variants;
|
|
25440
|
-
const
|
|
25680
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25681
|
+
const complex = new Complex$1(inumberValue);
|
|
25441
25682
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25442
25683
|
const result = complex.Cos();
|
|
25443
25684
|
if (typeof result === "number" || isRealNum(result)) return NumberValueObject.create(+result);
|
|
@@ -25457,7 +25698,8 @@ var Imcosh = class extends BaseFunction {
|
|
|
25457
25698
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25458
25699
|
if (isError) return errorObject;
|
|
25459
25700
|
const [inumberObject] = variants;
|
|
25460
|
-
const
|
|
25701
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25702
|
+
const complex = new Complex$1(inumberValue);
|
|
25461
25703
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25462
25704
|
const result = complex.Cosh();
|
|
25463
25705
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
@@ -25478,7 +25720,8 @@ var Imcot = class extends BaseFunction {
|
|
|
25478
25720
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25479
25721
|
if (isError) return errorObject;
|
|
25480
25722
|
const [inumberObject] = variants;
|
|
25481
|
-
const
|
|
25723
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25724
|
+
const complex = new Complex$1(inumberValue);
|
|
25482
25725
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25483
25726
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return ErrorValueObject.create("#NUM!");
|
|
25484
25727
|
const result = complex.Cot();
|
|
@@ -25499,7 +25742,8 @@ var Imcoth = class extends BaseFunction {
|
|
|
25499
25742
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25500
25743
|
if (isError) return errorObject;
|
|
25501
25744
|
const [inumberObject] = variants;
|
|
25502
|
-
const
|
|
25745
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25746
|
+
const complex = new Complex$1(inumberValue);
|
|
25503
25747
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25504
25748
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return ErrorValueObject.create("#NUM!");
|
|
25505
25749
|
const result = complex.Coth();
|
|
@@ -25521,7 +25765,8 @@ var Imcsc = class extends BaseFunction {
|
|
|
25521
25765
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25522
25766
|
if (isError) return errorObject;
|
|
25523
25767
|
const [inumberObject] = variants;
|
|
25524
|
-
const
|
|
25768
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25769
|
+
const complex = new Complex$1(inumberValue);
|
|
25525
25770
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25526
25771
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return ErrorValueObject.create("#NUM!");
|
|
25527
25772
|
const result = complex.Csc();
|
|
@@ -25542,7 +25787,8 @@ var Imcsch = class extends BaseFunction {
|
|
|
25542
25787
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25543
25788
|
if (isError) return errorObject;
|
|
25544
25789
|
const [inumberObject] = variants;
|
|
25545
|
-
const
|
|
25790
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25791
|
+
const complex = new Complex$1(inumberValue);
|
|
25546
25792
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25547
25793
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return ErrorValueObject.create("#NUM!");
|
|
25548
25794
|
const result = complex.Csch();
|
|
@@ -25589,7 +25835,8 @@ var Imexp = class extends BaseFunction {
|
|
|
25589
25835
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25590
25836
|
if (isError) return errorObject;
|
|
25591
25837
|
const [inumberObject] = variants;
|
|
25592
|
-
const
|
|
25838
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25839
|
+
const complex = new Complex$1(inumberValue);
|
|
25593
25840
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25594
25841
|
const result = complex.Exp();
|
|
25595
25842
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
@@ -25610,7 +25857,8 @@ var Imln = class extends BaseFunction {
|
|
|
25610
25857
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25611
25858
|
if (isError) return errorObject;
|
|
25612
25859
|
const [inumberObject] = variants;
|
|
25613
|
-
const
|
|
25860
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25861
|
+
const complex = new Complex$1(inumberValue);
|
|
25614
25862
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25615
25863
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return ErrorValueObject.create("#NUM!");
|
|
25616
25864
|
const result = complex.Ln();
|
|
@@ -25666,7 +25914,8 @@ var Imlog2 = class extends BaseFunction {
|
|
|
25666
25914
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25667
25915
|
if (isError) return errorObject;
|
|
25668
25916
|
const [inumberObject] = variants;
|
|
25669
|
-
const
|
|
25917
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25918
|
+
const complex = new Complex$1(inumberValue);
|
|
25670
25919
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25671
25920
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return ErrorValueObject.create("#NUM!");
|
|
25672
25921
|
const result = complex.Log(2);
|
|
@@ -25687,7 +25936,8 @@ var Imlog10 = class extends BaseFunction {
|
|
|
25687
25936
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25688
25937
|
if (isError) return errorObject;
|
|
25689
25938
|
const [inumberObject] = variants;
|
|
25690
|
-
const
|
|
25939
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25940
|
+
const complex = new Complex$1(inumberValue);
|
|
25691
25941
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25692
25942
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return ErrorValueObject.create("#NUM!");
|
|
25693
25943
|
const result = complex.Log(10);
|
|
@@ -25709,7 +25959,8 @@ var Impower = class extends BaseFunction {
|
|
|
25709
25959
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber, number);
|
|
25710
25960
|
if (isError) return errorObject;
|
|
25711
25961
|
const [inumberObject, numberObject] = variants;
|
|
25712
|
-
const
|
|
25962
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
25963
|
+
const complex = new Complex$1(inumberValue);
|
|
25713
25964
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25714
25965
|
const numberValue = +numberObject.getValue();
|
|
25715
25966
|
if (Number.isNaN(numberValue)) return ErrorValueObject.create("#VALUE!");
|
|
@@ -25783,7 +26034,8 @@ var Imreal = class extends BaseFunction {
|
|
|
25783
26034
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25784
26035
|
if (isError) return errorObject;
|
|
25785
26036
|
const [inumberObject] = variants;
|
|
25786
|
-
const
|
|
26037
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
26038
|
+
const complex = new Complex$1(inumberValue);
|
|
25787
26039
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25788
26040
|
const result = complex.getRealNum();
|
|
25789
26041
|
return NumberValueObject.create(result);
|
|
@@ -25802,7 +26054,8 @@ var Imsec = class extends BaseFunction {
|
|
|
25802
26054
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25803
26055
|
if (isError) return errorObject;
|
|
25804
26056
|
const [inumberObject] = variants;
|
|
25805
|
-
const
|
|
26057
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
26058
|
+
const complex = new Complex$1(inumberValue);
|
|
25806
26059
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25807
26060
|
const result = complex.Sec();
|
|
25808
26061
|
if (typeof result === "number" || isRealNum(result)) return NumberValueObject.create(+result);
|
|
@@ -25822,7 +26075,8 @@ var Imsech = class extends BaseFunction {
|
|
|
25822
26075
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25823
26076
|
if (isError) return errorObject;
|
|
25824
26077
|
const [inumberObject] = variants;
|
|
25825
|
-
const
|
|
26078
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
26079
|
+
const complex = new Complex$1(inumberValue);
|
|
25826
26080
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25827
26081
|
const result = complex.Sech();
|
|
25828
26082
|
if (typeof result === "number" || isRealNum(result)) return NumberValueObject.create(+result);
|
|
@@ -25842,7 +26096,8 @@ var Imsin = class extends BaseFunction {
|
|
|
25842
26096
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25843
26097
|
if (isError) return errorObject;
|
|
25844
26098
|
const [inumberObject] = variants;
|
|
25845
|
-
const
|
|
26099
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
26100
|
+
const complex = new Complex$1(inumberValue);
|
|
25846
26101
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25847
26102
|
const result = complex.Sin();
|
|
25848
26103
|
if (typeof result === "number" || isRealNum(result)) return NumberValueObject.create(+result);
|
|
@@ -25862,7 +26117,8 @@ var Imsinh = class extends BaseFunction {
|
|
|
25862
26117
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25863
26118
|
if (isError) return errorObject;
|
|
25864
26119
|
const [inumberObject] = variants;
|
|
25865
|
-
const
|
|
26120
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
26121
|
+
const complex = new Complex$1(inumberValue);
|
|
25866
26122
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25867
26123
|
const result = complex.Sinh();
|
|
25868
26124
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
@@ -25883,7 +26139,8 @@ var Imsqrt = class extends BaseFunction {
|
|
|
25883
26139
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25884
26140
|
if (isError) return errorObject;
|
|
25885
26141
|
const [inumberObject] = variants;
|
|
25886
|
-
const
|
|
26142
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
26143
|
+
const complex = new Complex$1(inumberValue);
|
|
25887
26144
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25888
26145
|
if (complex.getRealNum() === 0 && complex.getINum() === 0) return NumberValueObject.create(0);
|
|
25889
26146
|
const result = complex.Sqrt();
|
|
@@ -25980,7 +26237,8 @@ var Imtan = class extends BaseFunction {
|
|
|
25980
26237
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25981
26238
|
if (isError) return errorObject;
|
|
25982
26239
|
const [inumberObject] = variants;
|
|
25983
|
-
const
|
|
26240
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
26241
|
+
const complex = new Complex$1(inumberValue);
|
|
25984
26242
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
25985
26243
|
const result = complex.Tan();
|
|
25986
26244
|
if (typeof result === "number" || isRealNum(result)) return NumberValueObject.create(+result);
|
|
@@ -26000,7 +26258,8 @@ var Imtanh = class extends BaseFunction {
|
|
|
26000
26258
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
26001
26259
|
if (isError) return errorObject;
|
|
26002
26260
|
const [inumberObject] = variants;
|
|
26003
|
-
const
|
|
26261
|
+
const inumberValue = `${inumberObject.getValue()}`;
|
|
26262
|
+
const complex = new Complex$1(inumberValue);
|
|
26004
26263
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
26005
26264
|
const result = complex.Tanh();
|
|
26006
26265
|
if (complex.isError()) return ErrorValueObject.create("#NUM!");
|
|
@@ -26285,7 +26544,8 @@ function getCouponSchedule(settlementSerialNumber, maturitySerialNumber, frequen
|
|
|
26285
26544
|
};
|
|
26286
26545
|
}
|
|
26287
26546
|
function calculateCoupdaybs(settlementSerialNumber, maturitySerialNumber, frequency, basis, dateSystem = DateSystem.Date1900) {
|
|
26288
|
-
const
|
|
26547
|
+
const coupDateSerialNumber = calculateCouppcd(settlementSerialNumber, maturitySerialNumber, frequency, dateSystem);
|
|
26548
|
+
const { days } = getTwoDateDaysByBasis(coupDateSerialNumber, settlementSerialNumber, basis, dateSystem);
|
|
26289
26549
|
return days;
|
|
26290
26550
|
}
|
|
26291
26551
|
function calculateCoupdays(settlementSerialNumber, maturitySerialNumber, frequency, basis, dateSystem = DateSystem.Date1900) {
|
|
@@ -26382,7 +26642,8 @@ function calculateOddLongFirstCoupon(settlementSerialNumber, maturitySerialNumbe
|
|
|
26382
26642
|
let DSC;
|
|
26383
26643
|
if (basis === 2 || basis === 3) DSC = getPositiveDaysBetween(settlementSerialNumber, calculateCoupncd(settlementSerialNumber, firstCouponSerialNumber, frequency, dateSystem), basis, dateSystem);
|
|
26384
26644
|
else {
|
|
26385
|
-
const
|
|
26645
|
+
const couppcd = calculateCouppcd(settlementSerialNumber, firstCouponSerialNumber, frequency, dateSystem);
|
|
26646
|
+
const { days } = getTwoDateDaysByBasis(couppcd, settlementSerialNumber, basis, dateSystem);
|
|
26386
26647
|
DSC = E - days;
|
|
26387
26648
|
}
|
|
26388
26649
|
result += redemption / (1 + yld / frequency) ** (N + Nq + DSC / E);
|
|
@@ -26430,7 +26691,9 @@ function getDateSerialNumberByMonths(serialNumber, months, returnLastDay, dateSy
|
|
|
26430
26691
|
let date = excelSerialToDate(serialNumber, dateSystem);
|
|
26431
26692
|
date = dateAddMonths(date, months);
|
|
26432
26693
|
if (returnLastDay) {
|
|
26433
|
-
const
|
|
26694
|
+
const year = date.getUTCFullYear();
|
|
26695
|
+
const month = date.getUTCMonth();
|
|
26696
|
+
const daysInMonth = getDaysInMonth(year, month);
|
|
26434
26697
|
date.setUTCDate(daysInMonth);
|
|
26435
26698
|
}
|
|
26436
26699
|
return excelDateSerial(date, dateSystem);
|
|
@@ -26495,7 +26758,7 @@ function guessIsNaNorInfinity(guess, iterF) {
|
|
|
26495
26758
|
low = xBegin + step * (xBegin - xEnd);
|
|
26496
26759
|
high = xEnd + step * (xEnd - xBegin);
|
|
26497
26760
|
} else return ErrorValueObject.create("#NUM!");
|
|
26498
|
-
if (i ===
|
|
26761
|
+
if (i === 59) return ErrorValueObject.create("#NUM!");
|
|
26499
26762
|
}
|
|
26500
26763
|
xBegin = xBegin;
|
|
26501
26764
|
xEnd = xEnd;
|
|
@@ -26587,7 +26850,10 @@ var Accrint = class extends BaseFunction {
|
|
|
26587
26850
|
const couppcd = calculateCouppcd(settlementSerialNumber, firstInterestSerialNumber, frequencyValue, this.getDateSystem());
|
|
26588
26851
|
const numMonths = 12 / frequencyValue;
|
|
26589
26852
|
const firstInterestDate = excelSerialToDate(firstInterestSerialNumber, this.getDateSystem());
|
|
26590
|
-
const
|
|
26853
|
+
const firstInterestDateYear = firstInterestDate.getUTCFullYear();
|
|
26854
|
+
const firstInterestDateMonth = firstInterestDate.getUTCMonth();
|
|
26855
|
+
const firstInterestDateDay = firstInterestDate.getUTCDate();
|
|
26856
|
+
const lastDayOfMonthF = lastDayOfMonth(firstInterestDateYear, firstInterestDateMonth, firstInterestDateDay);
|
|
26591
26857
|
let coupDateSerialNumber = getDateSerialNumberByMonths(firstInterestSerialNumber, -numMonths, lastDayOfMonthF, this.getDateSystem());
|
|
26592
26858
|
const startsAtFirstCoupon = issueSerialNumber === 0 && issueCouppcd === 0;
|
|
26593
26859
|
if (settlementSerialNumber > firstInterestSerialNumber && calcMethodValue) {
|
|
@@ -26638,7 +26904,8 @@ var Accrintm = class extends BaseFunction {
|
|
|
26638
26904
|
_defineProperty(this, "maxParams", 5);
|
|
26639
26905
|
}
|
|
26640
26906
|
calculate(issue, settlement, rate, par, basis) {
|
|
26641
|
-
const
|
|
26907
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
26908
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(issue, settlement, rate, par, _basis);
|
|
26642
26909
|
if (isError) return errorObject;
|
|
26643
26910
|
const [issueObject, settlementObject, rateObject, parObject, basisObject] = variants;
|
|
26644
26911
|
const issueSerialNumber = getDateSerialNumberByObject(issueObject, this.getDateSystem());
|
|
@@ -26666,7 +26933,8 @@ var Amorlinc = class extends BaseFunction {
|
|
|
26666
26933
|
_defineProperty(this, "maxParams", 7);
|
|
26667
26934
|
}
|
|
26668
26935
|
calculate(cost, datePurchased, firstPeriod, salvage, period, rate, basis) {
|
|
26669
|
-
const
|
|
26936
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
26937
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(cost, datePurchased, firstPeriod, salvage, period, rate, _basis);
|
|
26670
26938
|
if (isError) return errorObject;
|
|
26671
26939
|
const [costObject, datePurchasedObject, firstPeriodObject, salvageObject, periodObject, rateObject, basisObject] = variants;
|
|
26672
26940
|
const datePurchasedSerialNumber = getDateSerialNumberByObject(datePurchasedObject, this.getDateSystem());
|
|
@@ -26713,7 +26981,8 @@ var Coupdaybs = class extends BaseFunction {
|
|
|
26713
26981
|
_defineProperty(this, "maxParams", 4);
|
|
26714
26982
|
}
|
|
26715
26983
|
calculate(settlement, maturity, frequency, basis) {
|
|
26716
|
-
const
|
|
26984
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
26985
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, _basis);
|
|
26717
26986
|
if (isError) return errorObject;
|
|
26718
26987
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26719
26988
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject, this.getDateSystem());
|
|
@@ -26743,7 +27012,8 @@ var Coupdays = class extends BaseFunction {
|
|
|
26743
27012
|
_defineProperty(this, "maxParams", 4);
|
|
26744
27013
|
}
|
|
26745
27014
|
calculate(settlement, maturity, frequency, basis) {
|
|
26746
|
-
const
|
|
27015
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
27016
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, _basis);
|
|
26747
27017
|
if (isError) return errorObject;
|
|
26748
27018
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26749
27019
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject, this.getDateSystem());
|
|
@@ -26772,7 +27042,8 @@ var Coupdaysnc = class extends BaseFunction {
|
|
|
26772
27042
|
_defineProperty(this, "maxParams", 4);
|
|
26773
27043
|
}
|
|
26774
27044
|
calculate(settlement, maturity, frequency, basis) {
|
|
26775
|
-
const
|
|
27045
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
27046
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, _basis);
|
|
26776
27047
|
if (isError) return errorObject;
|
|
26777
27048
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26778
27049
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject, this.getDateSystem());
|
|
@@ -26787,7 +27058,8 @@ var Coupdaysnc = class extends BaseFunction {
|
|
|
26787
27058
|
2,
|
|
26788
27059
|
4
|
|
26789
27060
|
].includes(frequencyValue) || basisValue < 0 || basisValue > 4 || Math.floor(settlementSerialNumber) >= Math.floor(maturitySerialNumber)) return ErrorValueObject.create("#NUM!");
|
|
26790
|
-
const
|
|
27061
|
+
const coupDateSerialNumber = calculateCoupncd(settlementSerialNumber, maturitySerialNumber, frequencyValue, this.getDateSystem());
|
|
27062
|
+
const { days } = getTwoDateDaysByBasis(settlementSerialNumber, coupDateSerialNumber, basisValue, this.getDateSystem());
|
|
26791
27063
|
return NumberValueObject.create(days);
|
|
26792
27064
|
}
|
|
26793
27065
|
};
|
|
@@ -26801,7 +27073,8 @@ var Coupncd = class extends BaseFunction {
|
|
|
26801
27073
|
_defineProperty(this, "maxParams", 4);
|
|
26802
27074
|
}
|
|
26803
27075
|
calculate(settlement, maturity, frequency, basis) {
|
|
26804
|
-
const
|
|
27076
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
27077
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, _basis);
|
|
26805
27078
|
if (isError) return errorObject;
|
|
26806
27079
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26807
27080
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject, this.getDateSystem());
|
|
@@ -26830,7 +27103,8 @@ var Coupnum = class extends BaseFunction {
|
|
|
26830
27103
|
_defineProperty(this, "maxParams", 4);
|
|
26831
27104
|
}
|
|
26832
27105
|
calculate(settlement, maturity, frequency, basis) {
|
|
26833
|
-
const
|
|
27106
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
27107
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, _basis);
|
|
26834
27108
|
if (isError) return errorObject;
|
|
26835
27109
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26836
27110
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject, this.getDateSystem());
|
|
@@ -26861,7 +27135,8 @@ var Couppcd = class extends BaseFunction {
|
|
|
26861
27135
|
_defineProperty(this, "maxParams", 4);
|
|
26862
27136
|
}
|
|
26863
27137
|
calculate(settlement, maturity, frequency, basis) {
|
|
26864
|
-
const
|
|
27138
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
27139
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, _basis);
|
|
26865
27140
|
if (isError) return errorObject;
|
|
26866
27141
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26867
27142
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject, this.getDateSystem());
|
|
@@ -26985,7 +27260,11 @@ var Db = class extends BaseFunction {
|
|
|
26985
27260
|
const periodArray = expandArrayValueObject(maxRowLength, maxColumnLength, period, ErrorValueObject.create("#N/A"));
|
|
26986
27261
|
const monthArray = expandArrayValueObject(maxRowLength, maxColumnLength, _month, ErrorValueObject.create("#N/A"));
|
|
26987
27262
|
const resultArray = costArray.map((costObject, rowIndex, columnIndex) => {
|
|
26988
|
-
const
|
|
27263
|
+
const salvageObject = salvageArray.get(rowIndex, columnIndex);
|
|
27264
|
+
const lifeObject = lifeArray.get(rowIndex, columnIndex);
|
|
27265
|
+
const periodObject = periodArray.get(rowIndex, columnIndex);
|
|
27266
|
+
const monthObject = monthArray.get(rowIndex, columnIndex);
|
|
27267
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(costObject, salvageObject, lifeObject, periodObject, monthObject);
|
|
26989
27268
|
if (isError) return errorObject;
|
|
26990
27269
|
const [_costObject, _salvageObject, _lifeObject, _periodObject, _monthObject] = variants;
|
|
26991
27270
|
const costValue = +_costObject.getValue();
|
|
@@ -27041,7 +27320,11 @@ var Ddb = class extends BaseFunction {
|
|
|
27041
27320
|
const periodArray = expandArrayValueObject(maxRowLength, maxColumnLength, period, ErrorValueObject.create("#N/A"));
|
|
27042
27321
|
const factorArray = expandArrayValueObject(maxRowLength, maxColumnLength, _factor, ErrorValueObject.create("#N/A"));
|
|
27043
27322
|
const resultArray = costArray.map((costObject, rowIndex, columnIndex) => {
|
|
27044
|
-
const
|
|
27323
|
+
const salvageObject = salvageArray.get(rowIndex, columnIndex);
|
|
27324
|
+
const lifeObject = lifeArray.get(rowIndex, columnIndex);
|
|
27325
|
+
const periodObject = periodArray.get(rowIndex, columnIndex);
|
|
27326
|
+
const factorObject = factorArray.get(rowIndex, columnIndex);
|
|
27327
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(costObject, salvageObject, lifeObject, periodObject, factorObject);
|
|
27045
27328
|
if (isError) return errorObject;
|
|
27046
27329
|
const [_costObject, _salvageObject, _lifeObject, _periodObject, _factorObject] = variants;
|
|
27047
27330
|
const costValue = +_costObject.getValue();
|
|
@@ -27069,7 +27352,8 @@ var Disc = class extends BaseFunction {
|
|
|
27069
27352
|
_defineProperty(this, "maxParams", 5);
|
|
27070
27353
|
}
|
|
27071
27354
|
calculate(settlement, maturity, pr, redemption, basis) {
|
|
27072
|
-
const
|
|
27355
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
27356
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, pr, redemption, _basis);
|
|
27073
27357
|
if (isError) return errorObject;
|
|
27074
27358
|
const [settlementObject, maturityObject, prObject, redemptionObject, basisObject] = variants;
|
|
27075
27359
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject, this.getDateSystem());
|
|
@@ -27213,10 +27497,19 @@ var Fv = class extends BaseFunction {
|
|
|
27213
27497
|
const pvArray = expandArrayValueObject(maxRowLength, maxColumnLength, _pv, ErrorValueObject.create("#N/A"));
|
|
27214
27498
|
const typeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _type, ErrorValueObject.create("#N/A"));
|
|
27215
27499
|
const resultArray = rateArray.map((rateObject, rowIndex, columnIndex) => {
|
|
27216
|
-
const
|
|
27500
|
+
const nperObject = nperArray.get(rowIndex, columnIndex);
|
|
27501
|
+
const pmtObject = pmtArray.get(rowIndex, columnIndex);
|
|
27502
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
27503
|
+
const typeObject = typeArray.get(rowIndex, columnIndex);
|
|
27504
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rateObject, nperObject, pmtObject, pvObject, typeObject);
|
|
27217
27505
|
if (isError) return errorObject;
|
|
27218
27506
|
const [_rateObject, _nperObject, _pmtObject, _pvObject, _typeObject] = variants;
|
|
27219
|
-
const
|
|
27507
|
+
const rateValue = +_rateObject.getValue();
|
|
27508
|
+
const nperValue = +_nperObject.getValue();
|
|
27509
|
+
const pmtValue = +_pmtObject.getValue();
|
|
27510
|
+
const pvValue = +_pvObject.getValue();
|
|
27511
|
+
const typeValue = +_typeObject.getValue();
|
|
27512
|
+
const result = calculateFV(rateValue, nperValue, pmtValue, pvValue, typeValue ? 1 : 0);
|
|
27220
27513
|
if (Number.isNaN(result) || !Number.isFinite(result)) return ErrorValueObject.create("#NUM!");
|
|
27221
27514
|
if (rowIndex === 0 && columnIndex === 0) return NumberValueObject.create(result, getCurrencyFormat(this.getLocale()));
|
|
27222
27515
|
else return NumberValueObject.create(result);
|
|
@@ -27269,7 +27562,8 @@ var Intrate = class extends BaseFunction {
|
|
|
27269
27562
|
_defineProperty(this, "maxParams", 5);
|
|
27270
27563
|
}
|
|
27271
27564
|
calculate(settlement, maturity, investment, redemption, basis) {
|
|
27272
|
-
const
|
|
27565
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
27566
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, investment, redemption, _basis);
|
|
27273
27567
|
if (isError) return errorObject;
|
|
27274
27568
|
const [settlementObject, maturityObject, investmentObject, redemptionObject, basisObject] = variants;
|
|
27275
27569
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject, this.getDateSystem());
|
|
@@ -27308,7 +27602,12 @@ var Ipmt = class extends BaseFunction {
|
|
|
27308
27602
|
const fvArray = expandArrayValueObject(maxRowLength, maxColumnLength, _fv, ErrorValueObject.create("#N/A"));
|
|
27309
27603
|
const typeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _type, ErrorValueObject.create("#N/A"));
|
|
27310
27604
|
const resultArray = rateArray.map((rateObject, rowIndex, columnIndex) => {
|
|
27311
|
-
const
|
|
27605
|
+
const perObject = perArray.get(rowIndex, columnIndex);
|
|
27606
|
+
const nperObject = nperArray.get(rowIndex, columnIndex);
|
|
27607
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
27608
|
+
const fvObject = fvArray.get(rowIndex, columnIndex);
|
|
27609
|
+
const typeObject = typeArray.get(rowIndex, columnIndex);
|
|
27610
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rateObject, perObject, nperObject, pvObject, fvObject, typeObject);
|
|
27312
27611
|
if (isError) return errorObject;
|
|
27313
27612
|
const [_rateObject, _perObject, _nperObject, _pvObject, _fvObject, _typeObject] = variants;
|
|
27314
27613
|
const rateValue = +_rateObject.getValue();
|
|
@@ -27411,7 +27710,10 @@ var Ispmt = class extends BaseFunction {
|
|
|
27411
27710
|
const nperArray = expandArrayValueObject(maxRowLength, maxColumnLength, nper, ErrorValueObject.create("#N/A"));
|
|
27412
27711
|
const pvArray = expandArrayValueObject(maxRowLength, maxColumnLength, pv, ErrorValueObject.create("#N/A"));
|
|
27413
27712
|
const resultArray = rateArray.map((rateObject, rowIndex, columnIndex) => {
|
|
27414
|
-
const
|
|
27713
|
+
const perObject = perArray.get(rowIndex, columnIndex);
|
|
27714
|
+
const nperObject = nperArray.get(rowIndex, columnIndex);
|
|
27715
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
27716
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rateObject, perObject, nperObject, pvObject);
|
|
27415
27717
|
if (isError) return errorObject;
|
|
27416
27718
|
const [_rateObject, _perObject, _nperObject, _pvObject] = variants;
|
|
27417
27719
|
const rateValue = +_rateObject.getValue();
|
|
@@ -27498,14 +27800,16 @@ var Mirr = class extends BaseFunction {
|
|
|
27498
27800
|
let _numberValues = [];
|
|
27499
27801
|
let _positive = false;
|
|
27500
27802
|
let _negative = false;
|
|
27501
|
-
if (!values.isError())
|
|
27502
|
-
|
|
27503
|
-
|
|
27504
|
-
|
|
27505
|
-
|
|
27506
|
-
|
|
27507
|
-
|
|
27508
|
-
|
|
27803
|
+
if (!values.isError()) {
|
|
27804
|
+
if (values.isNull()) _values = ErrorValueObject.create("#VALUE!");
|
|
27805
|
+
else if (!values.isArray()) _values = ErrorValueObject.create("#DIV/0!");
|
|
27806
|
+
else {
|
|
27807
|
+
const { numberValues, valuesHasError, errorObject, positive, negative } = this._checkValues(values);
|
|
27808
|
+
if (valuesHasError) _values = errorObject;
|
|
27809
|
+
_numberValues = numberValues;
|
|
27810
|
+
_positive = positive;
|
|
27811
|
+
_negative = negative;
|
|
27812
|
+
}
|
|
27509
27813
|
}
|
|
27510
27814
|
return {
|
|
27511
27815
|
_values,
|
|
@@ -27603,7 +27907,11 @@ var Nper = class extends BaseFunction {
|
|
|
27603
27907
|
const fvArray = expandArrayValueObject(maxRowLength, maxColumnLength, _fv, ErrorValueObject.create("#N/A"));
|
|
27604
27908
|
const typeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _type, ErrorValueObject.create("#N/A"));
|
|
27605
27909
|
const resultArray = rateArray.map((rateObject, rowIndex, columnIndex) => {
|
|
27606
|
-
const
|
|
27910
|
+
const pmtObject = pmtArray.get(rowIndex, columnIndex);
|
|
27911
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
27912
|
+
const fvObject = fvArray.get(rowIndex, columnIndex);
|
|
27913
|
+
const typeObject = typeArray.get(rowIndex, columnIndex);
|
|
27914
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rateObject, pmtObject, pvObject, fvObject, typeObject);
|
|
27607
27915
|
if (isError) return errorObject;
|
|
27608
27916
|
const [_rateObject, _pmtObject, _pvObject, _fvObject, _typeObject] = variants;
|
|
27609
27917
|
const rateValue = +_rateObject.getValue();
|
|
@@ -27648,7 +27956,8 @@ var Npv = class extends BaseFunction {
|
|
|
27648
27956
|
if (_rate.isString()) _rate = _rate.convertToNumberObjectValue();
|
|
27649
27957
|
if (_rate.isError()) return _rate;
|
|
27650
27958
|
if (isError) return errorObject;
|
|
27651
|
-
const
|
|
27959
|
+
const rateValue = +rate.getValue();
|
|
27960
|
+
const result = calculateNpv(rateValue, values);
|
|
27652
27961
|
if (Number.isNaN(result) || Math.abs(result) === Infinity) return ErrorValueObject.create("#DIV/0!");
|
|
27653
27962
|
if (rowIndex === 0 && columnIndex === 0) return NumberValueObject.create(result, getCurrencyFormat(this.getLocale()));
|
|
27654
27963
|
return NumberValueObject.create(result);
|
|
@@ -27979,7 +28288,9 @@ var Pduration = class extends BaseFunction {
|
|
|
27979
28288
|
const pvArray = expandArrayValueObject(maxRowLength, maxColumnLength, pv, ErrorValueObject.create("#N/A"));
|
|
27980
28289
|
const fvArray = expandArrayValueObject(maxRowLength, maxColumnLength, fv, ErrorValueObject.create("#N/A"));
|
|
27981
28290
|
const resultArray = rateArray.map((rateObject, rowIndex, columnIndex) => {
|
|
27982
|
-
const
|
|
28291
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
28292
|
+
const fvObject = fvArray.get(rowIndex, columnIndex);
|
|
28293
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rateObject, pvObject, fvObject);
|
|
27983
28294
|
if (isError) return errorObject;
|
|
27984
28295
|
const [_rateObject, _pvObject, _fvObject] = variants;
|
|
27985
28296
|
const rateValue = +_rateObject.getValue();
|
|
@@ -28015,7 +28326,11 @@ var Pmt = class extends BaseFunction {
|
|
|
28015
28326
|
const fvArray = expandArrayValueObject(maxRowLength, maxColumnLength, _fv, ErrorValueObject.create("#N/A"));
|
|
28016
28327
|
const typeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _type, ErrorValueObject.create("#N/A"));
|
|
28017
28328
|
const resultArray = rateArray.map((rateObject, rowIndex, columnIndex) => {
|
|
28018
|
-
const
|
|
28329
|
+
const nperObject = nperArray.get(rowIndex, columnIndex);
|
|
28330
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
28331
|
+
const fvObject = fvArray.get(rowIndex, columnIndex);
|
|
28332
|
+
const typeObject = typeArray.get(rowIndex, columnIndex);
|
|
28333
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rateObject, nperObject, pvObject, fvObject, typeObject);
|
|
28019
28334
|
if (isError) return errorObject;
|
|
28020
28335
|
const [_rateObject, _nperObject, _pvObject, _fvObject, _typeObject] = variants;
|
|
28021
28336
|
const rateValue = +_rateObject.getValue();
|
|
@@ -28055,7 +28370,12 @@ var Ppmt = class extends BaseFunction {
|
|
|
28055
28370
|
const fvArray = expandArrayValueObject(maxRowLength, maxColumnLength, _fv, ErrorValueObject.create("#N/A"));
|
|
28056
28371
|
const typeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _type, ErrorValueObject.create("#N/A"));
|
|
28057
28372
|
const resultArray = rateArray.map((rateObject, rowIndex, columnIndex) => {
|
|
28058
|
-
const
|
|
28373
|
+
const perObject = perArray.get(rowIndex, columnIndex);
|
|
28374
|
+
const nperObject = nperArray.get(rowIndex, columnIndex);
|
|
28375
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
28376
|
+
const fvObject = fvArray.get(rowIndex, columnIndex);
|
|
28377
|
+
const typeObject = typeArray.get(rowIndex, columnIndex);
|
|
28378
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rateObject, perObject, nperObject, pvObject, fvObject, typeObject);
|
|
28059
28379
|
if (isError) return errorObject;
|
|
28060
28380
|
const [_rateObject, _perObject, _nperObject, _pvObject, _fvObject, _typeObject] = variants;
|
|
28061
28381
|
const rateValue = +_rateObject.getValue();
|
|
@@ -28196,7 +28516,11 @@ var Pv = class extends BaseFunction {
|
|
|
28196
28516
|
const fvArray = expandArrayValueObject(maxRowLength, maxColumnLength, _fv, ErrorValueObject.create("#N/A"));
|
|
28197
28517
|
const typeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _type, ErrorValueObject.create("#N/A"));
|
|
28198
28518
|
const resultArray = rateArray.map((rateObject, rowIndex, columnIndex) => {
|
|
28199
|
-
const
|
|
28519
|
+
const nperObject = nperArray.get(rowIndex, columnIndex);
|
|
28520
|
+
const pmtObject = pmtArray.get(rowIndex, columnIndex);
|
|
28521
|
+
const fvObject = fvArray.get(rowIndex, columnIndex);
|
|
28522
|
+
const typeObject = typeArray.get(rowIndex, columnIndex);
|
|
28523
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rateObject, nperObject, pmtObject, fvObject, typeObject);
|
|
28200
28524
|
if (isError) return errorObject;
|
|
28201
28525
|
const [_rateObject, _nperObject, _pmtObject, _fvObject, _typeObject] = variants;
|
|
28202
28526
|
const rateValue = +_rateObject.getValue();
|
|
@@ -28236,7 +28560,12 @@ var Rate = class extends BaseFunction {
|
|
|
28236
28560
|
const typeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _type, ErrorValueObject.create("#N/A"));
|
|
28237
28561
|
const guessArray = expandArrayValueObject(maxRowLength, maxColumnLength, _guess, ErrorValueObject.create("#N/A"));
|
|
28238
28562
|
const resultArray = nperArray.map((nperObject, rowIndex, columnIndex) => {
|
|
28239
|
-
const
|
|
28563
|
+
const pmtObject = pmtArray.get(rowIndex, columnIndex);
|
|
28564
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
28565
|
+
const fvObject = fvArray.get(rowIndex, columnIndex);
|
|
28566
|
+
const typeObject = typeArray.get(rowIndex, columnIndex);
|
|
28567
|
+
const guessObject = guessArray.get(rowIndex, columnIndex);
|
|
28568
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(nperObject, pmtObject, pvObject, fvObject, typeObject, guessObject);
|
|
28240
28569
|
if (isError) return errorObject;
|
|
28241
28570
|
const [_nperObject, _pmtObject, _pvObject, _fvObject, _typeObject, _guessObject] = variants;
|
|
28242
28571
|
const nperValue = +_nperObject.getValue();
|
|
@@ -28347,7 +28676,9 @@ var Rri = class extends BaseFunction {
|
|
|
28347
28676
|
const pvArray = expandArrayValueObject(maxRowLength, maxColumnLength, pv, ErrorValueObject.create("#N/A"));
|
|
28348
28677
|
const fvArray = expandArrayValueObject(maxRowLength, maxColumnLength, fv, ErrorValueObject.create("#N/A"));
|
|
28349
28678
|
const resultArray = nperArray.map((nperObject, rowIndex, columnIndex) => {
|
|
28350
|
-
const
|
|
28679
|
+
const pvObject = pvArray.get(rowIndex, columnIndex);
|
|
28680
|
+
const fvObject = fvArray.get(rowIndex, columnIndex);
|
|
28681
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(nperObject, pvObject, fvObject);
|
|
28351
28682
|
if (isError) return errorObject;
|
|
28352
28683
|
const [_nperObject, _pvObject, _fvObject] = variants;
|
|
28353
28684
|
const nperValue = +_nperObject.getValue();
|
|
@@ -28458,7 +28789,8 @@ var Tbilleq = class extends BaseFunction {
|
|
|
28458
28789
|
const DSM = Math.floor(maturitySerialNumber) - Math.floor(settlementSerialNumber);
|
|
28459
28790
|
const date = excelSerialToDate(settlementSerialNumber, this.getDateSystem());
|
|
28460
28791
|
const isSerialZero = settlementSerialNumber === 0;
|
|
28461
|
-
const
|
|
28792
|
+
const year = this.getDateSystem() === DateSystem.Date1900 && isSerialZero ? 1900 : date.getUTCFullYear();
|
|
28793
|
+
const yearDays = getDaysInYear(year);
|
|
28462
28794
|
if (DSM > yearDays) return ErrorValueObject.create("#NUM!");
|
|
28463
28795
|
let result = 365 * discountValue / (360 - discountValue * DSM);
|
|
28464
28796
|
if (DSM > 182) {
|
|
@@ -28494,7 +28826,8 @@ var Tbillprice = class extends BaseFunction {
|
|
|
28494
28826
|
if (discountValue <= 0 || settlementSerialNumber >= maturitySerialNumber) return ErrorValueObject.create("#NUM!");
|
|
28495
28827
|
const DSM = Math.floor(maturitySerialNumber) - Math.floor(settlementSerialNumber);
|
|
28496
28828
|
const date = excelSerialToDate(settlementSerialNumber, this.getDateSystem());
|
|
28497
|
-
|
|
28829
|
+
const year = this.getDateSystem() === DateSystem.Date1900 && settlementSerialNumber === 0 ? 1900 : date.getUTCFullYear();
|
|
28830
|
+
if (DSM > getDaysInYear(year)) return ErrorValueObject.create("#NUM!");
|
|
28498
28831
|
const result = 100 * (1 - discountValue * DSM / 360);
|
|
28499
28832
|
if (result < 0) return ErrorValueObject.create("#NUM!");
|
|
28500
28833
|
return NumberValueObject.create(result, getCurrencyFormat(this.getLocale()));
|
|
@@ -28522,7 +28855,8 @@ var Tbillyield = class extends BaseFunction {
|
|
|
28522
28855
|
if (prValue <= 0 || settlementSerialNumber >= maturitySerialNumber) return ErrorValueObject.create("#NUM!");
|
|
28523
28856
|
const DSM = Math.floor(maturitySerialNumber) - Math.floor(settlementSerialNumber);
|
|
28524
28857
|
const date = excelSerialToDate(settlementSerialNumber, this.getDateSystem());
|
|
28525
|
-
|
|
28858
|
+
const year = this.getDateSystem() === DateSystem.Date1900 && settlementSerialNumber === 0 ? 1900 : date.getUTCFullYear();
|
|
28859
|
+
if (DSM > getDaysInYear(year)) return ErrorValueObject.create("#NUM!");
|
|
28526
28860
|
const result = (100 - prValue) / prValue * 360 / DSM;
|
|
28527
28861
|
return NumberValueObject.create(result);
|
|
28528
28862
|
}
|
|
@@ -28555,7 +28889,13 @@ var Vdb = class extends BaseFunction {
|
|
|
28555
28889
|
}
|
|
28556
28890
|
_getResultArray(costArray, salvageArray, lifeArray, startPeriodArray, endPeriodArray, factorArray, noSwitchArray, maxRowLength, maxColumnLength) {
|
|
28557
28891
|
const resultArray = costArray.map((costObject, rowIndex, columnIndex) => {
|
|
28558
|
-
const
|
|
28892
|
+
const salvageObject = salvageArray.get(rowIndex, columnIndex);
|
|
28893
|
+
const lifeObject = lifeArray.get(rowIndex, columnIndex);
|
|
28894
|
+
const startPeriodObject = startPeriodArray.get(rowIndex, columnIndex);
|
|
28895
|
+
const endPeriodObject = endPeriodArray.get(rowIndex, columnIndex);
|
|
28896
|
+
const factorObject = factorArray.get(rowIndex, columnIndex);
|
|
28897
|
+
const noSwitchObject = noSwitchArray.get(rowIndex, columnIndex);
|
|
28898
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(costObject, salvageObject, lifeObject, startPeriodObject, endPeriodObject, factorObject, noSwitchObject);
|
|
28559
28899
|
if (isError) return errorObject;
|
|
28560
28900
|
const [_costObject, _salvageObject, _lifeObject, _startPeriodObject, _endPeriodObject, _factorObject, _noSwitchObject] = variants;
|
|
28561
28901
|
const costValue = +_costObject.getValue();
|
|
@@ -29190,12 +29530,16 @@ var Cell = class extends BaseFunction {
|
|
|
29190
29530
|
return this._handleSingleObject(_infoType, reference);
|
|
29191
29531
|
}
|
|
29192
29532
|
_handleSingleObject(infoType, reference, infoTypeIsArray = false) {
|
|
29533
|
+
var _referenceObject$getC;
|
|
29193
29534
|
let _reference = reference;
|
|
29194
29535
|
if (_reference.isError()) return _reference;
|
|
29195
29536
|
if (!_reference.isReferenceObject()) return ErrorValueObject.create("#N/A");
|
|
29196
29537
|
const { columnData, defaultColumnWidth } = _reference.getCurrentActiveSheetData();
|
|
29197
29538
|
const forcedSheetName = _reference.getForcedSheetName();
|
|
29198
|
-
|
|
29539
|
+
const referenceObject = _reference;
|
|
29540
|
+
const cellData = referenceObject.getCellData(referenceObject.getRangePosition().startRow, referenceObject.getRangePosition().startColumn);
|
|
29541
|
+
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;
|
|
29542
|
+
_reference = referenceObject.toArrayValueObject();
|
|
29199
29543
|
const _currentRow = _reference.getCurrentRow();
|
|
29200
29544
|
const _currentColumn = _reference.getCurrentColumn();
|
|
29201
29545
|
_reference = _reference.getFirstCell();
|
|
@@ -29207,7 +29551,7 @@ var Cell = class extends BaseFunction {
|
|
|
29207
29551
|
case "color": return NumberValueObject.create(0);
|
|
29208
29552
|
case "contents": return _reference;
|
|
29209
29553
|
case "filename": return ErrorValueObject.create("#VALUE!");
|
|
29210
|
-
case "format": return StringValueObject.create(
|
|
29554
|
+
case "format": return StringValueObject.create(getCellFormatCode(numberFormat));
|
|
29211
29555
|
case "parentheses": return NumberValueObject.create(0);
|
|
29212
29556
|
case "prefix": return StringValueObject.create("");
|
|
29213
29557
|
case "protect": return NumberValueObject.create(1);
|
|
@@ -29230,6 +29574,24 @@ var Cell = class extends BaseFunction {
|
|
|
29230
29574
|
return ArrayValueObject.createByArray(resultArray);
|
|
29231
29575
|
}
|
|
29232
29576
|
};
|
|
29577
|
+
function getCellFormatCode(pattern) {
|
|
29578
|
+
if (!pattern || /^general$/iu.test(pattern.trim())) return "G";
|
|
29579
|
+
const normalized = pattern.split(";")[0].replace(/"[^"]*"/gu, "").replace(/\\./gu, "").replace(/_.|\*./gu, "").toLocaleLowerCase();
|
|
29580
|
+
const hasDate = /[yd]/u.test(normalized);
|
|
29581
|
+
const hasTime = /h|s/u.test(normalized);
|
|
29582
|
+
if (hasDate) return "D4";
|
|
29583
|
+
if (hasTime) return /s/u.test(normalized) ? "D8" : "D9";
|
|
29584
|
+
if (/%/u.test(normalized)) return `P${decimalPlaces(normalized)}`;
|
|
29585
|
+
if (/[eE][+-]?0+/u.test(normalized)) return `S${decimalPlaces(normalized)}`;
|
|
29586
|
+
if (/[$£¥€]/u.test(normalized)) return `C${decimalPlaces(normalized)}`;
|
|
29587
|
+
if (/,/u.test(normalized)) return `,${decimalPlaces(normalized)}`;
|
|
29588
|
+
if (/[0#?]/u.test(normalized)) return `F${decimalPlaces(normalized)}`;
|
|
29589
|
+
return "G";
|
|
29590
|
+
}
|
|
29591
|
+
function decimalPlaces(pattern) {
|
|
29592
|
+
var _pattern$match;
|
|
29593
|
+
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;
|
|
29594
|
+
}
|
|
29233
29595
|
|
|
29234
29596
|
//#endregion
|
|
29235
29597
|
//#region src/functions/information/error-type/index.ts
|
|
@@ -29271,7 +29633,9 @@ var Isbetween = class extends BaseFunction {
|
|
|
29271
29633
|
_defineProperty(this, "maxParams", 5);
|
|
29272
29634
|
}
|
|
29273
29635
|
calculate(valueToCompare, lowerValue, upperValue, lowerValueIsInclusive, upperValueIsInclusive) {
|
|
29274
|
-
const
|
|
29636
|
+
const _lowerValueIsInclusive = lowerValueIsInclusive ?? BooleanValueObject.create(true);
|
|
29637
|
+
const _upperValueIsInclusive = upperValueIsInclusive ?? BooleanValueObject.create(true);
|
|
29638
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArray(valueToCompare, lowerValue, upperValue, _lowerValueIsInclusive, _upperValueIsInclusive);
|
|
29275
29639
|
if (isError) return errorObject;
|
|
29276
29640
|
const [valueToCompareObject, lowerValueObject, upperValueObject, lowerValueIsInclusiveObject, upperValueIsInclusiveObject] = variants;
|
|
29277
29641
|
if (lowerValueIsInclusiveObject.isString() || upperValueIsInclusiveObject.isString()) return ErrorValueObject.create("#VALUE!");
|
|
@@ -30481,13 +30845,15 @@ var Map$1 = class extends BaseFunction {
|
|
|
30481
30845
|
_variant_reference = variant;
|
|
30482
30846
|
variant = variant.toArrayValueObject();
|
|
30483
30847
|
}
|
|
30484
|
-
if (!variant.isArray())
|
|
30485
|
-
|
|
30486
|
-
|
|
30487
|
-
|
|
30488
|
-
|
|
30489
|
-
|
|
30490
|
-
|
|
30848
|
+
if (!variant.isArray()) {
|
|
30849
|
+
if (r === 0 && c === 0) {
|
|
30850
|
+
lambdaVariant.push(_variant_reference || variant);
|
|
30851
|
+
continue;
|
|
30852
|
+
} else {
|
|
30853
|
+
row.push(ErrorValueObject.create("#N/A"));
|
|
30854
|
+
isRowPushed = true;
|
|
30855
|
+
break;
|
|
30856
|
+
}
|
|
30491
30857
|
}
|
|
30492
30858
|
let valueObject = variant.get(r, c);
|
|
30493
30859
|
if (!valueObject) {
|
|
@@ -30993,7 +31359,8 @@ var Address = class extends BaseFunction {
|
|
|
30993
31359
|
if (Number.isNaN(row) || Number.isNaN(column) || Number.isNaN(absNumberValue) || absNumberValue < 1 || absNumberValue > 4) return ErrorValueObject.create("#VALUE!");
|
|
30994
31360
|
const absType = transformAbsoluteRefType(absNumberValue);
|
|
30995
31361
|
const a1Value = this.getZeroOrOneByOneDefault(a1);
|
|
30996
|
-
const
|
|
31362
|
+
const sheetTextValue = `${sheetText.getValue()}`;
|
|
31363
|
+
const sheetName = addQuotesBothSides(sheetTextValue);
|
|
30997
31364
|
const range = {
|
|
30998
31365
|
startRow: row,
|
|
30999
31366
|
startColumn: column,
|
|
@@ -31120,8 +31487,10 @@ var Choosecols = class extends BaseFunction {
|
|
|
31120
31487
|
const variantValue = Math.trunc(+variantObject.getValue());
|
|
31121
31488
|
if (variantValue === 0 || Math.abs(variantValue) > arrayColumnCount) return ErrorValueObject.create("#VALUE!");
|
|
31122
31489
|
let searchColArray = array;
|
|
31123
|
-
if (arrayColumnCount > 1)
|
|
31124
|
-
|
|
31490
|
+
if (arrayColumnCount > 1) {
|
|
31491
|
+
if (variantValue < 0) searchColArray = array.slice(void 0, [variantValue + arrayColumnCount, variantValue + 1 + arrayColumnCount]);
|
|
31492
|
+
else searchColArray = array.slice(void 0, [variantValue - 1, variantValue]);
|
|
31493
|
+
}
|
|
31125
31494
|
for (let r = 0; r < arrayRowCount; r++) {
|
|
31126
31495
|
if (!result[r]) result[r] = [];
|
|
31127
31496
|
if (array.isArray()) result[r].push(searchColArray.get(r, 0));
|
|
@@ -31165,8 +31534,10 @@ var Chooserows = class extends BaseFunction {
|
|
|
31165
31534
|
const variantValue = Math.trunc(+variantObject.getValue());
|
|
31166
31535
|
if (variantValue === 0 || Math.abs(variantValue) > arrayRowCount) return ErrorValueObject.create("#VALUE!");
|
|
31167
31536
|
let searchRowArray = array;
|
|
31168
|
-
if (arrayRowCount > 1)
|
|
31169
|
-
|
|
31537
|
+
if (arrayRowCount > 1) {
|
|
31538
|
+
if (variantValue < 0) searchRowArray = array.slice([variantValue + arrayRowCount, variantValue + 1 + arrayRowCount]);
|
|
31539
|
+
else searchRowArray = array.slice([variantValue - 1, variantValue]);
|
|
31540
|
+
}
|
|
31170
31541
|
if (array.isArray()) result.push(searchRowArray.getArrayValue()[0]);
|
|
31171
31542
|
else result.push([array]);
|
|
31172
31543
|
}
|
|
@@ -31528,19 +31899,24 @@ var Hlookup = class extends BaseFunction {
|
|
|
31528
31899
|
if (lookupValue.isError()) return lookupValue;
|
|
31529
31900
|
if (tableArray.isError()) return ErrorValueObject.create("#REF!");
|
|
31530
31901
|
if (!tableArray.isArray()) return ErrorValueObject.create("#N/A");
|
|
31531
|
-
if (rowIndexNum.isError()) return
|
|
31902
|
+
if (rowIndexNum.isError()) return rowIndexNum;
|
|
31532
31903
|
if (rangeLookup === null || rangeLookup === void 0 ? void 0 : rangeLookup.isError()) return ErrorValueObject.create("#N/A");
|
|
31533
31904
|
const rangeLookupValue = this.getZeroOrOneByOneDefault(rangeLookup);
|
|
31534
31905
|
if (rangeLookupValue == null) return ErrorValueObject.create("#VALUE!");
|
|
31535
31906
|
const rowIndexNumValue = this.getIndexNumValue(rowIndexNum);
|
|
31536
|
-
if (rowIndexNumValue instanceof ErrorValueObject) return
|
|
31907
|
+
if (rowIndexNumValue instanceof ErrorValueObject) return ErrorValueObject.create("#VALUE!");
|
|
31908
|
+
const rowIndex = Math.floor(rowIndexNumValue);
|
|
31537
31909
|
const searchArray = tableArray.slice([0, 1]);
|
|
31538
|
-
const resultArray = tableArray.slice([
|
|
31539
|
-
if (searchArray == null
|
|
31540
|
-
if (lookupValue.isArray()) return lookupValue.map((value) => this._handleSingleObject(value, searchArray, resultArray, rangeLookupValue));
|
|
31541
|
-
return this._handleSingleObject(lookupValue, searchArray, resultArray, rangeLookupValue);
|
|
31910
|
+
const resultArray = tableArray.slice([rowIndex - 1, rowIndex]);
|
|
31911
|
+
if (searchArray == null) return ErrorValueObject.create("#REF!");
|
|
31912
|
+
if (lookupValue.isArray()) return lookupValue.map((value) => this._handleSingleObject(value, searchArray, resultArray, rangeLookupValue, rowIndex));
|
|
31913
|
+
return this._handleSingleObject(lookupValue, searchArray, resultArray, rangeLookupValue, rowIndex);
|
|
31542
31914
|
}
|
|
31543
|
-
_handleSingleObject(value, searchArray, resultArray, rangeLookupValue) {
|
|
31915
|
+
_handleSingleObject(value, searchArray, resultArray, rangeLookupValue, rowIndex) {
|
|
31916
|
+
if (resultArray == null || rowIndex < 1) {
|
|
31917
|
+
const match = this._handleSingleObject(value, searchArray, searchArray, rangeLookupValue, 1);
|
|
31918
|
+
return match.isError() ? match : ErrorValueObject.create(rowIndex < 1 ? "#VALUE!" : "#REF!");
|
|
31919
|
+
}
|
|
31544
31920
|
if (rangeLookupValue === 0) return this._blankResultAsZero(this.equalSearch(value, searchArray, resultArray));
|
|
31545
31921
|
return this.binarySearch(value, searchArray, resultArray);
|
|
31546
31922
|
}
|
|
@@ -31762,6 +32138,7 @@ var Index = class extends BaseFunction {
|
|
|
31762
32138
|
if (rowNumValue > referenceRowColumnCount.rowCount || columnNumValue > referenceRowColumnCount.columnCount) return ErrorValueObject.create("#REF!");
|
|
31763
32139
|
let _reference = reference;
|
|
31764
32140
|
if (areaNumValue > 1) _reference = reference.getCubeValues()[areaNumValue - 1];
|
|
32141
|
+
if (!columnNum && rowNumValue > 0 && referenceRowColumnCount.rowCount > 1 && referenceRowColumnCount.columnCount > 1 && _reference.isReferenceObject()) return ErrorValueObject.create("#REF!");
|
|
31765
32142
|
if (_reference.isReferenceObject()) return this._calculateReferenceObject(_reference, rowNumValue, columnNumValue);
|
|
31766
32143
|
return this._calculateArrayObject(_reference, rowNumValue, columnNumValue);
|
|
31767
32144
|
}
|
|
@@ -32930,13 +33307,15 @@ var Vlookup = class extends BaseFunction {
|
|
|
32930
33307
|
}
|
|
32931
33308
|
_handleTableArray(lookupValue, tableArray, colIndexNum, rangeLookupValue) {
|
|
32932
33309
|
let colIndexNumValue = this.getIndexNumValue(colIndexNum);
|
|
32933
|
-
if (colIndexNumValue instanceof ErrorValueObject) return
|
|
33310
|
+
if (colIndexNumValue instanceof ErrorValueObject) return ErrorValueObject.create("#VALUE!");
|
|
32934
33311
|
colIndexNumValue = Math.floor(colIndexNumValue);
|
|
32935
|
-
if (colIndexNumValue < 1) return ErrorValueObject.create("#VALUE!");
|
|
32936
33312
|
const searchArray = tableArray.slice(void 0, [0, 1]);
|
|
32937
33313
|
if (searchArray == null) return ErrorValueObject.create("#VALUE!");
|
|
32938
33314
|
const resultArray = tableArray.slice(void 0, [colIndexNumValue - 1, colIndexNumValue]);
|
|
32939
|
-
if (resultArray == null
|
|
33315
|
+
if (resultArray == null || colIndexNumValue < 1) {
|
|
33316
|
+
const match = this._handleSingleObject(lookupValue, searchArray, searchArray, rangeLookupValue);
|
|
33317
|
+
return match.isError() ? match : ErrorValueObject.create(colIndexNumValue < 1 ? "#VALUE!" : "#REF!");
|
|
33318
|
+
}
|
|
32940
33319
|
return this._handleSingleObject(lookupValue, searchArray, resultArray, rangeLookupValue);
|
|
32941
33320
|
}
|
|
32942
33321
|
_handleSingleObject(value, searchArray, resultArray, rangeLookupValue) {
|
|
@@ -34259,7 +34638,8 @@ var Fact = class extends BaseFunction {
|
|
|
34259
34638
|
let _number = number;
|
|
34260
34639
|
if (_number.isString()) _number = _number.convertToNumberObjectValue();
|
|
34261
34640
|
if (_number.isError()) return _number;
|
|
34262
|
-
const
|
|
34641
|
+
const numberValue = Math.floor(+_number.getValue());
|
|
34642
|
+
const result = calculateFactorial(numberValue);
|
|
34263
34643
|
if (Number.isNaN(result) || !Number.isFinite(result)) return ErrorValueObject.create("#NUM!");
|
|
34264
34644
|
return NumberValueObject.create(result);
|
|
34265
34645
|
}
|
|
@@ -34287,7 +34667,8 @@ var Factdouble = class extends BaseFunction {
|
|
|
34287
34667
|
let _number = number;
|
|
34288
34668
|
if (_number.isString()) _number = _number.convertToNumberObjectValue();
|
|
34289
34669
|
if (_number.isError()) return _number;
|
|
34290
|
-
const
|
|
34670
|
+
const numberValue = Math.floor(+_number.getValue());
|
|
34671
|
+
const result = calculateFactorial(numberValue, 2);
|
|
34291
34672
|
if (Number.isNaN(result) || !Number.isFinite(result)) return ErrorValueObject.create("#NUM!");
|
|
34292
34673
|
return NumberValueObject.create(result);
|
|
34293
34674
|
}
|
|
@@ -35343,13 +35724,12 @@ var Roundbank = class extends BaseFunction {
|
|
|
35343
35724
|
_roundBank(number, numDigits) {
|
|
35344
35725
|
if (numDigits > 16) return number;
|
|
35345
35726
|
if (numDigits < -16) return 0;
|
|
35346
|
-
const EPSILON = 1e-8;
|
|
35347
35727
|
const multiplier = 10 ** numDigits;
|
|
35348
35728
|
const adjustedNum = +(number * multiplier).toFixed(8);
|
|
35349
35729
|
const integerPart = Math.floor(adjustedNum);
|
|
35350
35730
|
const decimalPart = adjustedNum - integerPart;
|
|
35351
35731
|
let result = Math.round(adjustedNum);
|
|
35352
|
-
if (decimalPart > .
|
|
35732
|
+
if (decimalPart > .49999999 && decimalPart < .50000001) result = integerPart % 2 === 0 ? integerPart : integerPart + 1;
|
|
35353
35733
|
return numDigits ? result / multiplier : result;
|
|
35354
35734
|
}
|
|
35355
35735
|
};
|
|
@@ -35829,6 +36209,8 @@ var Sumif = class extends BaseFunction {
|
|
|
35829
36209
|
_defineProperty(this, "needsReferenceObject", true);
|
|
35830
36210
|
}
|
|
35831
36211
|
calculate(range, criteria, sumRange) {
|
|
36212
|
+
if (range.isError()) return range;
|
|
36213
|
+
if (sumRange === null || sumRange === void 0 ? void 0 : sumRange.isError()) return sumRange;
|
|
35832
36214
|
if (!range.isReferenceObject() || sumRange && !sumRange.isReferenceObject()) return ErrorValueObject.create("#VALUE!");
|
|
35833
36215
|
let _criteria = criteria;
|
|
35834
36216
|
if (criteria.isReferenceObject()) _criteria = criteria.toArrayValueObject();
|
|
@@ -35933,7 +36315,7 @@ var Sumproduct = class extends BaseFunction {
|
|
|
35933
36315
|
const arr = v;
|
|
35934
36316
|
const variantRowCount = arr.getRowCount();
|
|
35935
36317
|
const variantColumnCount = arr.getColumnCount();
|
|
35936
|
-
if (variantRowCount !== rowCount
|
|
36318
|
+
if (variantRowCount !== rowCount || variantColumnCount !== columnCount) return ErrorValueObject.create("#VALUE!");
|
|
35937
36319
|
}
|
|
35938
36320
|
}
|
|
35939
36321
|
return null;
|
|
@@ -37236,7 +37618,7 @@ var Countif = class extends BaseFunction {
|
|
|
37236
37618
|
}
|
|
37237
37619
|
}
|
|
37238
37620
|
if (_criteria.isArray()) {
|
|
37239
|
-
const resultArray = _criteria.mapValue((criteriaObject) => this._handleSingleObject(range, criteriaObject));
|
|
37621
|
+
const resultArray = _criteria.mapValue((criteriaObject) => this._handleSingleObject(range, criteria.isReferenceObject() && criteriaObject.isNull() ? NumberValueObject.create(0) : criteriaObject));
|
|
37240
37622
|
if (resultArray.getRowCount() === 1 && resultArray.getColumnCount() === 1) return resultArray.get(0, 0);
|
|
37241
37623
|
return resultArray;
|
|
37242
37624
|
}
|
|
@@ -37751,7 +38133,8 @@ var Gauss = class extends BaseFunction {
|
|
|
37751
38133
|
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(z);
|
|
37752
38134
|
if (isError) return errorObject;
|
|
37753
38135
|
const [zObject] = variants;
|
|
37754
|
-
const
|
|
38136
|
+
const zValue = +zObject.getValue();
|
|
38137
|
+
const result = normalCDF(zValue, 0, 1) - .5;
|
|
37755
38138
|
return NumberValueObject.create(result);
|
|
37756
38139
|
}
|
|
37757
38140
|
};
|
|
@@ -37862,7 +38245,8 @@ var Growth = class extends BaseFunction {
|
|
|
37862
38245
|
}
|
|
37863
38246
|
_getResultBySimpleVariables(knownYsValues, knownXsValues, newXsValues, constb) {
|
|
37864
38247
|
const knownYsValuesFlat = knownYsValues.flat();
|
|
37865
|
-
const
|
|
38248
|
+
const knownXsValuesFlat = knownXsValues.flat();
|
|
38249
|
+
const { slope, intercept } = getSlopeAndIntercept(knownXsValuesFlat, knownYsValuesFlat, constb, true);
|
|
37866
38250
|
const result = newXsValues.map((row) => {
|
|
37867
38251
|
return row.map((value) => intercept * slope ** value);
|
|
37868
38252
|
});
|
|
@@ -38084,7 +38468,8 @@ var Large = class extends BaseFunction {
|
|
|
38084
38468
|
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(k);
|
|
38085
38469
|
if (isError) return errorObject;
|
|
38086
38470
|
const [kObject] = variants;
|
|
38087
|
-
|
|
38471
|
+
const kValue = +kObject.getValue();
|
|
38472
|
+
return getLargeResult(array, kValue);
|
|
38088
38473
|
}
|
|
38089
38474
|
};
|
|
38090
38475
|
|
|
@@ -38950,7 +39335,8 @@ var PercentileExc = class extends BaseFunction {
|
|
|
38950
39335
|
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(k);
|
|
38951
39336
|
if (isError) return errorObject;
|
|
38952
39337
|
const [kObject] = variants;
|
|
38953
|
-
|
|
39338
|
+
const kValue = +kObject.getValue();
|
|
39339
|
+
return getPercentileExcResult(array, kValue);
|
|
38954
39340
|
}
|
|
38955
39341
|
};
|
|
38956
39342
|
|
|
@@ -38988,8 +39374,10 @@ var PercentrankExc = class extends BaseFunction {
|
|
|
38988
39374
|
const significanceValue = Math.floor(+significanceObject.getValue());
|
|
38989
39375
|
const n = array.length;
|
|
38990
39376
|
if (n === 0 || xValue < array[0] || xValue > array[n - 1]) return ErrorValueObject.create("#N/A");
|
|
38991
|
-
if (n === 1)
|
|
38992
|
-
|
|
39377
|
+
if (n === 1) {
|
|
39378
|
+
if (xValue === array[0]) return NumberValueObject.create(1);
|
|
39379
|
+
else return ErrorValueObject.create("#N/A");
|
|
39380
|
+
}
|
|
38993
39381
|
let result = 0;
|
|
38994
39382
|
let match = false;
|
|
38995
39383
|
let i = 0;
|
|
@@ -39080,8 +39468,10 @@ var Permutationa = class extends BaseFunction {
|
|
|
39080
39468
|
const numberValue = Math.floor(+_numberObject.getValue());
|
|
39081
39469
|
const numberChosenValue = Math.floor(+_numberChosenObject.getValue());
|
|
39082
39470
|
if (numberValue < 0 || numberValue >= 2147483647 || numberChosenValue < 0) return ErrorValueObject.create("#NUM!");
|
|
39083
|
-
if (numberValue === 0)
|
|
39084
|
-
|
|
39471
|
+
if (numberValue === 0) {
|
|
39472
|
+
if (numberChosenValue === 0) return NumberValueObject.create(1);
|
|
39473
|
+
else return NumberValueObject.create(0);
|
|
39474
|
+
}
|
|
39085
39475
|
const result = numberValue ** numberChosenValue;
|
|
39086
39476
|
if (!Number.isFinite(result)) return ErrorValueObject.create("#NUM!");
|
|
39087
39477
|
return NumberValueObject.create(result);
|
|
@@ -39235,7 +39625,8 @@ var QuartileExc = class extends BaseFunction {
|
|
|
39235
39625
|
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(quart);
|
|
39236
39626
|
if (isError) return errorObject;
|
|
39237
39627
|
const [quartObject] = variants;
|
|
39238
|
-
|
|
39628
|
+
const quartValue = Math.floor(+quartObject.getValue());
|
|
39629
|
+
return getQuartileExcResult(array, quartValue);
|
|
39239
39630
|
}
|
|
39240
39631
|
};
|
|
39241
39632
|
|
|
@@ -39603,7 +39994,8 @@ var Small = class extends BaseFunction {
|
|
|
39603
39994
|
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(k);
|
|
39604
39995
|
if (isError) return errorObject;
|
|
39605
39996
|
const [kObject] = variants;
|
|
39606
|
-
|
|
39997
|
+
const kValue = +kObject.getValue();
|
|
39998
|
+
return getSmallResult(array, kValue);
|
|
39607
39999
|
}
|
|
39608
40000
|
};
|
|
39609
40001
|
|
|
@@ -39930,7 +40322,8 @@ var Trend = class extends BaseFunction {
|
|
|
39930
40322
|
}
|
|
39931
40323
|
_getResultBySimpleVariables(knownYsValues, knownXsValues, newXsValues, constb) {
|
|
39932
40324
|
const knownYsValuesFlat = knownYsValues.flat();
|
|
39933
|
-
const
|
|
40325
|
+
const knownXsValuesFlat = knownXsValues.flat();
|
|
40326
|
+
const { slope: m, intercept: b } = getSlopeAndIntercept(knownXsValuesFlat, knownYsValuesFlat, constb, false);
|
|
39934
40327
|
if (Number.isNaN(m)) return ErrorValueObject.create("#N/A");
|
|
39935
40328
|
const result = newXsValues.map((row) => {
|
|
39936
40329
|
return row.map((value) => m * value + b);
|
|
@@ -40187,9 +40580,12 @@ var Arraytotext = class extends BaseFunction {
|
|
|
40187
40580
|
if (valueObject.isBoolean()) value = value.toLocaleUpperCase();
|
|
40188
40581
|
if (valueObject.isString() && formatValue) result += `"${value}"`;
|
|
40189
40582
|
else result += value;
|
|
40190
|
-
if (!(r === arrayRowCount - 1 && c === arrayColumnCount - 1))
|
|
40191
|
-
|
|
40192
|
-
|
|
40583
|
+
if (!(r === arrayRowCount - 1 && c === arrayColumnCount - 1)) {
|
|
40584
|
+
if (formatValue) {
|
|
40585
|
+
if (c === arrayColumnCount - 1) result += ";";
|
|
40586
|
+
else result += ",";
|
|
40587
|
+
} else result += ", ";
|
|
40588
|
+
}
|
|
40193
40589
|
}
|
|
40194
40590
|
if (formatValue) result = `{${result}}`;
|
|
40195
40591
|
if (result.length > 32767) return ErrorValueObject.create("#CALC!");
|
|
@@ -40260,9 +40656,10 @@ var Bahttext = class extends BaseFunction {
|
|
|
40260
40656
|
const integerPart = Math.abs(Number.parseInt(numberValue.toString(), 10));
|
|
40261
40657
|
const decimalPart = Number.parseFloat((Math.abs(numberValue) - integerPart).toFixed(2));
|
|
40262
40658
|
let result = "";
|
|
40263
|
-
if (integerPart === 0)
|
|
40264
|
-
|
|
40265
|
-
|
|
40659
|
+
if (integerPart === 0) {
|
|
40660
|
+
if (decimalPart !== 0) result = `${numberValue < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(decimalPart * 100)}สตางค์`;
|
|
40661
|
+
else result = "ศูนย์บาทถ้วน";
|
|
40662
|
+
} else if (decimalPart === 0) result = `${numberValue < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(integerPart)}บาทถ้วน`;
|
|
40266
40663
|
else result = `${numberValue < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(integerPart)}บาท${this._convertNumberToThaiText(decimalPart * 100)}สตางค์`;
|
|
40267
40664
|
return StringValueObject.create(result);
|
|
40268
40665
|
}
|
|
@@ -40313,9 +40710,7 @@ var Bahttext = class extends BaseFunction {
|
|
|
40313
40710
|
result += i < n ? special[5] : digitText;
|
|
40314
40711
|
break;
|
|
40315
40712
|
case 1: break;
|
|
40316
|
-
default:
|
|
40317
|
-
result += digitText;
|
|
40318
|
-
break;
|
|
40713
|
+
default: result += digitText;
|
|
40319
40714
|
}
|
|
40320
40715
|
else if (digit === 0) {
|
|
40321
40716
|
if (position === 0) result += units[position];
|
|
@@ -40618,8 +41013,10 @@ const getTextValueOfNumberFormat = (text) => {
|
|
|
40618
41013
|
let textValue = `${text.getValue()}`;
|
|
40619
41014
|
if (text.isNull()) textValue = "";
|
|
40620
41015
|
if (text.isBoolean()) textValue = textValue.toLocaleUpperCase();
|
|
40621
|
-
if (text.isNumber())
|
|
40622
|
-
|
|
41016
|
+
if (text.isNumber()) {
|
|
41017
|
+
if (text.getPattern() !== "") textValue = getFormatPreview(text.getPattern(), +text.getValue(), text.getDateSystem());
|
|
41018
|
+
else textValue = `${stripErrorMargin(+text.getValue())}`;
|
|
41019
|
+
}
|
|
40623
41020
|
return textValue;
|
|
40624
41021
|
};
|
|
40625
41022
|
|
|
@@ -40929,7 +41326,8 @@ var Lenb = class extends BaseFunction {
|
|
|
40929
41326
|
}
|
|
40930
41327
|
_handleSingleText(text) {
|
|
40931
41328
|
if (text.isError()) return text;
|
|
40932
|
-
const
|
|
41329
|
+
const textValue = getTextValueOfNumberFormat(text);
|
|
41330
|
+
const textByteLen = charLenByte(textValue);
|
|
40933
41331
|
return NumberValueObject.create(textByteLen);
|
|
40934
41332
|
}
|
|
40935
41333
|
};
|
|
@@ -42245,14 +42643,17 @@ var Text = class extends BaseFunction {
|
|
|
42245
42643
|
if (textValue.isBoolean()) return textValue;
|
|
42246
42644
|
let textValueNumber = textValue.getValue();
|
|
42247
42645
|
if (textValue.isNull()) textValueNumber = 0;
|
|
42248
|
-
if (textValue.isString())
|
|
42249
|
-
|
|
42250
|
-
|
|
42251
|
-
|
|
42646
|
+
if (textValue.isString()) {
|
|
42647
|
+
if (isRealNum(textValueNumber)) textValueNumber = Number(textValueNumber);
|
|
42648
|
+
else {
|
|
42649
|
+
const parsedValue = getNumfmtParseValueFilter(`${textValueNumber}`, { dateSystem: textValue.getDateSystem() });
|
|
42650
|
+
if (parsedValue && parsedValue.v != null && typeof parsedValue.v === "number") textValueNumber = parsedValue.v;
|
|
42651
|
+
}
|
|
42252
42652
|
}
|
|
42253
42653
|
if (formatTextValue.isNull()) formatTextValue = StringValueObject.create(" ");
|
|
42254
42654
|
const formatTextValueString = `${formatTextValue.getValue()}`;
|
|
42255
|
-
const
|
|
42655
|
+
const normalizedFormatTextValueString = normalizeExcelWeekdayFormat(formatTextValueString);
|
|
42656
|
+
const previewText = getFormatPreview(normalizedFormatTextValueString, textValueNumber, textValue.getDateSystem());
|
|
42256
42657
|
return StringValueObject.create(formatTextValueString === " " ? previewText.trimEnd() : previewText);
|
|
42257
42658
|
});
|
|
42258
42659
|
if (resultArray.getRowCount() === 1 && resultArray.getColumnCount() === 1) return resultArray.get(0, 0);
|
|
@@ -42309,8 +42710,10 @@ var Textafter = class extends BaseFunction {
|
|
|
42309
42710
|
if (_variantsNumberFloorValue instanceof ErrorValueObject) return _variantsNumberFloorValue;
|
|
42310
42711
|
const [instanceNumValue, matchModeValue, matchEndValue] = _variantsNumberFloorValue;
|
|
42311
42712
|
if (instanceNumValue === 0 || matchModeValue < 0 || matchModeValue > 1 || matchEndValue < 0 || matchEndValue > 1) return ErrorValueObject.create("#VALUE!");
|
|
42312
|
-
if (delimiterValue.includes(""))
|
|
42313
|
-
|
|
42713
|
+
if (delimiterValue.includes("")) {
|
|
42714
|
+
if (instanceNumValue > 0) return StringValueObject.create(textValue);
|
|
42715
|
+
else return StringValueObject.create("");
|
|
42716
|
+
}
|
|
42314
42717
|
if (!instanceNumIsNull && Math.abs(instanceNumValue) > textValue.length) return ErrorValueObject.create("#VALUE!");
|
|
42315
42718
|
if (delimiterValue.every((item) => item.length > textValue.length)) return ErrorValueObject.create("#N/A");
|
|
42316
42719
|
return this._getResult(textValue, delimiterValue, instanceNumValue, matchModeValue, matchEndValue, ifNotFoundObject, onlyThreeVariant);
|
|
@@ -42398,8 +42801,10 @@ var Textafter = class extends BaseFunction {
|
|
|
42398
42801
|
}
|
|
42399
42802
|
if (matchNum && matchNum < Math.abs(instanceNumValue) && onlyThreeVariant) return ErrorValueObject.create("#N/A");
|
|
42400
42803
|
if (!matchNum || matchNum < Math.abs(instanceNumValue)) {
|
|
42401
|
-
if (matchEndValue)
|
|
42402
|
-
|
|
42804
|
+
if (matchEndValue) {
|
|
42805
|
+
if (instanceNumValue > 0) return StringValueObject.create("");
|
|
42806
|
+
else return StringValueObject.create(textValue);
|
|
42807
|
+
}
|
|
42403
42808
|
return ifNotFoundObject;
|
|
42404
42809
|
}
|
|
42405
42810
|
const result = textValue.substr(resultIndex + preDelimiterLength);
|
|
@@ -42452,8 +42857,10 @@ var Textbefore = class extends BaseFunction {
|
|
|
42452
42857
|
if (_variantsNumberFloorValue instanceof ErrorValueObject) return _variantsNumberFloorValue;
|
|
42453
42858
|
const [instanceNumValue, matchModeValue, matchEndValue] = _variantsNumberFloorValue;
|
|
42454
42859
|
if (instanceNumValue === 0 || matchModeValue < 0 || matchModeValue > 1 || matchEndValue < 0 || matchEndValue > 1) return ErrorValueObject.create("#VALUE!");
|
|
42455
|
-
if (delimiterValue.includes(""))
|
|
42456
|
-
|
|
42860
|
+
if (delimiterValue.includes("")) {
|
|
42861
|
+
if (instanceNumValue > 0) return StringValueObject.create("");
|
|
42862
|
+
else return StringValueObject.create(textValue);
|
|
42863
|
+
}
|
|
42457
42864
|
if (!instanceNumIsNull && Math.abs(instanceNumValue) > textValue.length) return ErrorValueObject.create("#VALUE!");
|
|
42458
42865
|
if (delimiterValue.every((item) => item.length > textValue.length)) return ErrorValueObject.create("#N/A");
|
|
42459
42866
|
return this._getResult(textValue, delimiterValue, instanceNumValue, matchModeValue, matchEndValue, ifNotFoundObject, onlyThreeVariant);
|
|
@@ -42540,8 +42947,10 @@ var Textbefore = class extends BaseFunction {
|
|
|
42540
42947
|
}
|
|
42541
42948
|
if (matchNum && matchNum < Math.abs(instanceNumValue) && onlyThreeVariant) return ErrorValueObject.create("#N/A");
|
|
42542
42949
|
if (!matchNum || matchNum < Math.abs(instanceNumValue)) {
|
|
42543
|
-
if (matchEndValue)
|
|
42544
|
-
|
|
42950
|
+
if (matchEndValue) {
|
|
42951
|
+
if (instanceNumValue > 0) return StringValueObject.create(textValue);
|
|
42952
|
+
else return StringValueObject.create("");
|
|
42953
|
+
}
|
|
42545
42954
|
return ifNotFoundObject;
|
|
42546
42955
|
}
|
|
42547
42956
|
const result = textValue.substr(0, resultIndex);
|
|
@@ -43191,7 +43600,7 @@ function getObjectValue(result, isUseStrip = false) {
|
|
|
43191
43600
|
//#endregion
|
|
43192
43601
|
//#region package.json
|
|
43193
43602
|
var name = "@univerjs/engine-formula";
|
|
43194
|
-
var version = "1.0.0
|
|
43603
|
+
var version = "1.0.0";
|
|
43195
43604
|
|
|
43196
43605
|
//#endregion
|
|
43197
43606
|
//#region src/services/global-computing-status.service.ts
|
|
@@ -43363,10 +43772,13 @@ let FormulaCalculationTriggerService = class FormulaCalculationTriggerService ex
|
|
|
43363
43772
|
if (this._hasPendingCalculation || this._waitingCommandQueue.length > 0) this._scheduleFlush();
|
|
43364
43773
|
}
|
|
43365
43774
|
_generateDirty(commands) {
|
|
43366
|
-
|
|
43775
|
+
const result = createEmptyDirtyData();
|
|
43776
|
+
const rangeKeys = /* @__PURE__ */ new Set();
|
|
43777
|
+
for (const command of commands) {
|
|
43367
43778
|
const conversion = this._activeDirtyManagerService.get(command.id);
|
|
43368
|
-
|
|
43369
|
-
}
|
|
43779
|
+
if (conversion) appendDirtyData(result, conversion.getDirtyData(command), rangeKeys);
|
|
43780
|
+
}
|
|
43781
|
+
return result;
|
|
43370
43782
|
}
|
|
43371
43783
|
};
|
|
43372
43784
|
FormulaCalculationTriggerService = __decorate([__decorateParam(0, ICommandService), __decorateParam(1, IActiveDirtyManagerService)], FormulaCalculationTriggerService);
|
|
@@ -43374,30 +43786,32 @@ function createEmptyDirtyData() {
|
|
|
43374
43786
|
return {
|
|
43375
43787
|
forceCalculation: false,
|
|
43376
43788
|
dirtyRanges: [],
|
|
43377
|
-
dirtyNameMap:
|
|
43378
|
-
dirtyDefinedNameMap:
|
|
43379
|
-
dirtySuperTableMap:
|
|
43380
|
-
dirtyUnitFeatureMap:
|
|
43381
|
-
dirtyUnitOtherFormulaMap:
|
|
43382
|
-
clearDependencyTreeCache:
|
|
43789
|
+
dirtyNameMap: Object.create(null),
|
|
43790
|
+
dirtyDefinedNameMap: Object.create(null),
|
|
43791
|
+
dirtySuperTableMap: Object.create(null),
|
|
43792
|
+
dirtyUnitFeatureMap: Object.create(null),
|
|
43793
|
+
dirtyUnitOtherFormulaMap: Object.create(null),
|
|
43794
|
+
clearDependencyTreeCache: Object.create(null)
|
|
43383
43795
|
};
|
|
43384
43796
|
}
|
|
43385
43797
|
function mergeDirtyData(left, right) {
|
|
43386
|
-
const
|
|
43387
|
-
|
|
43388
|
-
|
|
43389
|
-
|
|
43390
|
-
|
|
43391
|
-
dirtyDefinedNameMap: mergeDirtyUnitStringMap(left.dirtyDefinedNameMap, right.dirtyDefinedNameMap),
|
|
43392
|
-
dirtySuperTableMap: mergeDirtyUnitStringMap(left.dirtySuperTableMap ?? {}, right.dirtySuperTableMap),
|
|
43393
|
-
dirtyUnitFeatureMap: mergeDirtyUnitNestedMap(left.dirtyUnitFeatureMap, right.dirtyUnitFeatureMap),
|
|
43394
|
-
dirtyUnitOtherFormulaMap: mergeDirtyUnitNestedMap(left.dirtyUnitOtherFormulaMap, right.dirtyUnitOtherFormulaMap),
|
|
43395
|
-
clearDependencyTreeCache: mergeDirtyUnitStringMap(left.clearDependencyTreeCache, right.clearDependencyTreeCache),
|
|
43396
|
-
forceCalculation: left.forceCalculation || Boolean(right.forceCalculation)
|
|
43397
|
-
};
|
|
43798
|
+
const result = createEmptyDirtyData();
|
|
43799
|
+
const rangeKeys = /* @__PURE__ */ new Set();
|
|
43800
|
+
appendDirtyData(result, left, rangeKeys);
|
|
43801
|
+
appendDirtyData(result, right, rangeKeys);
|
|
43802
|
+
return result;
|
|
43398
43803
|
}
|
|
43399
|
-
function
|
|
43400
|
-
|
|
43804
|
+
function appendDirtyData(target, source, rangeKeys) {
|
|
43805
|
+
mergeDirtyRanges(target.dirtyRanges, source.dirtyRanges ?? [], rangeKeys);
|
|
43806
|
+
mergeDirtyUnitStringMap(target.dirtyNameMap, source.dirtyNameMap);
|
|
43807
|
+
mergeDirtyUnitStringMap(target.dirtyDefinedNameMap, source.dirtyDefinedNameMap);
|
|
43808
|
+
mergeDirtyUnitStringMap(target.dirtySuperTableMap ??= Object.create(null), source.dirtySuperTableMap);
|
|
43809
|
+
mergeDirtyUnitNestedMap(target.dirtyUnitFeatureMap, source.dirtyUnitFeatureMap);
|
|
43810
|
+
mergeDirtyUnitNestedMap(target.dirtyUnitOtherFormulaMap, source.dirtyUnitOtherFormulaMap);
|
|
43811
|
+
mergeDirtyUnitStringMap(target.clearDependencyTreeCache, source.clearDependencyTreeCache);
|
|
43812
|
+
target.forceCalculation = target.forceCalculation || Boolean(source.forceCalculation);
|
|
43813
|
+
}
|
|
43814
|
+
function mergeDirtyRanges(target, source, keys) {
|
|
43401
43815
|
source.forEach((range) => {
|
|
43402
43816
|
const key = getDirtyRangeKey(range);
|
|
43403
43817
|
if (!keys.has(key)) {
|
|
@@ -43417,29 +43831,18 @@ function getDirtyRangeKey({ unitId, sheetId, range }) {
|
|
|
43417
43831
|
range.rangeType
|
|
43418
43832
|
]);
|
|
43419
43833
|
}
|
|
43420
|
-
function mergeDirtyUnitStringMap(
|
|
43421
|
-
const result = { ...left };
|
|
43834
|
+
function mergeDirtyUnitStringMap(target, right) {
|
|
43422
43835
|
Object.entries(right ?? {}).forEach(([unitId, values]) => {
|
|
43423
|
-
|
|
43424
|
-
...result[unitId],
|
|
43425
|
-
...values
|
|
43426
|
-
};
|
|
43836
|
+
Object.assign(target[unitId] ??= Object.create(null), values);
|
|
43427
43837
|
});
|
|
43428
|
-
return result;
|
|
43429
43838
|
}
|
|
43430
|
-
function mergeDirtyUnitNestedMap(
|
|
43431
|
-
const result = { ...left };
|
|
43839
|
+
function mergeDirtyUnitNestedMap(target, right) {
|
|
43432
43840
|
Object.entries(right ?? {}).forEach(([unitId, sheets]) => {
|
|
43433
|
-
const unitResult =
|
|
43841
|
+
const unitResult = target[unitId] ??= Object.create(null);
|
|
43434
43842
|
Object.entries(sheets ?? {}).forEach(([sheetId, values]) => {
|
|
43435
|
-
unitResult[sheetId]
|
|
43436
|
-
...unitResult[sheetId],
|
|
43437
|
-
...values
|
|
43438
|
-
};
|
|
43843
|
+
Object.assign(unitResult[sheetId] ??= Object.create(null), values);
|
|
43439
43844
|
});
|
|
43440
|
-
result[unitId] = unitResult;
|
|
43441
43845
|
});
|
|
43442
|
-
return result;
|
|
43443
43846
|
}
|
|
43444
43847
|
function hasDirtyData(dirtyData) {
|
|
43445
43848
|
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);
|