@univerjs/engine-formula 0.1.6 → 0.1.8

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 (46) hide show
  1. package/lib/cjs/index.js +1 -1
  2. package/lib/es/index.js +3715 -3356
  3. package/lib/types/basics/common.d.ts +9 -8
  4. package/lib/types/commands/mutations/set-array-formula-data.mutation.d.ts +3 -2
  5. package/lib/types/commands/mutations/set-defined-name.mutation.d.ts +1 -7
  6. package/lib/types/commands/mutations/set-formula-calculation.mutation.d.ts +1 -2
  7. package/lib/types/commands/mutations/set-formula-data.mutation.d.ts +3 -0
  8. package/lib/types/controller/calculate.controller.d.ts +2 -2
  9. package/lib/types/controller/set-dependency.controller.d.ts +10 -0
  10. package/lib/types/controller/set-other-formula.controller.d.ts +3 -1
  11. package/lib/types/engine/analysis/__tests__/create-command-test-bed.d.ts +3 -3
  12. package/lib/types/engine/analysis/lexer-tree-builder.d.ts +6 -2
  13. package/lib/types/engine/ast-node/function-node.d.ts +6 -2
  14. package/lib/types/engine/ast-node/reference-node.d.ts +1 -0
  15. package/lib/types/engine/dependency/dependency-tree.d.ts +2 -0
  16. package/lib/types/engine/dependency/formula-dependency.d.ts +9 -1
  17. package/lib/types/engine/reference-object/base-reference-object.d.ts +16 -6
  18. package/lib/types/engine/utils/reference.d.ts +10 -1
  19. package/lib/types/engine/utils/sequence.d.ts +2 -1
  20. package/lib/types/engine/utils/value-object.d.ts +7 -0
  21. package/lib/types/engine/value-object/array-value-object.d.ts +7 -1
  22. package/lib/types/functions/__tests__/create-function-test-bed.d.ts +3 -3
  23. package/lib/types/functions/base-function.d.ts +12 -0
  24. package/lib/types/functions/information/iseven/iseven.d.ts +7 -0
  25. package/lib/types/functions/information/iseven/iseven.spec.d.ts +16 -0
  26. package/lib/types/functions/information/isodd/isodd.d.ts +7 -0
  27. package/lib/types/functions/information/isodd/isodd.spec.d.ts +16 -0
  28. package/lib/types/functions/information/isref/index.d.ts +1 -1
  29. package/lib/types/functions/lookup/indirect/index.d.ts +8 -0
  30. package/lib/types/functions/math/subtotal/index.d.ts +1 -1
  31. package/lib/types/functions/statistical/maxifs/__tests__/index.spec.d.ts +16 -0
  32. package/lib/types/functions/statistical/maxifs/index.d.ts +7 -0
  33. package/lib/types/functions/text/lower/__test__/index.spec.d.ts +16 -0
  34. package/lib/types/functions/text/lower/index.d.ts +7 -0
  35. package/lib/types/index.d.ts +6 -7
  36. package/lib/types/models/__tests__/create-command-test-bed.d.ts +1 -1
  37. package/lib/types/models/formula-data.model.d.ts +16 -17
  38. package/lib/types/models/utils/formula-data-util.d.ts +10 -0
  39. package/lib/types/plugin.d.ts +1 -1
  40. package/lib/types/services/current-data.service.d.ts +9 -5
  41. package/lib/types/services/defined-names.service.d.ts +2 -0
  42. package/lib/types/services/dependency-manager.service.d.ts +74 -0
  43. package/lib/types/services/runtime.service.d.ts +1 -5
  44. package/lib/umd/index.js +1 -1
  45. package/package.json +9 -9
  46. package/lib/types/commands/mutations/set-numfmt-formula-data.mutation.d.ts +0 -7
@@ -1,4 +1,4 @@
1
- import { BooleanNumber, ICellData, IColumnData, IObjectArrayPrimitiveType, IObjectMatrixPrimitiveType, IRange, IRowData, IUnitRange, Nullable, ObjectMatrix } from '@univerjs/core';
1
+ import { BooleanNumber, ICellData, IColumnData, IObjectArrayPrimitiveType, IObjectMatrixPrimitiveType, IRange, IRowData, IUnitRange, Nullable, ObjectMatrix, Styles } from '@univerjs/core';
2
2
 
3
3
  export declare const ERROR_VALUE_OBJECT_CLASS_TYPE = "errorValueObject";
4
4
  export declare const ASYNC_OBJECT_CLASS_TYPE = "asyncObject";
@@ -29,6 +29,12 @@ export interface ISheetData {
29
29
  export interface IUnitData {
30
30
  [unitId: string]: ISheetData;
31
31
  }
32
+ /**
33
+ * Style data, numfmt needs to be queried from the style sheet
34
+ */
35
+ export interface IUnitStylesData {
36
+ [unitId: string]: Styles;
37
+ }
32
38
  export interface IRuntimeUnitDataType {
33
39
  [unitId: string]: Nullable<{
34
40
  [sheetId: string]: ObjectMatrix<Nullable<ICellData>>;
@@ -94,7 +100,7 @@ export interface IArrayFormulaUnitCellType extends IRuntimeUnitDataPrimitiveType
94
100
  }
95
101
  export interface IFormulaData {
96
102
  [unitId: string]: Nullable<{
97
- [sheetId: string]: IObjectMatrixPrimitiveType<IFormulaDataItem>;
103
+ [sheetId: string]: Nullable<IObjectMatrixPrimitiveType<Nullable<IFormulaDataItem>>>;
98
104
  }>;
99
105
  }
100
106
  export interface IOtherFormulaData {
@@ -104,11 +110,6 @@ export interface IOtherFormulaData {
104
110
  }>;
105
111
  }>;
106
112
  }
107
- export interface INumfmtItemMap {
108
- [unitId: string]: Nullable<{
109
- [sheetId: string]: IObjectMatrixPrimitiveType<Nullable<string>>;
110
- }>;
111
- }
112
113
  /**
113
114
  * @f formulaString, the text string of the formula.
114
115
  * @si The formula ID can be utilized in scenarios such as copy-pasting and drag-filling to convert formulas into references, eliminating the need for recreating the formulaString.
@@ -145,9 +146,9 @@ export interface IFormulaDatasetConfig {
145
146
  dirtyDefinedNameMap: IDirtyUnitSheetNameMap;
146
147
  dirtyUnitFeatureMap: IDirtyUnitFeatureMap;
147
148
  dirtyUnitOtherFormulaMap: IDirtyUnitOtherFormulaMap;
148
- numfmtItemMap: INumfmtItemMap;
149
149
  excludedCell?: IUnitExcludedCell;
150
150
  allUnitData?: IUnitData;
151
+ unitStylesData?: IUnitStylesData;
151
152
  unitSheetNameMap?: IUnitSheetNameMap;
152
153
  }
153
154
  export declare enum ConcatenateType {
@@ -1,10 +1,11 @@
1
1
  import { IArrayFormulaRangeType, IArrayFormulaUnitCellType } from '../../basics/common';
2
- import { IAccessor } from '@wendellhu/redi';
3
2
  import { IMutation } from '@univerjs/core';
4
3
 
5
4
  export interface ISetArrayFormulaDataMutationParams {
6
5
  arrayFormulaRange: IArrayFormulaRangeType;
7
6
  arrayFormulaCellData: IArrayFormulaUnitCellType;
8
7
  }
9
- export declare const SetArrayFormulaDataUndoMutationFactory: (accessor: IAccessor) => ISetArrayFormulaDataMutationParams;
8
+ /**
9
+ * There is no need to process data here, it is used as the main thread to send data to the worker. The main thread has already updated the data in advance, and there is no need to update it again here.
10
+ */
10
11
  export declare const SetArrayFormulaDataMutation: IMutation<ISetArrayFormulaDataMutationParams>;
@@ -1,4 +1,4 @@
1
- import { IMutation, IRange } from '@univerjs/core';
1
+ import { IMutation } from '@univerjs/core';
2
2
 
3
3
  export interface ISetDefinedNameMutationSearchParam {
4
4
  unitId: string;
@@ -17,9 +17,3 @@ export interface ISetDefinedNameMutationParam extends ISetDefinedNameMutationSea
17
17
  */
18
18
  export declare const SetDefinedNameMutation: IMutation<ISetDefinedNameMutationParam>;
19
19
  export declare const RemoveDefinedNameMutation: IMutation<ISetDefinedNameMutationParam>;
20
- export interface ISetDefinedNameCurrentMutationParam {
21
- unitId: string;
22
- sheetId: string;
23
- range: IRange;
24
- }
25
- export declare const SetDefinedNameCurrentMutation: IMutation<ISetDefinedNameCurrentMutationParam>;
@@ -1,5 +1,5 @@
1
1
  import { FormulaExecutedStateType, IExecutionInProgressParams } from '../../services/runtime.service';
2
- import { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, INumfmtItemMap, IRuntimeOtherUnitDataType, IRuntimeUnitDataPrimitiveType } from '../../basics/common';
2
+ import { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IRuntimeOtherUnitDataType, IRuntimeUnitDataPrimitiveType } from '../../basics/common';
3
3
  import { IExecutionOptions, IMutation, IUnitRange, Nullable } from '@univerjs/core';
4
4
 
5
5
  export interface ISetFormulaCalculationStartMutation {
@@ -9,7 +9,6 @@ export interface ISetFormulaCalculationStartMutation {
9
9
  dirtyUnitFeatureMap: IDirtyUnitFeatureMap;
10
10
  dirtyUnitOtherFormulaMap: IDirtyUnitOtherFormulaMap;
11
11
  options: Nullable<IExecutionOptions>;
12
- numfmtItemMap: INumfmtItemMap;
13
12
  forceCalculation?: boolean;
14
13
  }
15
14
  /**
@@ -4,4 +4,7 @@ import { IMutation } from '@univerjs/core';
4
4
  export interface ISetFormulaDataMutationParams {
5
5
  formulaData: IFormulaData;
6
6
  }
7
+ /**
8
+ * There is no need to process data here, it is used as the main thread to send data to the worker. The main thread has already updated the data in advance, and there is no need to update it again here.
9
+ */
7
10
  export declare const SetFormulaDataMutation: IMutation<ISetFormulaDataMutationParams>;
@@ -5,9 +5,9 @@ import { Disposable, ICommandService, IUniverInstanceService } from '@univerjs/c
5
5
  export declare class CalculateController extends Disposable {
6
6
  private readonly _commandService;
7
7
  private readonly _calculateFormulaService;
8
- private readonly _currentUniverService;
8
+ private readonly _univerInstanceService;
9
9
  private readonly _formulaDataModel;
10
- constructor(_commandService: ICommandService, _calculateFormulaService: CalculateFormulaService, _currentUniverService: IUniverInstanceService, _formulaDataModel: FormulaDataModel);
10
+ constructor(_commandService: ICommandService, _calculateFormulaService: CalculateFormulaService, _univerInstanceService: IUniverInstanceService, _formulaDataModel: FormulaDataModel);
11
11
  private _initialize;
12
12
  private _commandExecutedListener;
13
13
  private _calculate;
@@ -0,0 +1,10 @@
1
+ import { IDependencyManagerService } from '../services/dependency-manager.service';
2
+ import { Disposable, ICommandService } from '@univerjs/core';
3
+
4
+ export declare class SetDependencyController extends Disposable {
5
+ private readonly _commandService;
6
+ private readonly _dependencyManagerService;
7
+ constructor(_commandService: ICommandService, _dependencyManagerService: IDependencyManagerService);
8
+ private _initialize;
9
+ private _commandExecutedListener;
10
+ }
@@ -1,10 +1,12 @@
1
+ import { IDependencyManagerService } from '../services/dependency-manager.service';
1
2
  import { IOtherFormulaManagerService } from '../services/other-formula-manager.service';
2
3
  import { Disposable, ICommandService } from '@univerjs/core';
3
4
 
4
5
  export declare class SetOtherFormulaController extends Disposable {
5
6
  private readonly _commandService;
6
7
  private readonly _otherFormulaManagerService;
7
- constructor(_commandService: ICommandService, _otherFormulaManagerService: IOtherFormulaManagerService);
8
+ private readonly _dependencyManagerService;
9
+ constructor(_commandService: ICommandService, _otherFormulaManagerService: IOtherFormulaManagerService, _dependencyManagerService: IDependencyManagerService);
8
10
  private _initialize;
9
11
  private _commandExecutedListener;
10
12
  }
@@ -1,8 +1,8 @@
1
1
  import { ISheetData } from '../../../basics/common';
2
2
  import { Dependency } from '@wendellhu/redi';
3
- import { IWorkbookData, Univer } from '@univerjs/core';
3
+ import { IWorkbookData, Workbook, Univer } from '@univerjs/core';
4
4
 
5
- export declare function createCommandTestBed(workbookConfig?: IWorkbookData, dependencies?: Dependency[]): {
5
+ export declare function createCommandTestBed(workbookData?: IWorkbookData, dependencies?: Dependency[]): {
6
6
  univer: Univer;
7
7
  get: {
8
8
  <T>(id: import('@wendellhu/redi').DependencyIdentifier<T>, lookUp?: import('@wendellhu/redi').LookUp | undefined): T;
@@ -12,7 +12,7 @@ export declare function createCommandTestBed(workbookConfig?: IWorkbookData, dep
12
12
  <T_4>(id: import('@wendellhu/redi').DependencyIdentifier<T_4>, quantity?: import('@wendellhu/redi').Quantity | undefined, lookUp?: import('@wendellhu/redi').LookUp | undefined): T_4 | T_4[] | null;
13
13
  <T_5>(id: import('@wendellhu/redi').DependencyIdentifier<T_5>, quantityOrLookup?: import('@wendellhu/redi').Quantity | import('@wendellhu/redi').LookUp | undefined, lookUp?: import('@wendellhu/redi').LookUp | undefined): T_5 | T_5[] | null;
14
14
  };
15
- sheet: import('@univerjs/core').Workbook;
15
+ sheet: Workbook;
16
16
  unitId: string;
17
17
  sheetId: string;
18
18
  sheetData: ISheetData;
@@ -34,15 +34,16 @@ export declare class LexerTreeBuilder extends Disposable {
34
34
  functionName: string;
35
35
  paramIndex: number;
36
36
  } | undefined;
37
- moveFormulaRefOffset(formulaString: string, refOffsetX: number, refOffsetY: number): string;
38
37
  /**
39
38
  * Estimate the number of right brackets that need to be automatically added to the end of the formula.
40
39
  * @param formulaString
41
40
  */
42
41
  checkIfAddBracket(formulaString: string): number;
43
- convertRefersToAbsolute(formulaString: string, startAbsoluteRefType: AbsoluteRefType, endAbsoluteRefType: AbsoluteRefType): string;
44
42
  sequenceNodesBuilder(formulaString: string): (string | ISequenceNode)[] | undefined;
43
+ convertRefersToAbsolute(formulaString: string, startAbsoluteRefType: AbsoluteRefType, endAbsoluteRefType: AbsoluteRefType): string;
44
+ moveFormulaRefOffset(formulaString: string, refOffsetX: number, refOffsetY: number, ignoreAbsolute?: boolean): string;
45
45
  getSequenceNode(sequenceArray: ISequenceArray[]): (string | ISequenceNode)[];
46
+ private _processPushSequenceNode;
46
47
  private _getCurrentParamIndex;
47
48
  private _isLastMergeString;
48
49
  /**
@@ -59,6 +60,8 @@ export declare class LexerTreeBuilder extends Disposable {
59
60
  definedNames: string[];
60
61
  }, simpleCheckDefinedName?: (formulaString: string) => boolean): ErrorType.VALUE | LexerNode | (string | LexerNode)[] | undefined;
61
62
  private _suffixExpressionHandler;
63
+ private _processSuffixExpressionRemain;
64
+ private _processSuffixExpressionCloseBracket;
62
65
  private _checkCloseBracket;
63
66
  private _checkOpenBracket;
64
67
  private _checkOperator;
@@ -101,5 +104,6 @@ export declare class LexerTreeBuilder extends Disposable {
101
104
  private _resetTemp;
102
105
  private _checkSimilarErrorToken;
103
106
  private _nodeMaker;
107
+ private _isScientificNotation;
104
108
  private _addSequenceArray;
105
109
  }
@@ -1,6 +1,7 @@
1
1
  import { NodeType } from './node-type';
2
2
  import { BaseAstNodeFactory } from './base-ast-node-factory';
3
3
  import { BaseAstNode } from './base-ast-node';
4
+ import { IDefinedNamesService } from '../../services/defined-names.service';
4
5
  import { LexerNode } from '../analysis/lexer-node';
5
6
  import { IFormulaRuntimeService } from '../../services/runtime.service';
6
7
  import { IFunctionService } from '../../services/function.service';
@@ -13,7 +14,8 @@ export declare class FunctionNode extends BaseAstNode {
13
14
  private _functionExecutor;
14
15
  private _currentConfigService;
15
16
  private _runtimeService;
16
- constructor(token: string, _functionExecutor: BaseFunction, _currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService);
17
+ private _definedNamesService;
18
+ constructor(token: string, _functionExecutor: BaseFunction, _currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, _definedNamesService: IDefinedNamesService);
17
19
  get nodeType(): NodeType;
18
20
  executeAsync(): Promise<AstNodePromiseType>;
19
21
  execute(): void;
@@ -30,6 +32,7 @@ export declare class FunctionNode extends BaseAstNode {
30
32
  */
31
33
  private _lookupCompatibility;
32
34
  private _calculate;
35
+ private _setDefinedNamesForFunction;
33
36
  private _setRefInfo;
34
37
  private _setRefData;
35
38
  }
@@ -37,8 +40,9 @@ export declare class FunctionNodeFactory extends BaseAstNodeFactory {
37
40
  private readonly _functionService;
38
41
  private readonly _currentConfigService;
39
42
  private readonly _runtimeService;
43
+ private readonly _definedNamesService;
40
44
  private readonly _injector;
41
- constructor(_functionService: IFunctionService, _currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, _injector: Injector);
45
+ constructor(_functionService: IFunctionService, _currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, _definedNamesService: IDefinedNamesService, _injector: Injector);
42
46
  get zIndex(): number;
43
47
  create(token: string): BaseAstNode;
44
48
  checkAndCreateNodeType(param: LexerNode | string): BaseAstNode | undefined;
@@ -25,4 +25,5 @@ export declare class ReferenceNodeFactory extends BaseAstNodeFactory {
25
25
  constructor(_superTableService: ISuperTableService, _formulaRuntimeService: IFormulaRuntimeService, _functionService: IFunctionService, _injector: Injector);
26
26
  get zIndex(): number;
27
27
  checkAndCreateNodeType(param: LexerNode | string): ReferenceNode | undefined;
28
+ private _checkParentIsUnionOperator;
28
29
  }
@@ -35,6 +35,7 @@ export declare class FormulaDependencyTree extends Disposable {
35
35
  }>;
36
36
  private _state;
37
37
  dispose(): void;
38
+ resetState(): void;
38
39
  setAdded(): void;
39
40
  isAdded(): boolean;
40
41
  setSkip(): void;
@@ -63,6 +64,7 @@ export declare class FormulaDependencyTreeCache extends Disposable {
63
64
  private _cacheItems;
64
65
  dispose(): void;
65
66
  size(): number;
67
+ get length(): number;
66
68
  add(unitRangeWithToken: IUnitRangeWithToken, tree: FormulaDependencyTree): void;
67
69
  clear(): void;
68
70
  remove(token: string, tree: FormulaDependencyTree): void;
@@ -1,4 +1,5 @@
1
1
  import { FormulaDependencyTree } from './dependency-tree';
2
+ import { IDependencyManagerService } from '../../services/dependency-manager.service';
2
3
  import { Interpreter } from '../interpreter/interpreter';
3
4
  import { AstRootNode } from '../ast-node';
4
5
  import { AstTreeBuilder } from '../analysis/parser';
@@ -19,9 +20,10 @@ export declare class FormulaDependencyGenerator extends Disposable {
19
20
  private readonly _interpreter;
20
21
  private readonly _astTreeBuilder;
21
22
  private readonly _lexer;
23
+ private readonly _dependencyManagerService;
22
24
  private _updateRangeFlattenCache;
23
25
  private _dirtyUnitSheetNameMap;
24
- constructor(_currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, _otherFormulaManagerService: IOtherFormulaManagerService, _featureCalculationManagerService: IFeatureCalculationManagerService, _interpreter: Interpreter, _astTreeBuilder: AstTreeBuilder, _lexer: Lexer);
26
+ constructor(_currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, _otherFormulaManagerService: IOtherFormulaManagerService, _featureCalculationManagerService: IFeatureCalculationManagerService, _interpreter: Interpreter, _astTreeBuilder: AstTreeBuilder, _lexer: Lexer, _dependencyManagerService: IDependencyManagerService);
25
27
  dispose(): void;
26
28
  generate(): Promise<FormulaDependencyTree[]>;
27
29
  private _isCyclicUtil;
@@ -31,6 +33,9 @@ export declare class FormulaDependencyGenerator extends Disposable {
31
33
  * @param formulaData
32
34
  */
33
35
  private _generateTreeList;
36
+ private _registerFeatureFormulas;
37
+ private _registerOtherFormulas;
38
+ private _registerFormulas;
34
39
  /**
35
40
  * Break down the dirty areas into ranges for subsequent matching.
36
41
  */
@@ -53,6 +58,9 @@ export declare class FormulaDependencyGenerator extends Disposable {
53
58
  * @param treeList
54
59
  */
55
60
  private _getUpdateTreeListAndMakeDependency;
61
+ private _includeTreeFeature;
62
+ private _includeOtherFormula;
63
+ private _includeDefinedName;
56
64
  /**
57
65
  * Determine whether all ranges of the current node exist within the dirty area.
58
66
  * If they are within the dirty area, return true, indicating that this node needs to be calculated.
@@ -2,7 +2,7 @@ import { NullValueObject, NumberValueObject } from '../value-object/primitive-ob
2
2
  import { BaseValueObject, ErrorValueObject } from '../value-object/base-value-object';
3
3
  import { ArrayValueObject } from '../value-object/array-value-object';
4
4
  import { ObjectClassType } from '../../basics/object-class-type';
5
- import { INumfmtItemMap, IRuntimeUnitDataType, IUnitData, IUnitSheetNameMap } from '../../basics/common';
5
+ import { IRuntimeUnitDataType, IUnitData, IUnitSheetNameMap, IUnitStylesData } from '../../basics/common';
6
6
  import { FormulaAstLRU } from '../../basics/cache-lru';
7
7
  import { ICellData, IRange, Nullable } from '@univerjs/core';
8
8
 
@@ -16,13 +16,13 @@ export declare class BaseReferenceObject extends ObjectClassType {
16
16
  private _defaultSheetId;
17
17
  private _rangeData;
18
18
  private _unitData;
19
+ private _unitStylesData;
19
20
  private _defaultUnitId;
20
21
  private _forcedUnitId;
21
22
  private _runtimeData;
22
23
  private _arrayFormulaCellData;
23
24
  private _runtimeArrayFormulaCellData;
24
25
  private _runtimeFeatureCellData;
25
- private _numfmtItemData;
26
26
  private _refOffsetX;
27
27
  private _refOffsetY;
28
28
  constructor(_token: string);
@@ -61,6 +61,8 @@ export declare class BaseReferenceObject extends ObjectClassType {
61
61
  getDefaultUnitId(): string;
62
62
  getUnitData(): IUnitData;
63
63
  setUnitData(unitData: IUnitData): void;
64
+ getUnitStylesData(): IUnitStylesData;
65
+ setUnitStylesData(unitStylesData: IUnitStylesData): void;
64
66
  getRuntimeData(): IRuntimeUnitDataType;
65
67
  setRuntimeData(runtimeData: IRuntimeUnitDataType): void;
66
68
  getArrayFormulaCellData(): IRuntimeUnitDataType;
@@ -73,14 +75,12 @@ export declare class BaseReferenceObject extends ObjectClassType {
73
75
  setRuntimeFeatureCellData(unitData: {
74
76
  [featureId: string]: IRuntimeUnitDataType;
75
77
  }): void;
76
- getNumfmtItemData(): INumfmtItemMap;
77
- setNumfmtItemData(numfmtItemData: INumfmtItemMap): void;
78
78
  getActiveSheetRowCount(): number;
79
79
  getActiveSheetColumnCount(): number;
80
80
  getRowCount(): number;
81
81
  getColumnCount(): number;
82
- getRowData(): import('@univerjs/core').IObjectArrayPrimitiveType<Partial<import("@univerjs/core").IRowData>>;
83
- getColumnData(): import('@univerjs/core').IObjectArrayPrimitiveType<Partial<import("@univerjs/core").IColumnData>>;
82
+ getRowData(): import('@univerjs/core').IObjectArrayPrimitiveType<Partial<import('@univerjs/core').IRowData>>;
83
+ getColumnData(): import('@univerjs/core').IObjectArrayPrimitiveType<Partial<import('@univerjs/core').IColumnData>>;
84
84
  isCell(): boolean;
85
85
  isColumn(): boolean;
86
86
  isRow(): boolean;
@@ -92,12 +92,22 @@ export declare class BaseReferenceObject extends ObjectClassType {
92
92
  getCellByRow(row: number): ErrorValueObject | NullValueObject | NumberValueObject | import('../value-object/primitive-object').BooleanValueObject | import('../value-object/primitive-object').StringValueObject | ArrayValueObject;
93
93
  getCellByColumn(column: number): ErrorValueObject | NullValueObject | NumberValueObject | import('../value-object/primitive-object').BooleanValueObject | import('../value-object/primitive-object').StringValueObject | ArrayValueObject;
94
94
  getCurrentActiveSheetData(): import('../../basics/common').ISheetItem;
95
+ getCurrentStylesData(): import('@univerjs/core').Styles;
95
96
  getCurrentRuntimeSheetData(): import('@univerjs/core').ObjectMatrix<Nullable<ICellData>> | undefined;
96
97
  getCurrentActiveArrayFormulaCellData(): import('@univerjs/core').ObjectMatrix<Nullable<ICellData>> | undefined;
97
98
  getCurrentRuntimeActiveArrayFormulaCellData(): import('@univerjs/core').ObjectMatrix<Nullable<ICellData>> | undefined;
98
99
  getCellData(row: number, column: number): ICellData;
99
100
  getRuntimeFeatureCellValue(row: number, column: number): ICellData | undefined;
100
101
  getCellByPosition(row?: number, column?: number): ErrorValueObject | NullValueObject | NumberValueObject | import('../value-object/primitive-object').BooleanValueObject | import('../value-object/primitive-object').StringValueObject | ArrayValueObject;
102
+ /**
103
+ * Get the pattern of the cell
104
+ * @param unitId
105
+ * @param sheetId
106
+ * @param row
107
+ * @param column
108
+ * @returns
109
+ */
110
+ getCellPattern(unitId: string, sheetId: string, row: number, column: number): string;
101
111
  toArrayValueObject(useCache?: boolean): ArrayValueObject;
102
112
  toUnitRange(): {
103
113
  range: {
@@ -1,4 +1,4 @@
1
- import { IRange, IUnitRangeName, AbsoluteRefType } from '@univerjs/core';
1
+ import { IRange, IUnitRangeName, IUnitRangeWithName, AbsoluteRefType } from '@univerjs/core';
2
2
 
3
3
  export interface IAbsoluteRefTypeForRange {
4
4
  startAbsoluteRefType: AbsoluteRefType;
@@ -39,6 +39,15 @@ export declare function handleRefStringInfo(refString: string): {
39
39
  unitId: string;
40
40
  };
41
41
  export declare function deserializeRangeWithSheet(refString: string): IUnitRangeName;
42
+ export declare function isReferenceStringWithEffectiveColumn(refString: string): boolean;
43
+ /**
44
+ * implement getSheetIdByName
45
+ * function getSheetIdByName(name: string) {
46
+ return univerInstanceService.getCurrentUnitForType<Workbook>(UniverInstanceType.UNIVER_SHEET)?.getSheetBySheetName(name)?.getSheetId() || '';
47
+ }
48
+ */
49
+ export declare function getRangeWithRefsString(refString: string, getSheetIdByName: (name: string) => string): IUnitRangeWithName[];
50
+ export declare function isReferenceStrings(refString: string): boolean;
42
51
  /**
43
52
  * Determine whether the sheet name needs to be wrapped in quotes
44
53
  * Excel will quote the worksheet name if any of the following is true:
@@ -6,7 +6,8 @@ export declare enum sequenceNodeType {
6
6
  STRING = 2,
7
7
  FUNCTION = 3,
8
8
  REFERENCE = 4,
9
- ARRAY = 5
9
+ ARRAY = 5,
10
+ DEFINED_NAME = 6
10
11
  }
11
12
  export interface ISequenceNode {
12
13
  nodeType: sequenceNodeType;
@@ -1,6 +1,13 @@
1
1
  import { NumberValueObject } from '../value-object/primitive-object';
2
2
  import { BaseValueObject } from '../value-object/base-value-object';
3
3
  import { FunctionVariantType } from '../reference-object/base-reference-object';
4
+ import { ICellData, Nullable } from '@univerjs/core';
4
5
 
5
6
  export declare function convertTonNumber(valueObject: BaseValueObject): NumberValueObject;
6
7
  export declare function isSingleValueObject(valueObject: FunctionVariantType): boolean;
8
+ /**
9
+ * Covert BaseValueObject to cell value
10
+ * @param objectValue
11
+ * @returns
12
+ */
13
+ export declare function objectValueToCellValue(objectValue: Nullable<BaseValueObject>): ICellData | undefined;
@@ -18,6 +18,10 @@ export declare class ArrayValueObject extends BaseValueObject {
18
18
  private _currentColumn;
19
19
  private _sliceCache;
20
20
  private _flattenCache;
21
+ /**
22
+ * The default value of the array, null values in comparison results support setting to false
23
+ */
24
+ private _defaultValue;
21
25
  private _flattenPosition;
22
26
  constructor(rawValue: string | IArrayValueObject);
23
27
  dispose(): void;
@@ -36,7 +40,8 @@ export declare class ArrayValueObject extends BaseValueObject {
36
40
  getArrayValue(): Nullable<BaseValueObject>[][];
37
41
  setArrayValue(value: BaseValueObject[][]): void;
38
42
  isArray(): boolean;
39
- get(row: number, column: number): BaseValueObject | null;
43
+ setDefaultValue(value: Nullable<BaseValueObject>): void;
44
+ get(row: number, column: number): Nullable<BaseValueObject>;
40
45
  getRealValue(row: number, column: number): BaseValueObject | null;
41
46
  set(row: number, column: number, value: Nullable<BaseValueObject>): void;
42
47
  getRangePosition(): {
@@ -65,6 +70,7 @@ export declare class ArrayValueObject extends BaseValueObject {
65
70
  * @param takeArray
66
71
  */
67
72
  pick(takeArray: ArrayValueObject): ArrayValueObject;
73
+ pickRaw(takeArray: ArrayValueObject): Nullable<BaseValueObject>[][];
68
74
  /**
69
75
  * Flatten a 2D array.
70
76
  * https://numpy.org/doc/stable/reference/generated/numpy.chararray.flatten.html#numpy.chararray.flatten
@@ -1,9 +1,9 @@
1
1
  import { FunctionVariantType } from '../../engine/reference-object/base-reference-object';
2
2
  import { ISheetData } from '../../basics/common';
3
3
  import { Dependency } from '@wendellhu/redi';
4
- import { IWorkbookData, Univer } from '@univerjs/core';
4
+ import { IWorkbookData, Workbook, Univer } from '@univerjs/core';
5
5
 
6
- export declare function createFunctionTestBed(workbookConfig?: IWorkbookData, dependencies?: Dependency[]): {
6
+ export declare function createFunctionTestBed(workbookData?: IWorkbookData, dependencies?: Dependency[]): {
7
7
  univer: Univer;
8
8
  get: {
9
9
  <T>(id: import('@wendellhu/redi').DependencyIdentifier<T>, lookUp?: import('@wendellhu/redi').LookUp | undefined): T;
@@ -13,7 +13,7 @@ export declare function createFunctionTestBed(workbookConfig?: IWorkbookData, de
13
13
  <T_4>(id: import('@wendellhu/redi').DependencyIdentifier<T_4>, quantity?: import('@wendellhu/redi').Quantity | undefined, lookUp?: import('@wendellhu/redi').LookUp | undefined): T_4 | T_4[] | null;
14
14
  <T_5>(id: import('@wendellhu/redi').DependencyIdentifier<T_5>, quantityOrLookup?: import('@wendellhu/redi').Quantity | import('@wendellhu/redi').LookUp | undefined, lookUp?: import('@wendellhu/redi').LookUp | undefined): T_5 | T_5[] | null;
15
15
  };
16
- sheet: import('@univerjs/core').Workbook;
16
+ sheet: Workbook;
17
17
  unitId: string;
18
18
  sheetId: string;
19
19
  sheetData: ISheetData;
@@ -1,3 +1,4 @@
1
+ import { IDefinedNameMapItem } from '../services/defined-names.service';
1
2
  import { PrimitiveValueType } from '../engine/value-object/primitive-object';
2
3
  import { BaseValueObject, ErrorValueObject } from '../engine/value-object/base-value-object';
3
4
  import { ArrayValueObject } from '../engine/value-object/array-value-object';
@@ -12,6 +13,7 @@ export declare class BaseFunction extends Disposable {
12
13
  private _subUnitId;
13
14
  private _row;
14
15
  private _column;
16
+ private _definedNames;
15
17
  /**
16
18
  * Whether the function needs to expand the parameters
17
19
  */
@@ -26,6 +28,14 @@ export declare class BaseFunction extends Disposable {
26
28
  get subUnitId(): Nullable<string>;
27
29
  get row(): number;
28
30
  get column(): number;
31
+ /**
32
+ * In Excel, to inject a defined name into a function that has positioning capabilities,
33
+ * such as using the INDIRECT function to reference a named range,
34
+ * you can write it as follows:
35
+ * =INDIRECT("DefinedName1")
36
+ */
37
+ getDefinedName(name: string): import('../services/defined-names.service').IDefinedNamesServiceParam | null;
38
+ setDefinedNames(definedNames: IDefinedNameMapItem): void;
29
39
  isAsync(): boolean;
30
40
  isAddress(): boolean;
31
41
  isCustom(): boolean;
@@ -60,6 +70,8 @@ export declare class BaseFunction extends Disposable {
60
70
  */
61
71
  getMatchTypeValue(logicValueObject?: BaseValueObject): number | undefined;
62
72
  binarySearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, searchType?: ArrayBinarySearchType): BaseValueObject;
73
+ private _getOneFirstByRaw;
74
+ private _getOneLastByRaw;
63
75
  equalSearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean): BaseValueObject;
64
76
  fuzzySearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean): BaseValueObject;
65
77
  orderSearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, searchType?: ArrayOrderSearchType, isDesc?: boolean): BaseValueObject;
@@ -0,0 +1,7 @@
1
+ import { BaseFunction } from '../../base-function';
2
+ import { BooleanValueObject } from '../../../engine/value-object/primitive-object';
3
+ import { BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
4
+
5
+ export declare class Iseven extends BaseFunction {
6
+ calculate(value: BaseValueObject): ErrorValueObject | BooleanValueObject;
7
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
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
+ export {};
@@ -0,0 +1,7 @@
1
+ import { BaseFunction } from '../../base-function';
2
+ import { BooleanValueObject } from '../../../engine/value-object/primitive-object';
3
+ import { BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
4
+
5
+ export declare class Isodd extends BaseFunction {
6
+ calculate(value: BaseValueObject): ErrorValueObject | BooleanValueObject;
7
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
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
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { BaseFunction } from '../../base-function';
2
+ import { BooleanValueObject } from '../../../engine/value-object/primitive-object';
2
3
  import { BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
3
- import { BooleanValueObject } from '../../..';
4
4
 
5
5
  export declare class Isref extends BaseFunction {
6
6
  needsReferenceObject: boolean;
@@ -3,6 +3,14 @@ import { BaseValueObject } from '../../../engine/value-object/base-value-object'
3
3
  import { BaseReferenceObject } from '../../../engine/reference-object/base-reference-object';
4
4
 
5
5
  export declare class Indirect extends BaseFunction {
6
+ isAddress(): boolean;
6
7
  calculate(refText: BaseValueObject, a1?: BaseValueObject): BaseValueObject | BaseReferenceObject;
7
8
  private _setDefault;
9
+ /**
10
+ * In Excel, to inject a defined name into a function that has positioning capabilities,
11
+ * such as using the INDIRECT function to reference a named range,
12
+ * you can write it as follows:
13
+ * =INDIRECT("DefinedName1")
14
+ */
15
+ private _convertToDefinedName;
8
16
  }
@@ -1,4 +1,4 @@
1
- import { ArrayValueObject } from '../../..';
1
+ import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
2
2
  import { BaseFunction } from '../../base-function';
3
3
  import { FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
4
4
 
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
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
+ export {};
@@ -0,0 +1,7 @@
1
+ import { BaseFunction } from '../../base-function';
2
+ import { BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
3
+ import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
4
+
5
+ export declare class Maxifs extends BaseFunction {
6
+ calculate(maxRange: BaseValueObject, ...variants: BaseValueObject[]): ErrorValueObject | ArrayValueObject;
7
+ }