@univerjs/engine-formula 1.5.2 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +2 -2
- package/lib/cjs/index.js +4 -2
- package/lib/cjs/{plugin-DFoqrWnC.js → plugin-2MkLwT8w.js} +601 -141
- package/lib/cjs/worker.js +1 -1
- package/lib/es/facade.js +2 -2
- package/lib/es/index.js +2 -2
- package/lib/es/{plugin-D8WjYqcc.js → plugin-CIMLSmdW.js} +591 -143
- package/lib/es/worker.js +1 -1
- package/lib/facade.js +2 -2
- package/lib/index.js +2 -2
- package/lib/{plugin-D8WjYqcc.js → plugin-CIMLSmdW.js} +591 -143
- package/lib/types/engine/utils/char-kit.d.ts +28 -3
- package/lib/types/engine/utils/compare.d.ts +24 -0
- package/lib/types/engine/utils/math-kit.d.ts +7 -0
- package/lib/types/engine/utils/numfmt-kit.d.ts +1 -2
- package/lib/types/engine/value-object/array-value-object.d.ts +5 -1
- package/lib/types/functions/financial/amordegrc/index.d.ts +10 -2
- package/lib/types/functions/lookup/xmatch/index.d.ts +1 -0
- package/lib/types/functions/math/iso-ceiling/index.d.ts +6 -4
- package/lib/types/functions/text/euroconvert/index.d.ts +10 -2
- package/lib/types/index.d.ts +2 -0
- package/lib/umd/index.js +4 -4
- package/lib/worker.js +1 -1
- package/package.json +6 -6
|
@@ -14,10 +14,35 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* A code point in the surrogate block is half of a UTF-16 pair, not a character.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isSurrogateCodePoint(codePoint: number): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* U+FDD0-U+FDEF and the last two code points of every plane (xFFFE, xFFFF).
|
|
22
|
+
*/
|
|
23
|
+
export declare function isNonCharacterCodePoint(codePoint: number): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Excel logic is confusing, so we use google sheet logic
|
|
18
26
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
27
|
+
* Each UTF-16 code unit above U+00FF counts as two bytes here, so a character outside
|
|
28
|
+
* the BMP counts as four. That length feeds LENB, LEFTB, RIGHTB, MIDB, REPLACEB,
|
|
29
|
+
* SEARCHB and FINDB. Excel 2021 (16.0, zh-CN, DBCS default language, checked 2026-11-18)
|
|
30
|
+
* contradicts itself on the same text: LENB("😊") is 2, but LEFTB("😊ab", 2) is "😊a",
|
|
31
|
+
* as if 😊 were one byte, and LEFTB("😊ab", 1) returns the whole pair; MIDB("😊ab", 1, 1)
|
|
32
|
+
* returns half a surrogate pair, while MIDB("中ab", 2, 1) returns a space standing for
|
|
33
|
+
* the second byte of a double-byte character.
|
|
21
34
|
*/
|
|
22
35
|
export declare function charLenByte(text: string): number;
|
|
23
36
|
export declare function getCharLenByteInText(text: string, charIndex: number, direction?: 'ltr' | 'rtl'): number;
|
|
37
|
+
/**
|
|
38
|
+
* Whether the code unit at `index` and the one after it form a surrogate pair, which
|
|
39
|
+
* together make up one character.
|
|
40
|
+
*/
|
|
41
|
+
export declare function isSurrogatePairAt(text: string, index: number): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Upper-cases text for a case-insensitive search without changing its length, so an
|
|
44
|
+
* index in the result is also the index in the original text. A character whose upper
|
|
45
|
+
* case is longer, such as ß becoming SS, is left as it is. The host locale is ignored,
|
|
46
|
+
* as it is for the wildcard comparisons in `compare.ts`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function upperCaseKeepingPositions(text: string): string;
|
|
@@ -32,8 +32,32 @@ export declare enum ArrayOrderSearchType {
|
|
|
32
32
|
export declare function getCompare(): (x: string, y: string) => number;
|
|
33
33
|
export declare function isWildcard(str: string): boolean;
|
|
34
34
|
export declare function normalizeTextForComparison(value: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Text equality for an exact lookup, where ? and * are ordinary characters (XLOOKUP and XMATCH
|
|
37
|
+
* match mode 0). It ignores case, as the `=` comparison does.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isLiteralTextMatch(currentValue: string, value: string): boolean;
|
|
35
40
|
export declare function isMatchWildcard(currentValue: string, value: string): boolean;
|
|
36
41
|
export declare function replaceWildcard(value: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* A wildcard pattern read as text to look for, rather than as text to compare with.
|
|
44
|
+
* `?` matches one character, `*` matches any text, and `~` makes the character after it
|
|
45
|
+
* literal; a trailing `~` adds nothing to the pattern.
|
|
46
|
+
*/
|
|
47
|
+
export interface IWildcardPattern {
|
|
48
|
+
/** The text to look for, escapes resolved, when the pattern has no wildcard. */
|
|
49
|
+
literal: string | null;
|
|
50
|
+
/** The parts between `*` wildcards; `null` inside a part stands for `?`. */
|
|
51
|
+
segments: ReadonlyArray<ReadonlyArray<string | null>>;
|
|
52
|
+
}
|
|
53
|
+
export declare function parseWildcardPattern(pattern: string): IWildcardPattern;
|
|
54
|
+
/**
|
|
55
|
+
* Index of the earliest match of `pattern` in `text` at or after `fromIndex`, or -1.
|
|
56
|
+
*
|
|
57
|
+
* The parts of a wildcard pattern are placed at their leftmost position, so the cost
|
|
58
|
+
* is text length times pattern length and no input can make the search backtrack.
|
|
59
|
+
*/
|
|
60
|
+
export declare function searchWildcard(text: string, pattern: IWildcardPattern, fromIndex: number): number;
|
|
37
61
|
export declare function compareWithWildcard(currentValue: string, value: string, operator: compareToken, isCaseSensitive?: boolean): boolean;
|
|
38
62
|
export declare function getMatchModeValue(matchModeValue: number): ArrayOrderSearchType;
|
|
39
63
|
export declare function getSearchModeValue(searchModeValue: number): ArrayBinarySearchType;
|
|
@@ -29,6 +29,13 @@ export declare function divide(a: number, b: number): number;
|
|
|
29
29
|
* @returns The rounded number.
|
|
30
30
|
*/
|
|
31
31
|
export declare function round(base: number, precision: number): number;
|
|
32
|
+
/**
|
|
33
|
+
* Rounds a number to a specified number of decimal places, halves to even ('banker's rounding').
|
|
34
|
+
* @param base The number to round.
|
|
35
|
+
* @param precision The number of decimal places to round to.
|
|
36
|
+
* @returns The rounded number.
|
|
37
|
+
*/
|
|
38
|
+
export declare function roundHalfEven(base: number, precision: number): number;
|
|
32
39
|
/**
|
|
33
40
|
* Rounds down a number to a specified number of decimal places.
|
|
34
41
|
* @param base The number to round down.
|
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { DateSystem, ICellData, Nullable, Styles } from '@univerjs/core';
|
|
17
|
-
import { LocaleType } from '@univerjs/core';
|
|
16
|
+
import type { DateSystem, ICellData, LocaleType, Nullable, Styles } from '@univerjs/core';
|
|
18
17
|
import { operatorToken } from '../../basics/token';
|
|
19
18
|
/**
|
|
20
19
|
* Handling number formats in styles
|
|
@@ -136,8 +136,12 @@ export declare class ArrayValueObject extends BaseValueObject {
|
|
|
136
136
|
* Due to the inability to effectively utilize the cache,
|
|
137
137
|
* the sequential matching approach is only used for special matches in XLOOKUP and XMATCH.
|
|
138
138
|
* For example, when match_mode is set to 1 and -1 for an exact match. If not found, it returns the next smaller item.
|
|
139
|
+
*
|
|
140
|
+
* With literalText, the exact match and the next smaller or larger fallback read ? and * in a text value as
|
|
141
|
+
* ordinary characters, as XLOOKUP and XMATCH do outside match mode 2. MATCH leaves it off, because its exact
|
|
142
|
+
* match accepts wildcards.
|
|
139
143
|
*/
|
|
140
|
-
orderSearch(valueObject: BaseValueObject, searchType?: ArrayOrderSearchType, isDesc?: boolean, isFuzzyMatching?: boolean, keepFirstNearest?: boolean): void | {
|
|
144
|
+
orderSearch(valueObject: BaseValueObject, searchType?: ArrayOrderSearchType, isDesc?: boolean, isFuzzyMatching?: boolean, keepFirstNearest?: boolean, literalText?: boolean): void | {
|
|
141
145
|
row: number;
|
|
142
146
|
column: number;
|
|
143
147
|
} | null;
|
|
@@ -13,8 +13,16 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
|
|
16
|
+
import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
17
|
+
import { BaseFunction } from '../../base-function';
|
|
18
|
+
export declare class Amordegrc extends BaseFunction {
|
|
18
19
|
minParams: number;
|
|
19
20
|
maxParams: number;
|
|
21
|
+
calculate(cost: BaseValueObject, datePurchased: BaseValueObject, firstPeriod: BaseValueObject, salvage: BaseValueObject, period: BaseValueObject, rate: BaseValueObject, basis?: BaseValueObject): BaseValueObject;
|
|
22
|
+
private _getResult;
|
|
23
|
+
/**
|
|
24
|
+
* The depreciation coefficient of the French accounting system, by the life of the asset in
|
|
25
|
+
* whole years: up to 4 is 1.5, 5 or 6 is 2 and longer is 2.5.
|
|
26
|
+
*/
|
|
27
|
+
private _getCoefficient;
|
|
20
28
|
}
|
|
@@ -21,4 +21,5 @@ export declare class Xmatch extends BaseFunction {
|
|
|
21
21
|
calculate(lookupValue: BaseValueObject, lookupArray: BaseValueObject, matchMode?: BaseValueObject, searchMode?: BaseValueObject): BaseValueObject;
|
|
22
22
|
private _handleSingleObject;
|
|
23
23
|
private _getResult;
|
|
24
|
+
private _exactMatches;
|
|
24
25
|
}
|
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
import { CeilingPrecise } from '../ceiling-precise';
|
|
17
|
+
/**
|
|
18
|
+
* ISO.CEILING rounds a number up to the nearest multiple of the significance's absolute value, whatever the
|
|
19
|
+
* signs, and returns 0 when either argument is 0. Excel defines it with the same result as CEILING.PRECISE.
|
|
20
|
+
*/
|
|
21
|
+
export declare class IsoCeiling extends CeilingPrecise {
|
|
20
22
|
}
|
|
@@ -13,8 +13,16 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
|
|
16
|
+
import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
17
|
+
import { BaseFunction } from '../../base-function';
|
|
18
|
+
export declare class Euroconvert extends BaseFunction {
|
|
18
19
|
minParams: number;
|
|
19
20
|
maxParams: number;
|
|
21
|
+
calculate(number: BaseValueObject, source: BaseValueObject, target: BaseValueObject, fullPrecision?: BaseValueObject, triangulationPrecision?: BaseValueObject): BaseValueObject;
|
|
22
|
+
private _getCurrency;
|
|
23
|
+
/**
|
|
24
|
+
* The decimals the intermediate euro value is rounded to, `null` when the argument is
|
|
25
|
+
* omitted, or the error it produces.
|
|
26
|
+
*/
|
|
27
|
+
private _getTriangulationDecimals;
|
|
20
28
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -80,6 +80,8 @@ export { AsyncArrayObject, AsyncObject } from './engine/reference-object/base-re
|
|
|
80
80
|
export { RangeReferenceObject } from './engine/reference-object/range-reference-object';
|
|
81
81
|
export { generateExecuteAstNodeData } from './engine/utils/ast-node-tool';
|
|
82
82
|
export { extractFormulaError } from './engine/utils/cell';
|
|
83
|
+
export { upperCaseKeepingPositions } from './engine/utils/char-kit';
|
|
84
|
+
export { normalizeTextForComparison } from './engine/utils/compare';
|
|
83
85
|
export { generateAstNode } from './engine/utils/generate-ast-node';
|
|
84
86
|
export { strip, stripErrorMargin } from './engine/utils/math-kit';
|
|
85
87
|
export { handleNumfmtInCell } from './engine/utils/numfmt-kit';
|