@univerjs/engine-formula 0.10.14-nightly.202511080715 → 0.11.0-nightly.202511151013

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 (34) hide show
  1. package/lib/cjs/index.js +1 -7
  2. package/lib/es/index.js +5762 -4954
  3. package/lib/index.js +5762 -4954
  4. package/lib/types/basics/common.d.ts +8 -3
  5. package/lib/types/basics/function.d.ts +5 -1
  6. package/lib/types/basics/inverted-index-cache.d.ts +4 -3
  7. package/lib/types/basics/regex.d.ts +10 -1
  8. package/lib/types/commands/mutations/set-array-formula-data.mutation.d.ts +2 -1
  9. package/lib/types/commands/mutations/set-defined-name.mutation.d.ts +1 -0
  10. package/lib/types/engine/analysis/lexer-tree-builder.d.ts +2 -0
  11. package/lib/types/engine/ast-node/base-ast-node.d.ts +1 -0
  12. package/lib/types/engine/ast-node/function-node.d.ts +4 -0
  13. package/lib/types/engine/ast-node/lambda-node.d.ts +2 -1
  14. package/lib/types/engine/ast-node/operator-node.d.ts +9 -2
  15. package/lib/types/engine/ast-node/reference-node.d.ts +11 -2
  16. package/lib/types/engine/reference-object/base-reference-object.d.ts +13 -6
  17. package/lib/types/engine/reference-object/multi-area-reference-object.d.ts +92 -0
  18. package/lib/types/engine/reference-object/table-reference-object.d.ts +86 -4
  19. package/lib/types/engine/value-object/base-value-object.d.ts +2 -1
  20. package/lib/types/engine/value-object/primitive-object.d.ts +2 -1
  21. package/lib/types/functions/information/cell/index.d.ts +1 -2
  22. package/lib/types/functions/lookup/offset/index.d.ts +1 -1
  23. package/lib/types/functions/math/base/index.d.ts +1 -2
  24. package/lib/types/functions/math/function-map.d.ts +1 -2
  25. package/lib/types/functions/math/subtotal/index.d.ts +2 -1
  26. package/lib/types/functions/math/sumproduct/index.d.ts +21 -0
  27. package/lib/types/functions/new-excel-functions.d.ts +2 -0
  28. package/lib/types/functions/text/function-map.d.ts +1 -2
  29. package/lib/types/index.d.ts +5 -2
  30. package/lib/types/services/defined-names.service.d.ts +3 -0
  31. package/lib/types/services/runtime.service.d.ts +9 -1
  32. package/lib/types/services/super-table.service.d.ts +6 -0
  33. package/lib/umd/index.js +1 -7
  34. package/package.json +5 -5
@@ -1,4 +1,4 @@
1
- import { BooleanNumber, ICellData, IColumnData, IObjectArrayPrimitiveType, IObjectMatrixPrimitiveType, IRange, IRowData, IUnitRange, Nullable, ObjectMatrix, Styles } from '@univerjs/core';
1
+ import { ICellData, IColumnData, IObjectArrayPrimitiveType, IObjectMatrixPrimitiveType, IRange, IRowData, IUnitRange, Nullable, ObjectMatrix, Styles } from '@univerjs/core';
2
2
  export declare const ERROR_VALUE_OBJECT_CLASS_TYPE = "errorValueObject";
3
3
  export declare const ASYNC_OBJECT_CLASS_TYPE = "asyncObject";
4
4
  export declare const REFERENCE_OBJECT_CLASS_TYPE = "referenceObject";
@@ -92,6 +92,11 @@ export interface IArrayFormulaRangeType {
92
92
  [sheetId: string]: IObjectMatrixPrimitiveType<IRange>;
93
93
  }>;
94
94
  }
95
+ export interface IArrayFormulaEmbeddedMap {
96
+ [unitId: string]: Nullable<{
97
+ [sheetId: string]: IObjectMatrixPrimitiveType<boolean>;
98
+ }>;
99
+ }
95
100
  export interface IFeatureDirtyRangeType {
96
101
  [unitId: string]: Nullable<{
97
102
  [sheetId: string]: IRange[];
@@ -139,7 +144,6 @@ export interface IOtherFormulaDataItem {
139
144
  }
140
145
  export interface ISuperTable {
141
146
  sheetId: string;
142
- hasCustomTitle: BooleanNumber;
143
147
  titleMap: Map<string, number>;
144
148
  range: IRange;
145
149
  }
@@ -147,7 +151,8 @@ export declare enum TableOptionType {
147
151
  ALL = "#All",
148
152
  DATA = "#Data",
149
153
  HEADERS = "#Headers",
150
- TOTALS = "#Totals"
154
+ TOTALS = "#Totals",
155
+ THIS_ROW = "#This Row"
151
156
  }
152
157
  export interface IUnitExcludedCell {
153
158
  [unitId: string]: Nullable<{
@@ -86,7 +86,11 @@ export declare enum FunctionType {
86
86
  /**
87
87
  * Defined name
88
88
  */
89
- DefinedName = 16
89
+ DefinedName = 16,
90
+ /**
91
+ * Super Table name
92
+ */
93
+ Table = 17
90
94
  }
91
95
  export interface IFunctionParam {
92
96
  /**
@@ -1,4 +1,5 @@
1
1
  import { NumericTuple } from '@flatten-js/interval-tree';
2
+ export declare const DEFAULT_EMPTY_CELL_KEY: unique symbol;
2
3
  export declare class InvertedIndexCache {
3
4
  /**
4
5
  * {
@@ -14,9 +15,9 @@ export declare class InvertedIndexCache {
14
15
  */
15
16
  private _cache;
16
17
  private _continueBuildingCache;
17
- set(unitId: string, sheetId: string, column: number, value: string | number | boolean | null, row: number, isForceUpdate?: boolean): void;
18
- getCellValuePositions(unitId: string, sheetId: string, column: number): Map<string | number | boolean | null, Set<number>> | undefined;
19
- getCellPositions(unitId: string, sheetId: string, column: number, value: string | number | boolean, rowsInCache: NumericTuple[]): number[] | undefined;
18
+ set(unitId: string, sheetId: string, column: number, value: string | number | boolean | null | symbol, row: number, isForceUpdate?: boolean): void;
19
+ getCellValuePositions(unitId: string, sheetId: string, column: number): Map<string | number | boolean | symbol | null, Set<number>> | undefined;
20
+ getCellPositions(unitId: string, sheetId: string, column: number, value: string | number | boolean | null | symbol, rowsInCache: NumericTuple[]): number[] | undefined;
20
21
  setContinueBuildingCache(unitId: string, sheetId: string, column: number, startRow: number, endRow: number): void;
21
22
  shouldContinueBuildingCache(unitId: string, sheetId: string, column: number, row: number): boolean;
22
23
  canUseCache(unitId: string, sheetId: string, column: number, rangeStartRow: number, rangeEndRow: number): {
@@ -35,7 +35,12 @@ 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
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
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*?\\[((?<!#).)*\\]\\])?$";
38
- export declare const SUPER_TABLE_COLUMN_REGEX = "[.*?]";
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
+ export declare const REFERENCE_TABLE_ALL_COLUMN_REGEX_PRECOMPILING: RegExp;
40
+ export declare const REFERENCE_TABLE_SINGLE_COLUMN_REGEX_PRECOMPILING: RegExp;
41
+ export declare const REFERENCE_TABLE_MULTIPLE_COLUMN_REGEX_PRECOMPILING: RegExp;
42
+ export declare const REFERENCE_TABLE_TITLE_ONLY_ANY_HASH_REGEX_PRECOMPILING: RegExp;
43
+ export declare const SUPER_TABLE_COLUMN_REGEX = "\\[[^\\]]*?]";
39
44
  export declare const SUPER_TABLE_COLUMN_REGEX_PRECOMPILING: RegExp;
40
45
  export declare const ARRAY_VALUE_REGEX = "{.*?}";
41
46
  export declare const ARRAY_VALUE_REGEX_PRECOMPILING: RegExp;
@@ -46,5 +51,9 @@ export declare function regexTestColumn(token: string): boolean;
46
51
  export declare function regexTestSingleRow(token: string): boolean;
47
52
  export declare function regexTestSingleColumn(token: string): boolean;
48
53
  export declare function regexTestSuperTableColumn(token: string): boolean;
54
+ export declare function regexTestReferenceTableAllColumn(token: string): boolean;
55
+ export declare function regexTestReferenceTableSingleColumn(token: string): boolean;
56
+ export declare function regexTestReferenceTableMultipleColumn(token: string): boolean;
57
+ export declare function regexTestReferenceTableTitleOnlyAnyHash(token: string): boolean;
49
58
  export declare function regexTestArrayValue(token: string): boolean;
50
59
  export declare function isReferenceString(refString: string): boolean;
@@ -1,8 +1,9 @@
1
1
  import { IMutation } from '@univerjs/core';
2
- import { IArrayFormulaRangeType, IArrayFormulaUnitCellType } from '../../basics/common';
2
+ import { IArrayFormulaEmbeddedMap, IArrayFormulaRangeType, IArrayFormulaUnitCellType } from '../../basics/common';
3
3
  export interface ISetArrayFormulaDataMutationParams {
4
4
  arrayFormulaRange: IArrayFormulaRangeType;
5
5
  arrayFormulaCellData: IArrayFormulaUnitCellType;
6
+ arrayFormulaEmbedded: IArrayFormulaEmbeddedMap;
6
7
  }
7
8
  /**
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.
@@ -9,6 +9,7 @@ export interface ISetDefinedNameMutationParam extends ISetDefinedNameMutationSea
9
9
  comment?: string;
10
10
  localSheetId?: string;
11
11
  hidden?: boolean;
12
+ formulaOrRefStringWithPrefix?: string;
12
13
  }
13
14
  /**
14
15
  * Generate undo mutation of a `SetDefinedNameMutation`
@@ -1,5 +1,6 @@
1
1
  import { Nullable, AbsoluteRefType, Disposable } from '@univerjs/core';
2
2
  import { IDirtyUnitSheetDefinedNameMap } from '../../basics/common';
3
+ import { IFunctionNames } from '../../basics/function';
3
4
  import { IDefinedNamesServiceParam } from '../../services/defined-names.service';
4
5
  import { ISequenceArray, ISequenceNode } from '../utils/sequence';
5
6
  import { FormulaAstLRU } from '../../basics/cache-lru';
@@ -137,5 +138,6 @@ export declare class LexerTreeBuilder extends Disposable {
137
138
  private _nodeMaker;
138
139
  private _isScientificNotation;
139
140
  private _addSequenceArray;
141
+ getNewFormulaWithPrefix(formulaString: string, hasFunction: (functionToken: IFunctionNames) => boolean): string | null;
140
142
  }
141
143
  export {};
@@ -23,6 +23,7 @@ export declare class BaseAstNode {
23
23
  constructor(_token: string);
24
24
  dispose(): void;
25
25
  get nodeType(): NodeType;
26
+ resetCalculationState(): void;
26
27
  isAsync(): boolean;
27
28
  isAddress(): boolean;
28
29
  isForcedCalculateFunction(): boolean;
@@ -21,6 +21,10 @@ export declare class FunctionNode extends BaseAstNode {
21
21
  executeAsync(): Promise<AstNodePromiseType>;
22
22
  execute(): void;
23
23
  isFunctionExecutorArgumentsIgnoreNumberPattern(): boolean;
24
+ /**
25
+ * If it contains an array formula, set the current cell to the cache and send itself as a ref outward
26
+ */
27
+ private _setEmbeddedArrayFormulaToResult;
24
28
  /**
25
29
  * Compatibility handling for special functions.
26
30
  */
@@ -8,8 +8,9 @@ export declare class LambdaNode extends BaseAstNode {
8
8
  private _lambdaId;
9
9
  private _interpreter;
10
10
  private _lambdaPrivacyVarKeys;
11
+ private _runtimeService;
11
12
  private _isNotEmpty;
12
- constructor(token: string, _lambdaId: string, _interpreter: Interpreter, _lambdaPrivacyVarKeys: string[]);
13
+ constructor(token: string, _lambdaId: string, _interpreter: Interpreter, _lambdaPrivacyVarKeys: string[], _runtimeService: IFormulaRuntimeService);
13
14
  get nodeType(): NodeType;
14
15
  setNotEmpty(state?: boolean): void;
15
16
  isEmptyParamFunction(): boolean;
@@ -1,18 +1,25 @@
1
1
  import { BaseFunction } from '../../functions/base-function';
2
2
  import { IFunctionService } from '../../services/function.service';
3
+ import { IFormulaRuntimeService } from '../../services/runtime.service';
3
4
  import { LexerNode } from '../analysis/lexer-node';
4
5
  import { BaseAstNode } from './base-ast-node';
5
6
  import { BaseAstNodeFactory } from './base-ast-node-factory';
6
7
  import { NodeType } from './node-type';
7
8
  export declare class OperatorNode extends BaseAstNode {
8
9
  private _functionExecutor;
9
- constructor(operatorString: string, _functionExecutor: BaseFunction);
10
+ private _runtimeService;
11
+ constructor(operatorString: string, _functionExecutor: BaseFunction, _runtimeService: IFormulaRuntimeService);
10
12
  get nodeType(): NodeType;
11
13
  execute(): void;
14
+ /**
15
+ * If it contains an array formula, set the current cell to the cache and send itself as a ref outward
16
+ */
17
+ private _setEmbeddedArrayFormulaToResult;
12
18
  }
13
19
  export declare class OperatorNodeFactory extends BaseAstNodeFactory {
14
20
  private readonly _functionService;
15
- constructor(_functionService: IFunctionService);
21
+ private readonly _runtimeService;
22
+ constructor(_functionService: IFunctionService, _runtimeService: IFormulaRuntimeService);
16
23
  get zIndex(): number;
17
24
  create(param: string): BaseAstNode;
18
25
  checkAndCreateNodeType(param: LexerNode | string): BaseAstNode | undefined;
@@ -1,7 +1,9 @@
1
1
  import { IFormulaCurrentConfigService } from '../../services/current-data.service';
2
2
  import { IFunctionService } from '../../services/function.service';
3
3
  import { IFormulaRuntimeService } from '../../services/runtime.service';
4
+ import { ISuperTableService } from '../../services/super-table.service';
4
5
  import { LexerNode } from '../analysis/lexer-node';
6
+ import { TableReferenceObject } from '../reference-object/table-reference-object';
5
7
  import { ReferenceObjectType } from '../utils/value-object';
6
8
  import { BaseAstNode } from './base-ast-node';
7
9
  import { BaseAstNodeFactory } from './base-ast-node-factory';
@@ -11,9 +13,10 @@ export declare class ReferenceNode extends BaseAstNode {
11
13
  private _runtimeService;
12
14
  private _referenceObjectType;
13
15
  private _isPrepareMerge;
16
+ private _tableReferenceObject?;
14
17
  private _refOffsetX;
15
18
  private _refOffsetY;
16
- constructor(_currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, operatorString: string, _referenceObjectType: ReferenceObjectType, _isPrepareMerge?: boolean);
19
+ constructor(_currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, operatorString: string, _referenceObjectType: ReferenceObjectType, _isPrepareMerge?: boolean, _tableReferenceObject?: TableReferenceObject | undefined);
17
20
  get nodeType(): NodeType;
18
21
  execute(): void;
19
22
  setRefOffset(x?: number, y?: number): void;
@@ -26,8 +29,14 @@ export declare class ReferenceNodeFactory extends BaseAstNodeFactory {
26
29
  private readonly _currentConfigService;
27
30
  private readonly _formulaRuntimeService;
28
31
  private readonly _functionService;
29
- constructor(_currentConfigService: IFormulaCurrentConfigService, _formulaRuntimeService: IFormulaRuntimeService, _functionService: IFunctionService);
32
+ private readonly _superTableService;
33
+ constructor(_currentConfigService: IFormulaCurrentConfigService, _formulaRuntimeService: IFormulaRuntimeService, _functionService: IFunctionService, _superTableService: ISuperTableService);
30
34
  get zIndex(): number;
31
35
  checkAndCreateNodeType(param: LexerNode | string): ReferenceNode | undefined;
36
+ private _getTableMap;
37
+ private _getNode;
38
+ private _getTableReferenceNode;
39
+ private _splitTableStructuredRef;
40
+ private _checkTokenIsTableReference;
32
41
  private _checkParentIsUnionOperator;
33
42
  }
@@ -4,7 +4,6 @@ import { BaseValueObject } from '../value-object/base-value-object';
4
4
  import { FormulaAstLRU } from '../../basics/cache-lru';
5
5
  import { ObjectClassType } from '../../basics/object-class-type';
6
6
  import { ArrayValueObject } from '../value-object/array-value-object';
7
- import { StringValueObject } from '../value-object/primitive-object';
8
7
  export type NodeValueType = BaseValueObject | BaseReferenceObject | AsyncObject | AsyncArrayObject;
9
8
  export type FunctionVariantType = BaseValueObject | BaseReferenceObject;
10
9
  export declare const FORMULA_REF_TO_ARRAY_CACHE: FormulaAstLRU<ArrayValueObject>;
@@ -25,6 +24,8 @@ export declare class BaseReferenceObject extends ObjectClassType {
25
24
  private _runtimeFeatureCellData;
26
25
  private _refOffsetX;
27
26
  private _refOffsetY;
27
+ private _currentRow?;
28
+ private _currentColumn?;
28
29
  constructor(_token: string);
29
30
  dispose(): void;
30
31
  getToken(): string;
@@ -48,7 +49,7 @@ export declare class BaseReferenceObject extends ObjectClassType {
48
49
  };
49
50
  isReferenceObject(): boolean;
50
51
  iterator(callback: (valueObject: Nullable<BaseValueObject>, rowIndex: number, columnIndex: number) => Nullable<boolean>): Nullable<boolean>;
51
- getFirstCell(): BaseValueObject | StringValueObject;
52
+ getFirstCell(): BaseValueObject;
52
53
  getRangeData(): IRange;
53
54
  setRangeData(range: IRange): void;
54
55
  getUnitId(): string;
@@ -93,12 +94,15 @@ export declare class BaseReferenceObject extends ObjectClassType {
93
94
  isRow(): boolean;
94
95
  isRange(): boolean;
95
96
  isTable(): boolean;
97
+ isCurrentRowForRange(): boolean;
98
+ isCurrentColumnForRange(): boolean;
99
+ isMultiArea(): boolean;
96
100
  unionBy(referenceObject: BaseReferenceObject): NodeValueType;
97
101
  unionRange(rangeData1: IRange, rangeData2: IRange): IRange;
98
- getCellValueObject(cell: ICellData): BaseValueObject | StringValueObject;
102
+ getCellValueObject(cell: ICellData): BaseValueObject;
99
103
  private _getPatternByCell;
100
- getCellByRow(row: number): BaseValueObject | StringValueObject;
101
- getCellByColumn(column: number): BaseValueObject | StringValueObject;
104
+ getCellByRow(row: number): BaseValueObject;
105
+ getCellByColumn(column: number): BaseValueObject;
102
106
  getCurrentActiveSheetData(): import('../../basics/common').ISheetItem;
103
107
  getCurrentStylesData(): import('@univerjs/core').Styles;
104
108
  getCurrentRuntimeSheetData(): import('@univerjs/core').ObjectMatrix<Nullable<ICellData>> | undefined;
@@ -106,7 +110,10 @@ export declare class BaseReferenceObject extends ObjectClassType {
106
110
  getCurrentRuntimeActiveArrayFormulaCellData(): import('@univerjs/core').ObjectMatrix<Nullable<ICellData>> | undefined;
107
111
  getCellData(row: number, column: number): Nullable<ICellData>;
108
112
  getRuntimeFeatureCellValue(row: number, column: number): ICellData | undefined;
109
- getCellByPosition(rowRaw?: number, columnRaw?: number): BaseValueObject | StringValueObject;
113
+ getCellByPosition(rowRaw?: number, columnRaw?: number): BaseValueObject;
114
+ setCurrentRowAndColumn(row: number, column: number): void;
115
+ getCurrentRow(): number | undefined;
116
+ getCurrentColumn(): number | undefined;
110
117
  /**
111
118
  * Get the pattern of the cell
112
119
  * @param unitId
@@ -0,0 +1,92 @@
1
+ import { Nullable } from '@univerjs/core';
2
+ import { ArrayValueObject } from '../value-object/array-value-object';
3
+ import { BaseValueObject, ErrorValueObject } from '../value-object/base-value-object';
4
+ import { BaseReferenceObject } from './base-reference-object';
5
+ export type MultiAreaValue = BaseReferenceObject | ErrorValueObject;
6
+ export declare class MultiAreaReferenceObject extends BaseReferenceObject {
7
+ /**
8
+ * 2D structure:
9
+ * - First dimension: stored by rows
10
+ * - Second dimension: each AreaValue within that row
11
+ */
12
+ private _areas;
13
+ constructor(token: string, areas?: MultiAreaValue[][]);
14
+ dispose(): void;
15
+ getAreas(): MultiAreaValue[][];
16
+ setAreas(areas: MultiAreaValue[][]): void;
17
+ /**
18
+ * Append an area:
19
+ * - If a single AreaValue is passed, it will be wrapped as one row.
20
+ * - If an AreaValue[] is passed, it will be inserted as an entire row.
21
+ */
22
+ addArea(area: MultiAreaValue | MultiAreaValue[]): void;
23
+ /** Flatten the 2D areas to reuse 1D logic */
24
+ private _flatAreas;
25
+ isMultiArea(): boolean;
26
+ isRange(): boolean;
27
+ isCell(): boolean;
28
+ isRow(): boolean;
29
+ isColumn(): boolean;
30
+ getRowCount(): number;
31
+ getColumnCount(): number;
32
+ isExceedRange(): boolean;
33
+ setRefOffset(x?: number, y?: number): void;
34
+ private _getReferenceArea;
35
+ /**
36
+ * Multi-area reference may span multiple sheets, but Excel requires
37
+ * them to be in the same sheet for most functions. We follow Excel semantics
38
+ * by returning the first area’s identifiers.
39
+ */
40
+ getUnitId(): string;
41
+ getSheetId(): string;
42
+ getActiveSheetRowCount(): number;
43
+ getActiveSheetColumnCount(): number;
44
+ /**
45
+ * Iterate through all areas in order, flattening the multi-area into
46
+ * a sequence of cells.
47
+ *
48
+ * Note: The order here is "row-major":
49
+ * iterate by the row order of _areas, then within each row by the area order.
50
+ */
51
+ iterator(callback: (v: Nullable<BaseValueObject>, row: number, col: number) => Nullable<boolean>): void;
52
+ /**
53
+ * Excel defines the "first cell" of a multi-area reference
54
+ * as the first cell of the first area.
55
+ */
56
+ getFirstCell(): BaseValueObject;
57
+ /**
58
+ * For multi-area, we only take the *first cell* of each area and
59
+ * arrange them into a 2D ArrayValueObject:
60
+ *
61
+ * - outer `_areas` dimension => rows
62
+ * - inner `_areas[row]` dimension => columns
63
+ */
64
+ toArrayValueObject(): ArrayValueObject;
65
+ getRangePosition(): {
66
+ startRow: number;
67
+ endRow: number;
68
+ startColumn: number;
69
+ endColumn: number;
70
+ rangeType?: import('@univerjs/core').RANGE_TYPE;
71
+ startAbsoluteRefType?: import('@univerjs/core').AbsoluteRefType;
72
+ endAbsoluteRefType?: import('@univerjs/core').AbsoluteRefType;
73
+ unitId?: string;
74
+ sheetId?: string;
75
+ };
76
+ toUnitRange(): {
77
+ range: {
78
+ startRow: number;
79
+ endRow: number;
80
+ startColumn: number;
81
+ endColumn: number;
82
+ rangeType?: import('@univerjs/core').RANGE_TYPE;
83
+ startAbsoluteRefType?: import('@univerjs/core').AbsoluteRefType;
84
+ endAbsoluteRefType?: import('@univerjs/core').AbsoluteRefType;
85
+ unitId?: string;
86
+ sheetId?: string;
87
+ };
88
+ sheetId: string;
89
+ unitId: string;
90
+ };
91
+ getRangeData(): import('@univerjs/core').IRange;
92
+ }
@@ -1,10 +1,92 @@
1
- import { ISuperTable, TableOptionType } from '../../basics/common';
1
+ import { ISuperTable, IUnitSheetNameMap, TableOptionType } from '../../basics/common';
2
2
  import { BaseReferenceObject } from './base-reference-object';
3
+ /**
4
+ * Table reference object compatible with Excel Structured References
5
+ *
6
+ * Supported (examples):
7
+ * - =Table[Column] // Single column (default DATA)
8
+ * - =Table[[ColumnA]:[ColumnB]] // Column range (default DATA)
9
+ * - =Table[#All] / [#Data] / [#Headers] / [#Totals] / [#This Row]
10
+ * - =Table[[#All],[Column]] // Section + column/column range
11
+ * - =Table[[#Data],[ColA]:[ColB]]
12
+ * - =Table[[#This Row],[Column]]
13
+ *
14
+ * Not supported (invalid):
15
+ * - Multiple sections in parallel (e.g., [[#Headers],[#Data]])
16
+ * - Non-existent sections (e.g., #Title)
17
+ * - Column indices instead of column names (e.g., [[1]:[3]])
18
+ */
3
19
  export declare class TableReferenceObject extends BaseReferenceObject {
4
20
  private _tableData;
21
+ /**
22
+ * Structured reference body (with or without outer []):
23
+ * - "#Data" / "#All"
24
+ * - "[Col]" / "[[ColA]:[ColB]]"
25
+ * - "[[#Data],[Col]]" / "[[#All],[ColA]:[ColB]]"
26
+ */
5
27
  private _columnDataString;
6
- constructor(token: string, _tableData: ISuperTable, _columnDataString: string, tableOptionMap: Map<string, TableOptionType>);
28
+ /** Section text to enum mapping ('#All', '#Data', '#Headers', '#Totals', '#This Row') */
29
+ private _tableOptionMap;
30
+ private _isCurrentRowForRange;
31
+ constructor(token: string, _tableData: ISuperTable,
32
+ /**
33
+ * Structured reference body (with or without outer []):
34
+ * - "#Data" / "#All"
35
+ * - "[Col]" / "[[ColA]:[ColB]]"
36
+ * - "[[#Data],[Col]]" / "[[#All],[ColA]:[ColB]]"
37
+ */
38
+ _columnDataString: string | undefined,
39
+ /** Section text to enum mapping ('#All', '#Data', '#Headers', '#Totals', '#This Row') */
40
+ _tableOptionMap: Map<string, TableOptionType>);
41
+ getRangeData(): import('@univerjs/core').IRange;
42
+ getRefOffset(): {
43
+ x: number;
44
+ y: number;
45
+ };
7
46
  isTable(): boolean;
8
- private _stringToColumnData;
9
- private _columnHandler;
47
+ isCurrentRowForRange(): boolean;
48
+ setForcedSheetId(sheetNameMap: IUnitSheetNameMap): void;
49
+ /**
50
+ * Parse structured reference body, returning column range and Section type.
51
+ * Determination rules:
52
+ * - Whether it's a Section depends on "whether it starts with # after stripping", not whether it still has brackets.
53
+ * - No comma: Either Section, or column/column range
54
+ * - Has comma: Left is Section, right is column/column range
55
+ */
56
+ private _parseStructuredRef;
57
+ /** Strip one layer of outer brackets from "[...]" (return as-is if none) */
58
+ private _stripOuterBracketOnce;
59
+ /**
60
+ * Find first comma at depth=0 (used to split Section and column parts)
61
+ * Compatible with nesting like "[[#Data],[ColA]:[ColB]]".
62
+ */
63
+ private _findCommaAtTopLevel;
64
+ /**
65
+ * Parse Section, compatible with both "[#Data]" and "#Data" inputs
66
+ * Returns TableOptionType if matched; returns DATA if not (could throw error instead)
67
+ */
68
+ private _parseSectionMaybeBracketed;
69
+ /**
70
+ * Section mapping: Only accepts keywords starting with #.
71
+ * Returns undefined if not a valid Section (caller treats as column or fallback).
72
+ */
73
+ private _mapSection;
74
+ /**
75
+ * Parse column selection:
76
+ * - "[Col]" / "Col" => Single column
77
+ * - "[[ColA]:[ColB]]" / "[ColA]:[ColB]" / "ColA:ColB" => Column range
78
+ *
79
+ * Rules:
80
+ * - First find colon at top level, strip one layer of brackets from left and right sides (if present)
81
+ * - Returns -1 if column name not found (caller should handle as parse error)
82
+ */
83
+ private _parseColumnOrRange;
84
+ /** Strip one layer of outer brackets; return as-is if none (compatible with "[Col]" and "Col") */
85
+ private _stripOuterBracketIfAny;
86
+ /** Find range colon at depth=0 */
87
+ private _findColonAtTopLevel;
88
+ /** Column title → column index; returns -1 if not found (caller should handle as parse error) */
89
+ private _titleToIndex;
90
+ /** Resolve #This Row's row number; takes first data row (tableStartRow+1) when no context available */
91
+ private _resolveThisRow;
10
92
  }
@@ -40,6 +40,7 @@ export declare class BaseValueObject extends ObjectClassType {
40
40
  isNumber(): boolean;
41
41
  isBoolean(): boolean;
42
42
  isLambda(): boolean;
43
+ isDateFormat(): boolean;
43
44
  isError(): boolean;
44
45
  isNull(): boolean;
45
46
  isHyperlink(): boolean;
@@ -82,7 +83,7 @@ export declare class BaseValueObject extends ObjectClassType {
82
83
  multiplyBy(value: string | number | boolean): BaseValueObject;
83
84
  dividedBy(value: string | number | boolean): BaseValueObject;
84
85
  modInverse(valueObject: BaseValueObject): BaseValueObject;
85
- compareBy(value: string | number | boolean, operator: compareToken): BaseValueObject;
86
+ compareBy(value: string | number | boolean, operator: compareToken, isDateCompare?: boolean): BaseValueObject;
86
87
  concatenate(value: string | number | boolean, concatenateType?: ConcatenateType): string;
87
88
  pow(valueObject: BaseValueObject): BaseValueObject;
88
89
  powInverse(valueObject: BaseValueObject): BaseValueObject;
@@ -111,12 +111,13 @@ export declare class NumberValueObject extends BaseValueObject {
111
111
  mod(valueObject: BaseValueObject): BaseValueObject;
112
112
  concatenateFront(valueObject: BaseValueObject): BaseValueObject;
113
113
  concatenateBack(valueObject: BaseValueObject): BaseValueObject;
114
+ isDateFormat(): boolean;
114
115
  compare(valueObject: BaseValueObject, operator: compareToken): BaseValueObject;
115
116
  plusBy(value: string | number | boolean): BaseValueObject;
116
117
  minusBy(value: string | number | boolean): BaseValueObject;
117
118
  multiplyBy(value: string | number | boolean): BaseValueObject;
118
119
  dividedBy(value: string | number | boolean): BaseValueObject;
119
- compareBy(value: string | number | boolean, operator: compareToken): BaseValueObject;
120
+ compareBy(valueRaw: string | number | boolean, operator: compareToken, isDateCompare?: boolean): BaseValueObject;
120
121
  private _compareString;
121
122
  private _compareNumber;
122
123
  private _compareFiniteNumber;
@@ -1,11 +1,10 @@
1
1
  import { FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
2
- import { StringValueObject } from '../../../engine/value-object/primitive-object';
3
2
  import { BaseFunction } from '../../base-function';
4
3
  export declare class Cell extends BaseFunction {
5
4
  needsReferenceObject: boolean;
6
5
  minParams: number;
7
6
  maxParams: number;
8
- calculate(infoType: FunctionVariantType, reference: FunctionVariantType): StringValueObject | FunctionVariantType;
7
+ calculate(infoType: FunctionVariantType, reference: FunctionVariantType): FunctionVariantType;
9
8
  private _handleSingleObject;
10
9
  private _getWidthResult;
11
10
  }
@@ -1,5 +1,5 @@
1
- import { BaseFunction } from '../../base-function';
2
1
  import { FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
2
+ import { BaseFunction } from '../../base-function';
3
3
  export declare class Offset extends BaseFunction {
4
4
  minParams: number;
5
5
  maxParams: number;
@@ -1,9 +1,8 @@
1
1
  import { BaseValueObject } from '../../../engine/value-object/base-value-object';
2
- import { StringValueObject } from '../../../engine/value-object/primitive-object';
3
2
  import { BaseFunction } from '../../base-function';
4
3
  export declare class Base extends BaseFunction {
5
4
  minParams: number;
6
5
  maxParams: number;
7
- calculate(number: BaseValueObject, radix: BaseValueObject, minLength?: BaseValueObject): BaseValueObject | StringValueObject;
6
+ calculate(number: BaseValueObject, radix: BaseValueObject, minLength?: BaseValueObject): BaseValueObject;
8
7
  private _handleSingleObject;
9
8
  }
@@ -1,7 +1,6 @@
1
- import { Base } from './base';
2
1
  import { FUNCTION_NAMES_MATH } from './function-names';
3
2
  import { Product } from './product';
4
3
  import { Randarray } from './randarray';
5
4
  import { Subtotal } from './subtotal';
6
5
  import { Sumifs } from './sumifs';
7
- export declare const functionMath: ((FUNCTION_NAMES_MATH | typeof Base)[] | (FUNCTION_NAMES_MATH | typeof Product)[] | (FUNCTION_NAMES_MATH | typeof Randarray)[] | (FUNCTION_NAMES_MATH | typeof Subtotal)[] | (FUNCTION_NAMES_MATH | typeof Sumifs)[])[];
6
+ export declare const functionMath: ((FUNCTION_NAMES_MATH | typeof Product)[] | (FUNCTION_NAMES_MATH | typeof Randarray)[] | (FUNCTION_NAMES_MATH | typeof Subtotal)[] | (FUNCTION_NAMES_MATH | typeof Sumifs)[])[];
@@ -1,4 +1,5 @@
1
1
  import { FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
2
+ import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
2
3
  import { BaseFunction } from '../../base-function';
3
4
  export declare class Subtotal extends BaseFunction {
4
5
  minParams: number;
@@ -6,7 +7,7 @@ export declare class Subtotal extends BaseFunction {
6
7
  needsReferenceObject: boolean;
7
8
  needsFilteredOutRows: boolean;
8
9
  needsFormulaDataModel: boolean;
9
- calculate(functionNum: FunctionVariantType, ...refs: FunctionVariantType[]): FunctionVariantType;
10
+ calculate(functionNum: FunctionVariantType, ...refs: FunctionVariantType[]): ArrayValueObject | FunctionVariantType;
10
11
  private _handleSingleObject;
11
12
  private _getIndexNumValue;
12
13
  private _average;
@@ -4,6 +4,27 @@ export declare class Sumproduct extends BaseFunction {
4
4
  minParams: number;
5
5
  maxParams: number;
6
6
  calculate(array1: BaseValueObject, ...variants: BaseValueObject[]): BaseValueObject;
7
+ /**
8
+ * Validate all variants:
9
+ * - propagate first error BaseValueObject
10
+ * - ensure array dimensions are compatible with base (rowCount/columnCount)
11
+ * Returns an ErrorValueObject / BaseValueObject on failure, or null when OK.
12
+ */
13
+ private _validateVariants;
14
+ /**
15
+ * Core SUMPRODUCT loop.
16
+ * - baseArray already contains numeric values from array1
17
+ * - variants may be scalar or array; non-number cells are treated as 0
18
+ * - any error cell short-circuits with that error
19
+ */
20
+ private _sumProduct;
21
+ /**
22
+ * Get the value object of a variant at (r, c).
23
+ * - For scalar variants, returns the variant itself.
24
+ * - For array variants, returns the cell at (r, c).
25
+ * If cell does not exist, returns null and let caller convert to #VALUE!.
26
+ */
27
+ private _getVariantCell;
7
28
  private _initArray1;
8
29
  private _getResultArrayByArray1;
9
30
  }
@@ -0,0 +1,2 @@
1
+ import { IFunctionNames } from '../basics/function';
2
+ export declare const NEW_EXCEL_FUNCTIONS: Set<IFunctionNames>;
@@ -1,7 +1,6 @@
1
- import { Concat } from './concat';
2
1
  import { Concatenate } from './concatenate';
3
2
  import { FUNCTION_NAMES_TEXT } from './function-names';
4
3
  import { Textafter } from './textafter';
5
4
  import { Textbefore } from './textbefore';
6
5
  import { Textsplit } from './textsplit';
7
- export declare const functionText: ((FUNCTION_NAMES_TEXT | typeof Concat)[] | (FUNCTION_NAMES_TEXT | typeof Concatenate)[] | (FUNCTION_NAMES_TEXT | typeof Textafter)[] | (FUNCTION_NAMES_TEXT | typeof Textbefore)[] | (FUNCTION_NAMES_TEXT | typeof Textsplit)[])[];
6
+ export declare const functionText: ((FUNCTION_NAMES_TEXT | typeof Concatenate)[] | (FUNCTION_NAMES_TEXT | typeof Textafter)[] | (FUNCTION_NAMES_TEXT | typeof Textbefore)[] | (FUNCTION_NAMES_TEXT | typeof Textsplit)[])[];