@univerjs/engine-formula 1.0.0-alpha.1 → 1.0.0-alpha.3

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.
Files changed (76) hide show
  1. package/lib/cjs/facade.js +9 -5
  2. package/lib/cjs/index.js +1530 -268
  3. package/lib/es/facade.js +9 -5
  4. package/lib/es/index.js +1520 -270
  5. package/lib/facade.js +9 -5
  6. package/lib/index.js +1520 -270
  7. package/lib/types/basics/regex.d.ts +2 -2
  8. package/lib/types/commands/mutations/set-super-table.mutation.d.ts +4 -1
  9. package/lib/types/controllers/super-table-active-dirty.controller.d.ts +22 -0
  10. package/lib/types/engine/analysis/lexer-tree-builder.d.ts +2 -1
  11. package/lib/types/engine/analysis/lexer.d.ts +2 -1
  12. package/lib/types/engine/analysis/parser.d.ts +2 -1
  13. package/lib/types/engine/ast-node/function-node.d.ts +4 -0
  14. package/lib/types/engine/ast-node/operator-node.d.ts +1 -0
  15. package/lib/types/engine/ast-node/prefix-node.d.ts +1 -0
  16. package/lib/types/engine/interpreter/interpreter.d.ts +11 -0
  17. package/lib/types/engine/reference-object/cell-reference-object.d.ts +1 -0
  18. package/lib/types/engine/utils/generate-ast-node.d.ts +1 -1
  19. package/lib/types/engine/utils/math-kit.d.ts +5 -0
  20. package/lib/types/engine/value-object/array-value-object.d.ts +5 -0
  21. package/lib/types/engine/value-object/base-value-object.d.ts +6 -0
  22. package/lib/types/facade/f-formula.d.ts +9 -5
  23. package/lib/types/functions/base-function.d.ts +16 -1
  24. package/lib/types/functions/cube/cubekpimember/index.d.ts +20 -0
  25. package/lib/types/functions/cube/cubemember/index.d.ts +20 -0
  26. package/lib/types/functions/cube/cubememberproperty/index.d.ts +20 -0
  27. package/lib/types/functions/cube/cuberankedmember/index.d.ts +20 -0
  28. package/lib/types/functions/cube/cubeset/index.d.ts +20 -0
  29. package/lib/types/functions/cube/cubesetcount/index.d.ts +20 -0
  30. package/lib/types/functions/cube/cubevalue/index.d.ts +20 -0
  31. package/lib/types/functions/financial/amordegrc/index.d.ts +20 -0
  32. package/lib/types/functions/information/info/index.d.ts +20 -0
  33. package/lib/types/functions/information/isomitted/index.d.ts +20 -0
  34. package/lib/types/functions/logical/function-map.d.ts +3 -2
  35. package/lib/types/functions/logical/function-names.d.ts +2 -0
  36. package/lib/types/functions/logical/groupby/index.d.ts +46 -0
  37. package/lib/types/functions/logical/if/index.d.ts +5 -0
  38. package/lib/types/functions/logical/iferror/index.d.ts +4 -1
  39. package/lib/types/functions/logical/percentof/index.d.ts +27 -0
  40. package/lib/types/functions/lookup/anchorarray/index.d.ts +23 -0
  41. package/lib/types/functions/lookup/function-names.d.ts +1 -0
  42. package/lib/types/functions/lookup/getpivotdata/index.d.ts +20 -0
  43. package/lib/types/functions/lookup/hlookup/index.d.ts +1 -0
  44. package/lib/types/functions/lookup/indirect/index.d.ts +1 -0
  45. package/lib/types/functions/lookup/rtd/index.d.ts +20 -0
  46. package/lib/types/functions/lookup/vlookup/index.d.ts +2 -0
  47. package/lib/types/functions/lookup/xlookup/index.d.ts +2 -0
  48. package/lib/types/functions/math/iso-ceiling/index.d.ts +20 -0
  49. package/lib/types/functions/math/sum/index.d.ts +1 -0
  50. package/lib/types/functions/meta/compare/index.d.ts +1 -0
  51. package/lib/types/functions/not-implemented-function.d.ts +23 -0
  52. package/lib/types/functions/statistical/average/index.d.ts +1 -0
  53. package/lib/types/functions/statistical/countifs/index.d.ts +1 -0
  54. package/lib/types/functions/statistical/forecast-ets/index.d.ts +20 -0
  55. package/lib/types/functions/statistical/forecast-ets-confint/index.d.ts +20 -0
  56. package/lib/types/functions/statistical/forecast-ets-seasonality/index.d.ts +20 -0
  57. package/lib/types/functions/statistical/forecast-ets-stat/index.d.ts +20 -0
  58. package/lib/types/functions/statistical/linest/index.d.ts +1 -0
  59. package/lib/types/functions/text/call/index.d.ts +20 -0
  60. package/lib/types/functions/text/euroconvert/index.d.ts +20 -0
  61. package/lib/types/functions/text/function-names.d.ts +1 -0
  62. package/lib/types/functions/text/phonetic/index.d.ts +20 -0
  63. package/lib/types/functions/text/register-id/index.d.ts +20 -0
  64. package/lib/types/functions/text/textsplit/index.d.ts +1 -0
  65. package/lib/types/functions/web/filterxml/index.d.ts +22 -0
  66. package/lib/types/functions/web/function-map.d.ts +2 -2
  67. package/lib/types/functions/web/webservice/index.d.ts +20 -0
  68. package/lib/types/index.d.ts +3 -1
  69. package/lib/types/models/formula-data.model.d.ts +1 -0
  70. package/lib/types/services/active-dirty-manager.service.d.ts +2 -1
  71. package/lib/types/services/calculate-formula.service.d.ts +2 -2
  72. package/lib/types/services/defined-names.service.d.ts +2 -2
  73. package/lib/types/services/formula-calculation-trigger.service.d.ts +38 -0
  74. package/lib/types/services/runtime.service.d.ts +6 -0
  75. package/lib/umd/index.js +5 -2
  76. package/package.json +5 -5
@@ -33,8 +33,8 @@ export declare const REFERENCE_REGEX_SINGLE_ROW_PRECOMPILING: RegExp;
33
33
  export declare const REFERENCE_REGEX_SINGLE_COLUMN = "^'?(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?(((?![\\[\\]\\/?*\\\\]).)*!)?'?\\s*?\\$?[A-Za-z]+$";
34
34
  export declare const REFERENCE_REGEX_SINGLE_COLUMN_PRECOMPILING: RegExp;
35
35
  export declare const REFERENCE_TABLE_ALL_COLUMN_REGEX = "^(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+$";
36
- export declare const REFERENCE_TABLE_SINGLE_COLUMN_REGEX = "^(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+(\\[((?<!#).)*\\]|\\[\\[#.+\\]\\s*?,\\s*?\\[((?<!#).)*\\]\\])+$";
37
- export declare const REFERENCE_TABLE_MULTIPLE_COLUMN_REGEX = "^(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+(\\[\\[((?<!#).)*\\]\\s*?:\\s*?\\[((?<!#).)*\\]\\])?$|^((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+(\\[\\[#.+\\]\\s*?,\\s*?\\[((?<!#).)*\\]\\s*?:\\s*?\\[((?<!#).)*\\]\\])?$";
36
+ export declare const REFERENCE_TABLE_SINGLE_COLUMN_REGEX = "^(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+(\\[((?<!#)[\\s\\S])*\\]|\\[\\[#.+\\]\\s*?,\\s*?\\[((?<!#)[\\s\\S])*\\]\\])+$";
37
+ export declare const REFERENCE_TABLE_MULTIPLE_COLUMN_REGEX = "^(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+(\\[\\[((?<!#)[\\s\\S])*\\]\\s*?:\\s*?\\[((?<!#)[\\s\\S])*\\]\\])?$|^((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+(\\[\\[#.+\\]\\s*?,\\s*?\\[((?<!#)[\\s\\S])*\\]\\s*?:\\s*?\\[((?<!#)[\\s\\S])*\\]\\])?$";
38
38
  export declare const REFERENCE_TABLE_TITLE_ONLY_ANY_HASH_REGEX = "^(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+\\[\\s*#([^\\]]+)\\s*\\]$";
39
39
  export declare const REFERENCE_TABLE_ALL_COLUMN_REGEX_PRECOMPILING: RegExp;
40
40
  export declare const REFERENCE_TABLE_SINGLE_COLUMN_REGEX_PRECOMPILING: RegExp;
@@ -20,6 +20,9 @@ export interface ISetSuperTableMutationSearchParam {
20
20
  unitId: string;
21
21
  tableName: string;
22
22
  }
23
+ export interface IRemoveSuperTableMutationParam extends ISetSuperTableMutationSearchParam {
24
+ reference?: Pick<ISuperTable, 'sheetId' | 'range'>;
25
+ }
23
26
  export interface ISetSuperTableMutationParam extends ISetSuperTableMutationSearchParam {
24
27
  oldTableName?: string;
25
28
  reference: ISuperTable;
@@ -29,5 +32,5 @@ export interface ISetSuperTableMutationParam extends ISetSuperTableMutationSearc
29
32
  * It requires setting local to true during execution.
30
33
  */
31
34
  export declare const SetSuperTableMutation: IMutation<ISetSuperTableMutationParam>;
32
- export declare const RemoveSuperTableMutation: IMutation<ISetSuperTableMutationSearchParam>;
35
+ export declare const RemoveSuperTableMutation: IMutation<IRemoveSuperTableMutationParam>;
33
36
  export declare const SetSuperTableOptionMutation: IMutation<ISuperTableOptionParam>;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Disposable } from '@univerjs/core';
17
+ import { IActiveDirtyManagerService } from '../services/active-dirty-manager.service';
18
+ export declare class SuperTableActiveDirtyController extends Disposable {
19
+ private readonly _activeDirtyManagerService;
20
+ constructor(_activeDirtyManagerService: IActiveDirtyManagerService);
21
+ private _initialize;
22
+ }
@@ -26,7 +26,8 @@ export declare const FormulaLexerNodeCache: FormulaAstLRU<LexerNode>;
26
26
  export declare const FormulaSequenceNodeCache: FormulaAstLRU<(string | ISequenceNode)[]>;
27
27
  interface IInjectDefinedNameParam {
28
28
  unitId: Nullable<string>;
29
- getValueByName(unitId: string, name: string): Nullable<IDefinedNamesServiceParam>;
29
+ sheetId?: Nullable<string>;
30
+ getValueByName(unitId: string, name: string, sheetId?: Nullable<string>): Nullable<IDefinedNamesServiceParam>;
30
31
  getDirtyDefinedNameMap(): IDirtyUnitDefinedNameMap;
31
32
  getSheetName: (unitId: string, sheetId: string) => string;
32
33
  }
@@ -13,6 +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 { Nullable } from '@univerjs/core';
16
17
  import { Disposable } from '@univerjs/core';
17
18
  import { IFormulaCurrentConfigService } from '../../services/current-data.service';
18
19
  import { IDefinedNamesService } from '../../services/defined-names.service';
@@ -22,5 +23,5 @@ export declare class Lexer extends Disposable {
22
23
  private readonly _lexerTreeBuilder;
23
24
  private readonly _formulaCurrentConfigService;
24
25
  constructor(_definedNamesService: IDefinedNamesService, _lexerTreeBuilder: LexerTreeBuilder, _formulaCurrentConfigService: IFormulaCurrentConfigService);
25
- treeBuilder(formulaString: string, transformSuffix?: boolean): import("../..").ErrorType.VALUE | import("./lexer-node").LexerNode | (string | import("./lexer-node").LexerNode)[] | undefined;
26
+ treeBuilder(formulaString: string, transformSuffix?: boolean, unitId?: Nullable<string>): import("../..").ErrorType.VALUE | import("./lexer-node").LexerNode | (string | import("./lexer-node").LexerNode)[] | undefined;
26
27
  }
@@ -14,10 +14,10 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { Nullable } from '@univerjs/core';
17
- import type { BaseAstNode } from '../ast-node/base-ast-node';
18
17
  import { Disposable } from '@univerjs/core';
19
18
  import { IFormulaRuntimeService } from '../../services/runtime.service';
20
19
  import { AstRootNodeFactory } from '../ast-node/ast-root-node';
20
+ import { BaseAstNode } from '../ast-node/base-ast-node';
21
21
  import { FunctionNodeFactory } from '../ast-node/function-node';
22
22
  import { LambdaNodeFactory } from '../ast-node/lambda-node';
23
23
  import { LambdaParameterNodeFactory } from '../ast-node/lambda-parameter-node';
@@ -48,5 +48,6 @@ export declare class AstTreeBuilder extends Disposable {
48
48
  private _changeLetToLambda;
49
49
  private _parse;
50
50
  private _checkAstNode;
51
+ private _createGroupByAggregatorTokenNode;
51
52
  private _initializeAstNode;
52
53
  }
@@ -35,11 +35,14 @@ export declare class FunctionNode extends BaseAstNode {
35
35
  get nodeType(): NodeType;
36
36
  executeAsync(): Promise<AstNodePromiseType>;
37
37
  execute(): void;
38
+ private _collectVariants;
39
+ private _getChildVariant;
38
40
  isFunctionExecutorArgumentsIgnoreNumberPattern(): boolean;
39
41
  /**
40
42
  * If it contains an array formula, set the current cell to the cache and send itself as a ref outward
41
43
  */
42
44
  private _setEmbeddedArrayFormulaToResult;
45
+ private _normalizeTopLevelLegacyArrayResult;
43
46
  /**
44
47
  * Compatibility handling for special functions.
45
48
  */
@@ -59,6 +62,7 @@ export declare class FunctionNode extends BaseAstNode {
59
62
  private _handleAddressFunction;
60
63
  private _mapVariantsToValues;
61
64
  private _calculate;
65
+ private _calculateAst;
62
66
  private _calculateAsync;
63
67
  private _setDefinedNamesForFunction;
64
68
  private _setRefInfo;
@@ -26,6 +26,7 @@ export declare class OperatorNode extends BaseAstNode {
26
26
  constructor(operatorString: string, _functionExecutor: BaseFunction, _runtimeService: IFormulaRuntimeService);
27
27
  get nodeType(): NodeType;
28
28
  execute(): void;
29
+ private _referenceToOperatorValue;
29
30
  /**
30
31
  * If it contains an array formula, set the current cell to the cache and send itself as a ref outward
31
32
  */
@@ -29,6 +29,7 @@ export declare class PrefixNode extends BaseAstNode {
29
29
  get nodeType(): NodeType;
30
30
  execute(): void;
31
31
  private _handlerAT;
32
+ private _preserveAtRangeForFormula2LookupArray;
32
33
  }
33
34
  export declare class PrefixNodeFactory extends BaseAstNodeFactory {
34
35
  private readonly _functionService;
@@ -30,4 +30,15 @@ export declare class Interpreter extends Disposable {
30
30
  private _checkAsyncNode;
31
31
  private _executeAsync;
32
32
  private _execute;
33
+ private _executeLazyFunctionAsync;
34
+ private _executeLazyFunction;
35
+ private _executeLazyIfAsync;
36
+ private _executeLazyIf;
37
+ private _executeLazyIfErrorAsync;
38
+ private _executeLazyIfError;
39
+ private _toLazyIfErrorValue;
40
+ private _toLazyIfSelectedValue;
41
+ private _implicitLazyIfReferenceValue;
42
+ private _preserveLazyIfSelectedReferenceArray;
43
+ private _implicitLazyIfArrayValue;
33
44
  }
@@ -20,6 +20,7 @@ import { RangeReferenceObject } from './range-reference-object';
20
20
  export declare class CellReferenceObject extends BaseReferenceObject {
21
21
  constructor(token: string);
22
22
  isCell(): boolean;
23
+ isExceedRange(): boolean;
23
24
  unionBy(referenceObject: BaseReferenceObject): ErrorValueObject | RangeReferenceObject;
24
25
  unionRange(rangeData1: IRange, rangeData2: IRange): IRange;
25
26
  private _createRange;
@@ -21,5 +21,5 @@ import type { AstRootNode } from '../ast-node/ast-root-node';
21
21
  import type { IFormulaDependencyTree } from '../dependency/dependency-tree';
22
22
  import { FormulaAstLRU } from '../../basics/cache-lru';
23
23
  export declare const FORMULA_AST_CACHE: FormulaAstLRU<AstRootNode>;
24
- export declare function generateAstNode(unitId: string, formulaString: string, lexer: Lexer, astTreeBuilder: AstTreeBuilder, currentConfigService: IFormulaCurrentConfigService): AstRootNode;
24
+ export declare function generateAstNode(unitId: string, formulaString: string, lexer: Lexer, astTreeBuilder: AstTreeBuilder, currentConfigService: IFormulaCurrentConfigService, subUnitId?: string): AstRootNode;
25
25
  export declare function includeDefinedName(tree: IFormulaDependencyTree, node: Nullable<AstRootNode>, currentConfigService: IFormulaCurrentConfigService): boolean;
@@ -13,6 +13,11 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ /**
17
+ * Since Excel follows the IEEE 754 specification, it only handles precision issues when displaying cells. For example, =0.1+0.2, the stored value in XML is 0.30000000000000004, and the displayed value is 0.3. The accuracy of the calculation process does not need to be considered. We only focus on the accuracy of the calculation results. Any result is processed within 15 digits.
18
+
19
+ Reference https://en.wikipedia.org/wiki/Numeric_precision_in_Microsoft_Excel
20
+ */
16
21
  export declare function plus(a: number, b: number): number;
17
22
  export declare function minus(a: number, b: number): number;
18
23
  export declare function multiply(a: number, b: number): number;
@@ -41,6 +41,8 @@ export declare class ArrayValueObject extends BaseValueObject {
41
41
  private _sheetId;
42
42
  private _currentRow;
43
43
  private _currentColumn;
44
+ private _useInvertedIndexCache;
45
+ private _legacyImplicitForAggregate;
44
46
  private _sliceCache;
45
47
  private _flattenCache;
46
48
  /**
@@ -62,6 +64,9 @@ export declare class ArrayValueObject extends BaseValueObject {
62
64
  getSheetId(): string;
63
65
  getCurrentRow(): number;
64
66
  getCurrentColumn(): number;
67
+ usesInvertedIndexCache(): boolean;
68
+ usesLegacyImplicitForAggregate(): boolean;
69
+ setLegacyImplicitForAggregate(value: boolean): void;
65
70
  getArrayValue(): Nullable<BaseValueObject>[][];
66
71
  setArrayValue(value: BaseValueObject[][]): void;
67
72
  isArray(): boolean;
@@ -28,6 +28,8 @@ export interface IArrayValueObject {
28
28
  sheetId: string;
29
29
  row: number;
30
30
  column: number;
31
+ legacyImplicitForAggregate?: boolean;
32
+ useInvertedIndexCache?: boolean;
31
33
  }
32
34
  export declare class BaseValueObject extends ObjectClassType {
33
35
  private _rawValue;
@@ -158,6 +160,8 @@ export declare class BaseValueObject extends ObjectClassType {
158
160
  convertToNumberObjectValue(): BaseValueObject;
159
161
  convertToBooleanObjectValue(): BaseValueObject;
160
162
  }
163
+ export declare function formatValueForFormulaText(value: string | number | boolean | null): string;
164
+ export declare function formatNumberForFormulaText(value: number): string;
161
165
  export declare const ErrorValueObjectCache: FormulaAstLRU<ErrorValueObject>;
162
166
  export declare class ErrorValueObject extends BaseValueObject {
163
167
  private _errorType;
@@ -169,4 +173,6 @@ export declare class ErrorValueObject extends BaseValueObject {
169
173
  getErrorContent(): string;
170
174
  isEqualType(object: ObjectClassType): boolean;
171
175
  isError(): boolean;
176
+ concatenateFront(_valueObject: BaseValueObject): BaseValueObject;
177
+ concatenateBack(_valueObject: BaseValueObject): BaseValueObject;
172
178
  }
@@ -119,10 +119,13 @@ export declare class FFormula extends FBase {
119
119
  calculationEnd(callback: (functionsExecutedState: FormulaExecutedStateType) => void): IDisposable;
120
120
  /**
121
121
  * @deprecated Use `onCalculationResultApplied` instead.
122
+ * @param {number} [timeout] The timeout in milliseconds. Defaults to 30000.
123
+ * @returns {Promise<boolean>} Whether computing completed before timeout.
122
124
  */
123
125
  whenComputingCompleteAsync(timeout?: number): Promise<boolean>;
124
126
  /**
125
127
  * @deprecated Use `onCalculationResultApplied` instead.
128
+ * @returns {Promise<void>} A promise that resolves when calculation ends.
126
129
  */
127
130
  onCalculationEnd(): Promise<void>;
128
131
  /**
@@ -249,11 +252,11 @@ export declare class FFormula extends FBase {
249
252
  * dependency-calculation command for the given unit, sheet, and cell location,
250
253
  * and returns the computed dependency tree when the calculation is completed.
251
254
  *
252
- * @param param The target cell location:
253
- * - `unitId` The workbook ID.
254
- * - `sheetId` The sheet ID.
255
- * - `row` The zero-based row index.
256
- * - `column` The zero-based column index.
255
+ * @param {object} param The target cell location.
256
+ * @param {string} param.unitId The workbook ID.
257
+ * @param {string} param.sheetId The sheet ID.
258
+ * @param {number} param.row The zero-based row index.
259
+ * @param {number} param.column The zero-based column index.
257
260
  *
258
261
  * @param {number} [timeout]
259
262
  * Optional timeout in milliseconds. If no result is received within this
@@ -462,6 +465,7 @@ export declare class FFormula extends FBase {
462
465
  * ```
463
466
  *
464
467
  * @param formulaString The formula string to parse (with or without leading `=`)
468
+ * @param unitId The workbook unit id used to resolve defined names and tables.
465
469
  * @returns A formula expression tree describing the hierarchical structure of the formula
466
470
  */
467
471
  getFormulaExpressTree(formulaString: string, unitId: string): IExprTreeNode | null;
@@ -15,6 +15,7 @@
15
15
  */
16
16
  import type { IRange, LocaleType, Nullable } from '@univerjs/core';
17
17
  import type { IFunctionNames } from '../basics/function';
18
+ import type { BaseAstNode } from '../engine/ast-node/base-ast-node';
18
19
  import type { BaseReferenceObject, FunctionVariantType, NodeValueType } from '../engine/reference-object/base-reference-object';
19
20
  import type { ArrayBinarySearchType } from '../engine/utils/compare';
20
21
  import type { ArrayValueObject } from '../engine/value-object/array-value-object';
@@ -30,6 +31,8 @@ export declare class BaseFunction {
30
31
  private _subUnitId;
31
32
  private _row;
32
33
  private _column;
34
+ private _currentFormulaRowCount;
35
+ private _currentFormulaColumnCount;
33
36
  private _definedNames;
34
37
  private _locale;
35
38
  private _sheetOrder;
@@ -65,6 +68,15 @@ export declare class BaseFunction {
65
68
  * Whether the function needs to filter out rows
66
69
  */
67
70
  needsFilteredOutRows: boolean;
71
+ /**
72
+ * Whether the function needs unevaluated AST children.
73
+ */
74
+ needsAstChildren: boolean;
75
+ /**
76
+ * Legacy CSE-style array functions should write only the first result cell
77
+ * when they are used as a top-level normal formula.
78
+ */
79
+ returnsLegacyArrayAsScalar: boolean;
68
80
  /**
69
81
  * Minimum number of parameters
70
82
  */
@@ -79,6 +91,8 @@ export declare class BaseFunction {
79
91
  get subUnitId(): Nullable<string>;
80
92
  get row(): number;
81
93
  get column(): number;
94
+ get currentFormulaRowCount(): number;
95
+ get currentFormulaColumnCount(): number;
82
96
  dispose(): void;
83
97
  /**
84
98
  * In Excel, to inject a defined name into a function that has positioning capabilities,
@@ -108,9 +122,10 @@ export declare class BaseFunction {
108
122
  isAddress(): boolean;
109
123
  isCustom(): boolean;
110
124
  isArgumentsIgnoreNumberPattern(): boolean;
111
- setRefInfo(unitId: string, subUnitId: string, row: number, column: number): void;
125
+ setRefInfo(unitId: string, subUnitId: string, row: number, column: number, rowCount?: number, columnCount?: number): void;
112
126
  calculateCustom(...arg: Array<FormulaFunctionValueType>): FormulaFunctionResultValueType | Promise<FormulaFunctionResultValueType>;
113
127
  calculate(...arg: BaseValueObject[]): NodeValueType;
128
+ calculateAst(_children: BaseAstNode[], _getVariant: (node: BaseAstNode) => Nullable<FunctionVariantType>): NodeValueType;
114
129
  checkArrayType(variant: FunctionVariantType): boolean;
115
130
  /**
116
131
  * Starting with 1
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { NotImplementedFunction } from '../../not-implemented-function';
17
+ export declare class Cubekpimember extends NotImplementedFunction {
18
+ minParams: number;
19
+ maxParams: number;
20
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { NotImplementedFunction } from '../../not-implemented-function';
17
+ export declare class Cubemember extends NotImplementedFunction {
18
+ minParams: number;
19
+ maxParams: number;
20
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { NotImplementedFunction } from '../../not-implemented-function';
17
+ export declare class Cubememberproperty extends NotImplementedFunction {
18
+ minParams: number;
19
+ maxParams: number;
20
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { NotImplementedFunction } from '../../not-implemented-function';
17
+ export declare class Cuberankedmember extends NotImplementedFunction {
18
+ minParams: number;
19
+ maxParams: number;
20
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { NotImplementedFunction } from '../../not-implemented-function';
17
+ export declare class Cubeset extends NotImplementedFunction {
18
+ minParams: number;
19
+ maxParams: number;
20
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { NotImplementedFunction } from '../../not-implemented-function';
17
+ export declare class Cubesetcount extends NotImplementedFunction {
18
+ minParams: number;
19
+ maxParams: number;
20
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { NotImplementedFunction } from '../../not-implemented-function';
17
+ export declare class Cubevalue extends NotImplementedFunction {
18
+ minParams: number;
19
+ maxParams: number;
20
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { NotImplementedFunction } from '../../not-implemented-function';
17
+ export declare class Amordegrc extends NotImplementedFunction {
18
+ minParams: number;
19
+ maxParams: number;
20
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { NotImplementedFunction } from '../../not-implemented-function';
17
+ export declare class Info extends NotImplementedFunction {
18
+ minParams: number;
19
+ maxParams: number;
20
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { NotImplementedFunction } from '../../not-implemented-function';
17
+ export declare class Isomitted extends NotImplementedFunction {
18
+ minParams: number;
19
+ maxParams: number;
20
+ }
@@ -15,7 +15,8 @@
15
15
  */
16
16
  import { And } from './and';
17
17
  import { FUNCTION_NAMES_LOGICAL } from './function-names';
18
+ import { Groupby } from './groupby';
18
19
  import { If } from './if';
19
- import { Iferror } from './iferror';
20
+ import { Ifna } from './ifna';
20
21
  import { Makearray } from './makearray';
21
- export declare const functionLogical: ((FUNCTION_NAMES_LOGICAL | typeof And)[] | (FUNCTION_NAMES_LOGICAL | typeof If)[] | (FUNCTION_NAMES_LOGICAL | typeof Iferror)[] | (FUNCTION_NAMES_LOGICAL | typeof Makearray)[])[];
22
+ export declare const functionLogical: ((FUNCTION_NAMES_LOGICAL | typeof And)[] | (FUNCTION_NAMES_LOGICAL | typeof Groupby)[] | (FUNCTION_NAMES_LOGICAL | typeof If)[] | (FUNCTION_NAMES_LOGICAL | typeof Ifna)[] | (FUNCTION_NAMES_LOGICAL | typeof Makearray)[])[];
@@ -18,6 +18,7 @@ export declare enum FUNCTION_NAMES_LOGICAL {
18
18
  BYCOL = "BYCOL",
19
19
  BYROW = "BYROW",
20
20
  FALSE = "FALSE",
21
+ GROUPBY = "GROUPBY",
21
22
  IF = "IF",
22
23
  IFERROR = "IFERROR",
23
24
  IFNA = "IFNA",
@@ -28,6 +29,7 @@ export declare enum FUNCTION_NAMES_LOGICAL {
28
29
  MAP = "MAP",
29
30
  NOT = "NOT",
30
31
  OR = "OR",
32
+ PERCENTOF = "PERCENTOF",
31
33
  REDUCE = "REDUCE",
32
34
  SCAN = "SCAN",
33
35
  SWITCH = "SWITCH",
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { BaseAstNode } from '../../../engine/ast-node/base-ast-node';
17
+ import type { FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
18
+ import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
19
+ import { ErrorValueObject } from '../../../engine/value-object/base-value-object';
20
+ import { BaseFunction } from '../../base-function';
21
+ export declare class Groupby extends BaseFunction {
22
+ minParams: number;
23
+ maxParams: number;
24
+ needsReferenceObject: boolean;
25
+ needsAstChildren: boolean;
26
+ calculateAst(children: BaseAstNode[], getVariant: (node: BaseAstNode) => FunctionVariantType | null): ErrorValueObject | ArrayValueObject;
27
+ private _arrayInput;
28
+ private _aggregators;
29
+ private _normalizedFunctionName;
30
+ private _isAggregatorName;
31
+ private _outputValueColumnCount;
32
+ private _valueColumnForOutput;
33
+ private _aggregatorForOutput;
34
+ private _aggregatorHeader;
35
+ private _applyAggregator;
36
+ private _sum;
37
+ private _numericValue;
38
+ private _numberValue;
39
+ private _truthy;
40
+ private _keysEqual;
41
+ private _keyValue;
42
+ private _sortGroups;
43
+ private _compareKey;
44
+ private _compareValue;
45
+ private _textValue;
46
+ }
@@ -21,4 +21,9 @@ export declare class If extends BaseFunction {
21
21
  maxParams: number;
22
22
  calculate(logicalTest: BaseValueObject, valueIfTrue: BaseValueObject, valueIfFalse?: BaseValueObject): BaseValueObject | ArrayValueObject;
23
23
  private _handleSingleObject;
24
+ private _coerceSelectedValue;
25
+ private _coerceLogicalTest;
26
+ private _legacyImplicitSelectedValue;
27
+ private _legacyImplicitArrayValue;
28
+ private _isCurrentArrayFormula;
24
29
  }