@univerjs/engine-formula 0.1.0-beta.3 → 0.1.0-beta.5

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 (78) hide show
  1. package/lib/cjs/index.js +1 -1
  2. package/lib/es/index.js +3071 -2033
  3. package/lib/types/basics/__tests__/date.spec.d.ts +16 -0
  4. package/lib/types/basics/common.d.ts +7 -1
  5. package/lib/types/basics/date.d.ts +30 -0
  6. package/lib/types/basics/error-type.d.ts +1 -1
  7. package/lib/types/basics/object-class-type.d.ts +3 -0
  8. package/lib/types/commands/mutations/set-formula-calculation.mutation.d.ts +2 -1
  9. package/lib/types/commands/mutations/set-numfmt-formula-data.mutation.d.ts +21 -0
  10. package/lib/types/engine/ast-node/function-node.d.ts +12 -0
  11. package/lib/types/engine/ast-node/reference-node.d.ts +2 -1
  12. package/lib/types/engine/reference-object/base-reference-object.d.ts +4 -1
  13. package/lib/types/engine/utils/__tests__/cell.spec.d.ts +16 -0
  14. package/lib/types/engine/utils/array-object.d.ts +19 -0
  15. package/lib/types/engine/utils/cell.d.ts +17 -0
  16. package/lib/types/engine/utils/compare.d.ts +5 -0
  17. package/lib/types/engine/utils/object-compare.d.ts +7 -0
  18. package/lib/types/engine/value-object/array-value-object.d.ts +45 -3
  19. package/lib/types/engine/value-object/base-value-object.d.ts +1 -0
  20. package/lib/types/functions/__tests__/{create-command-test-bed.d.ts → create-function-test-bed.d.ts} +1 -1
  21. package/lib/types/functions/__tests__/nested-functions.spec.d.ts +16 -0
  22. package/lib/types/functions/base-function.d.ts +23 -1
  23. package/lib/types/functions/date/date/__tests__/index.spec.d.ts +16 -0
  24. package/lib/types/functions/date/date/index.d.ts +20 -0
  25. package/lib/types/functions/date/day/__tests__/index.spec.d.ts +16 -0
  26. package/lib/types/functions/date/day/index.d.ts +20 -0
  27. package/lib/types/functions/date/edate/__tests__/index.spec.d.ts +16 -0
  28. package/lib/types/functions/date/edate/index.d.ts +23 -0
  29. package/lib/types/functions/date/function-map.d.ts +3 -1
  30. package/lib/types/functions/date/month/__tests__/index.spec.d.ts +16 -0
  31. package/lib/types/functions/date/month/index.d.ts +20 -0
  32. package/lib/types/functions/date/today/__tests__/index.spec.d.ts +16 -0
  33. package/lib/types/functions/date/today/index.d.ts +22 -0
  34. package/lib/types/functions/date/year/__tests__/index.spec.d.ts +16 -0
  35. package/lib/types/functions/date/year/index.d.ts +20 -0
  36. package/lib/types/functions/information/function-map.d.ts +3 -1
  37. package/lib/types/functions/information/isblank/__tests__/index.spec.d.ts +16 -0
  38. package/lib/types/functions/information/isblank/index.d.ts +20 -0
  39. package/lib/types/functions/logical/and/__tests__/index.spec.d.ts +16 -0
  40. package/lib/types/functions/logical/and/index.d.ts +20 -0
  41. package/lib/types/functions/logical/function-map.d.ts +2 -1
  42. package/lib/types/functions/logical/if/__tests__/index.spec.d.ts +16 -0
  43. package/lib/types/functions/logical/if/index.d.ts +22 -0
  44. package/lib/types/functions/logical/iferror/__tests__/index.spec.d.ts +16 -0
  45. package/lib/types/functions/logical/iferror/index.d.ts +20 -0
  46. package/lib/types/functions/lookup/address/index.d.ts +2 -3
  47. package/lib/types/functions/lookup/function-map.d.ts +2 -2
  48. package/lib/types/functions/lookup/hlookup/__tests__/index.spec.d.ts +16 -0
  49. package/lib/types/functions/lookup/hlookup/index.d.ts +21 -0
  50. package/lib/types/functions/lookup/lookup/__tests__/index.spec.d.ts +16 -0
  51. package/lib/types/functions/lookup/lookup/index.d.ts +23 -0
  52. package/lib/types/functions/lookup/match/__tests__/index.spec.d.ts +16 -0
  53. package/lib/types/functions/lookup/match/index.d.ts +23 -0
  54. package/lib/types/functions/lookup/offset/__tests__/index.spec.d.ts +16 -0
  55. package/lib/types/functions/lookup/offset/index.d.ts +4 -3
  56. package/lib/types/functions/lookup/xlookup/__tests__/index.spec.d.ts +16 -0
  57. package/lib/types/functions/lookup/xlookup/index.d.ts +24 -0
  58. package/lib/types/functions/lookup/xmatch/__tests__/index.spec.d.ts +16 -0
  59. package/lib/types/functions/lookup/xmatch/index.d.ts +23 -0
  60. package/lib/types/functions/math/abs/index.d.ts +1 -2
  61. package/lib/types/functions/math/acos/index.d.ts +1 -2
  62. package/lib/types/functions/math/acosh/index.d.ts +1 -2
  63. package/lib/types/functions/math/acot/index.d.ts +1 -2
  64. package/lib/types/functions/math/sumifs/index.d.ts +3 -2
  65. package/lib/types/functions/meta/compare/index.d.ts +1 -1
  66. package/lib/types/functions/meta/multiply/index.d.ts +1 -1
  67. package/lib/types/functions/statistical/average/index.d.ts +1 -1
  68. package/lib/types/functions/statistical/count/index.d.ts +1 -1
  69. package/lib/types/functions/statistical/counta/index.d.ts +1 -1
  70. package/lib/types/functions/statistical/max/index.d.ts +1 -1
  71. package/lib/types/functions/text/concatenate/__tests__/index.spec.d.ts +16 -0
  72. package/lib/types/functions/text/concatenate/index.d.ts +2 -3
  73. package/lib/types/index.d.ts +3 -1
  74. package/lib/types/models/formula-data.model.d.ts +9 -3
  75. package/lib/types/services/current-data.service.d.ts +4 -1
  76. package/lib/types/services/runtime.service.d.ts +5 -2
  77. package/lib/umd/index.js +1 -1
  78. package/package.json +22 -9
@@ -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 {};
@@ -60,7 +60,7 @@ export interface IUnitSheetNameMap {
60
60
  }
61
61
  export interface IDirtyUnitSheetNameMap {
62
62
  [unitId: string]: Nullable<{
63
- [sheetId: string]: Nullable<string>;
63
+ [sheetId: string]: string;
64
64
  }>;
65
65
  }
66
66
  export interface IDirtyUnitFeatureMap {
@@ -97,6 +97,11 @@ export interface IOtherFormulaData {
97
97
  }>;
98
98
  }>;
99
99
  }
100
+ export interface INumfmtItemMap {
101
+ [unitId: string]: Nullable<{
102
+ [sheetId: string]: IObjectMatrixPrimitiveType<Nullable<string>>;
103
+ }>;
104
+ }
100
105
  /**
101
106
  * @f formulaString, the text string of the formula.
102
107
  * @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.
@@ -131,6 +136,7 @@ export interface IFormulaDatasetConfig {
131
136
  dirtyRanges: IUnitRange[];
132
137
  dirtyNameMap: IDirtyUnitSheetNameMap;
133
138
  dirtyUnitFeatureMap: IDirtyUnitFeatureMap;
139
+ numfmtItemMap: INumfmtItemMap;
134
140
  excludedCell?: IUnitExcludedCell;
135
141
  allUnitData?: IUnitData;
136
142
  unitSheetNameMap?: IUnitSheetNameMap;
@@ -0,0 +1,30 @@
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 declare const DEFFAULT_DATE_FORMAT = "yyyy-mm-dd;@";
17
+ /**
18
+ * Excel stores dates as sequential serial numbers so they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,447 days after January 1, 1900.
19
+ *
20
+ * Excel has a leap year error in 1900. February 29, 1900 is considered a legal date. In fact, there is no February 29 in 1900.
21
+ * 1900.2.28 Date Serial 59
22
+ * 1900.2.29 Date Serial 61
23
+ * 1900.3.1 Date Serial 61
24
+ * 1901.1.1 Date Serial 367
25
+ * @param date
26
+ * @returns
27
+ */
28
+ export declare function excelDateSerial(date: Date): number;
29
+ export declare function excelSerialToDate(serial: number): Date;
30
+ export declare function formatDateDefault(date: Date): string;
@@ -17,7 +17,7 @@ export declare enum ErrorType {
17
17
  /** Division by zero. */
18
18
  DIV_BY_ZERO = "#DIV/0!",
19
19
  /** Function error. */
20
- NAME = "#NAME!",
20
+ NAME = "#NAME?",
21
21
  VALUE = "#VALUE!",
22
22
  NUM = "#NUM!",
23
23
  NA = "#N/A",
@@ -15,6 +15,9 @@
15
15
  */
16
16
  import { Disposable } from '@univerjs/core';
17
17
  export declare class ObjectClassType extends Disposable {
18
+ pattern: string;
19
+ getPattern(): string;
20
+ setPattern(pattern: string): void;
18
21
  isError(): boolean;
19
22
  isAsyncObject(): boolean;
20
23
  isAsyncArrayObject(): boolean;
@@ -14,13 +14,14 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { IExecutionOptions, IMutation, IUnitRange, Nullable } from '@univerjs/core';
17
- import type { IDirtyUnitFeatureMap, IDirtyUnitSheetNameMap, IRuntimeOtherUnitDataType, IRuntimeUnitDataType } from '../../basics/common';
17
+ import type { IDirtyUnitFeatureMap, IDirtyUnitSheetNameMap, INumfmtItemMap, IRuntimeOtherUnitDataType, IRuntimeUnitDataType } from '../../basics/common';
18
18
  import type { FormulaExecutedStateType, IExecutionInProgressParams } from '../../services/runtime.service';
19
19
  export interface ISetFormulaCalculationStartMutation {
20
20
  dirtyRanges: IUnitRange[];
21
21
  dirtyNameMap: IDirtyUnitSheetNameMap;
22
22
  dirtyUnitFeatureMap: IDirtyUnitFeatureMap;
23
23
  options: Nullable<IExecutionOptions>;
24
+ numfmtItemMap: INumfmtItemMap;
24
25
  forceCalculation?: boolean;
25
26
  }
26
27
  /**
@@ -0,0 +1,21 @@
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
+ import type { IMutation } from '@univerjs/core';
17
+ import type { INumfmtItemMap } from '../../basics/common';
18
+ export interface ISetNumfmtFormulaDataMutationParams {
19
+ numfmtItemMap: INumfmtItemMap;
20
+ }
21
+ export declare const SetNumfmtFormulaDataMutation: IMutation<ISetNumfmtFormulaDataMutationParams>;
@@ -31,6 +31,18 @@ export declare class FunctionNode extends BaseAstNode {
31
31
  get nodeType(): NodeType;
32
32
  executeAsync(): Promise<AstNodePromiseType>;
33
33
  execute(): void;
34
+ /**
35
+ * Compatibility handling for special functions.
36
+ */
37
+ private _compatibility;
38
+ /**
39
+ * The LOOKUP function follows the following rules when dealing with vectors of different sizes:
40
+ * If the lookup_vector is larger than the result_vector,
41
+ * the LOOKUP function will ignore the extra portion of the lookup_vector and only use the portion of the result_vector that is the same size as the lookup_vector for lookup and returning results.
42
+ * If the lookup_vector is smaller than the result_vector,
43
+ * the LOOKUP function will continue using the last value of the result_vector for lookup and returning results after the last value of the lookup_vector.
44
+ */
45
+ private _lookupCompatibility;
34
46
  private _calculate;
35
47
  private _setRefInfo;
36
48
  private _setRefData;
@@ -28,7 +28,8 @@ export declare class ReferenceNode extends BaseAstNode {
28
28
  private _accessor;
29
29
  private _operatorString;
30
30
  private _referenceObject;
31
- constructor(_accessor: IAccessor, _operatorString: string, _referenceObject: BaseReferenceObject);
31
+ private _isPrepareMerge;
32
+ constructor(_accessor: IAccessor, _operatorString: string, _referenceObject: BaseReferenceObject, _isPrepareMerge?: boolean);
32
33
  get nodeType(): NodeType;
33
34
  execute(): void;
34
35
  }
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import type { ICellData, IRange, Nullable } from '@univerjs/core';
17
17
  import { FormulaAstLRU } from '../../basics/cache-lru';
18
- import type { IRuntimeUnitDataType, IUnitData, IUnitSheetNameMap } from '../../basics/common';
18
+ import type { INumfmtItemMap, IRuntimeUnitDataType, IUnitData, IUnitSheetNameMap } from '../../basics/common';
19
19
  import { ObjectClassType } from '../../basics/object-class-type';
20
20
  import { ArrayValueObject } from '../value-object/array-value-object';
21
21
  import { type BaseValueObject, ErrorValueObject } from '../value-object/base-value-object';
@@ -36,6 +36,7 @@ export declare class BaseReferenceObject extends ObjectClassType {
36
36
  private _arrayFormulaCellData;
37
37
  private _runtimeArrayFormulaCellData;
38
38
  private _runtimeFeatureCellData;
39
+ private _numfmtItemData;
39
40
  private _refOffsetX;
40
41
  private _refOffsetY;
41
42
  constructor(_token: string);
@@ -84,6 +85,8 @@ export declare class BaseReferenceObject extends ObjectClassType {
84
85
  setRuntimeFeatureCellData(unitData: {
85
86
  [featureId: string]: IRuntimeUnitDataType;
86
87
  }): void;
88
+ getNumfmtItemData(): INumfmtItemMap;
89
+ setNumfmtItemData(numfmtItemData: INumfmtItemMap): void;
87
90
  getRowCount(): number;
88
91
  getColumnCount(): number;
89
92
  isCell(): boolean;
@@ -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,19 @@
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
+ import { ArrayValueObject } from '../value-object/array-value-object';
17
+ import type { BaseValueObject } from '../value-object/base-value-object';
18
+ export declare function expandArrayValueObject(rowCount: number, columnCount: number, valueObject: BaseValueObject, defaultValue?: BaseValueObject): ArrayValueObject;
19
+ export declare function createNewArray(result: BaseValueObject[][], rowCount: number, columnCount: number): ArrayValueObject;
@@ -0,0 +1,17 @@
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
+ import type { ICellData, Nullable } from '@univerjs/core';
17
+ export declare function getCellValue(cell: Nullable<ICellData>): string | number | true;
@@ -18,6 +18,11 @@ export declare enum ArrayBinarySearchType {
18
18
  MIN = 0,
19
19
  MAX = 1
20
20
  }
21
+ export declare enum ArrayOrderSearchType {
22
+ NORMAL = 0,
23
+ MIN = 1,
24
+ MAX = 2
25
+ }
21
26
  export declare function getCompare(): (x: string, y: string) => number;
22
27
  export declare function isWildcard(str: string): boolean;
23
28
  export declare function isMatchWildcard(currentValue: string, value: string): boolean;
@@ -23,3 +23,10 @@ export declare function findCompareToken(str: string): [compareToken, BaseValueO
23
23
  * 3. <apple*: normal value, <=apple: obtains the same effect as <apple*
24
24
  */
25
25
  export declare function valueObjectCompare(range: BaseValueObject, criteria: BaseValueObject, operator?: compareToken): BaseValueObject;
26
+ /**
27
+ * Find the Boolean intersection of two ArrayValueObjects
28
+ * @param valueObject1
29
+ * @param valueObject2
30
+ * @returns
31
+ */
32
+ export declare function booleanObjectIntersection(valueObject1: BaseValueObject, valueObject2: BaseValueObject): BaseValueObject;
@@ -13,9 +13,9 @@
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
+ import type { Nullable } from '@univerjs/core';
17
17
  import { compareToken } from '../../basics/token';
18
- import { ArrayBinarySearchType } from '../utils/compare';
18
+ import { ArrayBinarySearchType, ArrayOrderSearchType } from '../utils/compare';
19
19
  import type { callbackMapFnType, callbackProductFnType, IArrayValueObject } from './base-value-object';
20
20
  import { BaseValueObject, ErrorValueObject } from './base-value-object';
21
21
  import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from './primitive-object';
@@ -32,8 +32,10 @@ export declare class ArrayValueObject extends BaseValueObject {
32
32
  private _currentColumn;
33
33
  private _sliceCache;
34
34
  private _flattenCache;
35
+ private _flattenPosition;
35
36
  constructor(rawValue: string | IArrayValueObject);
36
37
  dispose(): void;
38
+ clone(): ArrayValueObject;
37
39
  getRowCount(): number;
38
40
  setRowCount(rowCount: number): void;
39
41
  getColumnCount(): number;
@@ -49,6 +51,7 @@ export declare class ArrayValueObject extends BaseValueObject {
49
51
  setArrayValue(value: BaseValueObject[][]): void;
50
52
  isArray(): boolean;
51
53
  get(row: number, column: number): BaseValueObject;
54
+ getRealValue(row: number, column: number): BaseValueObject | null;
52
55
  set(row: number, column: number, value: BaseValueObject): void;
53
56
  getRangePosition(): {
54
57
  startRow: number;
@@ -57,7 +60,17 @@ export declare class ArrayValueObject extends BaseValueObject {
57
60
  endColumn: number;
58
61
  };
59
62
  iterator(callback: (valueObject: Nullable<BaseValueObject>, rowIndex: number, columnIndex: number) => Nullable<boolean>): void;
63
+ iteratorReverse(callback: (valueObject: Nullable<BaseValueObject>, rowIndex: number, columnIndex: number) => Nullable<boolean>): void;
64
+ getLastTruePosition(): Nullable<{
65
+ row: number;
66
+ column: number;
67
+ }>;
68
+ getFirstTruePosition(): Nullable<{
69
+ row: number;
70
+ column: number;
71
+ }>;
60
72
  getFirstCell(): BaseValueObject;
73
+ getLastCell(): BaseValueObject;
61
74
  /**
62
75
  * Referring to matrix calculations,
63
76
  * extract the matching values from a true/false matrix based on parameters and store them in a two-dimensional array.
@@ -71,6 +84,16 @@ export declare class ArrayValueObject extends BaseValueObject {
71
84
  * https://numpy.org/doc/stable/reference/generated/numpy.chararray.flatten.html#numpy.chararray.flatten
72
85
  */
73
86
  flatten(): ArrayValueObject;
87
+ /**
88
+ * Flatten a 2D array.
89
+ * In Excel, errors and blank cells are ignored, which results in a binary search that cannot strictly adhere to the number of cells.
90
+ */
91
+ flattenPosition(): {
92
+ stringArray: BaseValueObject[];
93
+ stringPosition: number[];
94
+ numberArray: BaseValueObject[];
95
+ numberPosition: number[];
96
+ };
74
97
  /**
75
98
  * I'm looking to perform slicing operations on 2D arrays, similar to the functionality provided by NumPy.
76
99
  * https://numpy.org/doc/stable/user/basics.indexing.html
@@ -82,7 +105,17 @@ export declare class ArrayValueObject extends BaseValueObject {
82
105
  sortByRow(index: number): void;
83
106
  sortByColumn(index: number): void;
84
107
  transpose(): ArrayValueObject;
85
- binarySearch(valueObject: BaseValueObject, searchType?: ArrayBinarySearchType): number | null | undefined;
108
+ /**
109
+ * Due to the inability to effectively utilize the cache,
110
+ * the sequential matching approach is only used for special matches in XLOOKUP and XMATCH.
111
+ * For example, when match_mode is set to 1 and -1 for an exact match. If not found, it returns the next smaller item.
112
+ */
113
+ orderSearch(valueObject: BaseValueObject, searchType?: ArrayOrderSearchType, isDesc?: boolean, isFuzzyMatching?: boolean): void | {
114
+ row: number;
115
+ column: number;
116
+ } | null;
117
+ binarySearch(valueObject: BaseValueObject, searchType?: ArrayBinarySearchType): number | undefined;
118
+ private _binarySearch;
86
119
  sum(): BaseValueObject;
87
120
  max(): BaseValueObject;
88
121
  min(): BaseValueObject;
@@ -100,6 +133,7 @@ export declare class ArrayValueObject extends BaseValueObject {
100
133
  concatenateBack(valueObject: BaseValueObject): BaseValueObject;
101
134
  product(valueObject: BaseValueObject, callbackFn: callbackProductFnType): BaseValueObject;
102
135
  map(callbackFn: callbackMapFnType): BaseValueObject;
136
+ mapValue(callbackFn: callbackMapFnType): BaseValueObject;
103
137
  pow(valueObject: BaseValueObject): BaseValueObject;
104
138
  /**
105
139
  *
@@ -124,6 +158,14 @@ export declare class ArrayValueObject extends BaseValueObject {
124
158
  mean(): BaseValueObject;
125
159
  median(): BaseValueObject;
126
160
  var(): BaseValueObject;
161
+ /**
162
+ * STDEV.P: ddof=0, ignore strings and booleans
163
+ * STDEV.S: ddof=1, ignore strings and booleans
164
+ *
165
+ * STDEVPA: ddof=0,
166
+ * STDEVA: ddof=1,
167
+ * @returns
168
+ */
127
169
  std(): BaseValueObject;
128
170
  log(): BaseValueObject;
129
171
  log10(): BaseValueObject;
@@ -66,6 +66,7 @@ export declare class BaseValueObject extends ObjectClassType {
66
66
  multiply(valueObject: BaseValueObject): BaseValueObject;
67
67
  divided(valueObject: BaseValueObject): BaseValueObject;
68
68
  map(callbackFn: callbackMapFnType): BaseValueObject;
69
+ mapValue(callbackFn: callbackMapFnType): BaseValueObject;
69
70
  product(valueObject: BaseValueObject, callbackFn: callbackProductFnType): BaseValueObject;
70
71
  compare(valueObject: BaseValueObject, operator: compareToken): BaseValueObject;
71
72
  isEqual(valueObject: BaseValueObject): BaseValueObject;
@@ -17,7 +17,7 @@ import type { IWorkbookData } from '@univerjs/core';
17
17
  import { Univer } from '@univerjs/core';
18
18
  import type { Dependency } from '@wendellhu/redi';
19
19
  import type { ISheetData } from '../../basics/common';
20
- export declare function createCommandTestBed(workbookConfig?: IWorkbookData, dependencies?: Dependency[]): {
20
+ export declare function createFunctionTestBed(workbookConfig?: IWorkbookData, dependencies?: Dependency[]): {
21
21
  univer: Univer;
22
22
  get: {
23
23
  <T>(id: import("@wendellhu/redi").DependencyIdentifier<T>, lookUp?: import("@wendellhu/redi").LookUp | undefined): T;
@@ -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 {};
@@ -17,6 +17,9 @@ import type { Nullable } from '@univerjs/core';
17
17
  import { Disposable } from '@univerjs/core';
18
18
  import type { IFunctionNames } from '../basics/function';
19
19
  import type { FunctionVariantType, NodeValueType } from '../engine/reference-object/base-reference-object';
20
+ import type { ArrayBinarySearchType } from '../engine/utils/compare';
21
+ import { ArrayOrderSearchType } from '../engine/utils/compare';
22
+ import type { ArrayValueObject } from '../engine/value-object/array-value-object';
20
23
  import { type BaseValueObject, ErrorValueObject } from '../engine/value-object/base-value-object';
21
24
  import type { PrimitiveValueType } from '../engine/value-object/primitive-object';
22
25
  export declare class BaseFunction extends Disposable {
@@ -45,7 +48,7 @@ export declare class BaseFunction extends Disposable {
45
48
  * @param indexNum
46
49
  * @returns
47
50
  */
48
- getIndexNumValue(indexNum: BaseValueObject): number | ErrorValueObject;
51
+ getIndexNumValue(indexNum: BaseValueObject, defaultValue?: number): number | ErrorValueObject;
49
52
  /**
50
53
  * A logical value that specifies 1/TRUE , 0/FALSE, default 1
51
54
  * For instance range_lookup, A logical value that specifies whether you want VLOOKUP to find an approximate or an exact match
@@ -60,4 +63,23 @@ export declare class BaseFunction extends Disposable {
60
63
  * @returns
61
64
  */
62
65
  getZeroOrOneByOneDefault(logicValueObject?: BaseValueObject): number | undefined;
66
+ /**
67
+ * A logical value that specifies 1/TRUE , 0/FALSE, -1, default 1.
68
+ * The difference from getZeroOrOneByOneDefault is that we need to get -1
69
+ * @param logicValueObject
70
+ * @returns
71
+ */
72
+ getMatchTypeValue(logicValueObject?: BaseValueObject): number | undefined;
73
+ binarySearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, searchType?: ArrayBinarySearchType): BaseValueObject;
74
+ equalSearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean): BaseValueObject;
75
+ fuzzySearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean): BaseValueObject;
76
+ orderSearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, searchType?: ArrayOrderSearchType, isDesc?: boolean): BaseValueObject;
77
+ /**
78
+ * @param axis 0 row, 1 column
79
+ * @returns
80
+ */
81
+ binarySearchExpand(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, axis?: number, searchType?: ArrayBinarySearchType): ErrorValueObject | ArrayValueObject | undefined;
82
+ equalSearchExpand(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean, axis?: number): ErrorValueObject | ArrayValueObject | undefined;
83
+ fuzzySearchExpand(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean, axis?: number): ErrorValueObject | ArrayValueObject | undefined;
84
+ orderSearchExpand(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, searchType?: ArrayOrderSearchType, isDesc?: boolean, axis?: number): ErrorValueObject | ArrayValueObject | undefined;
63
85
  }
@@ -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,20 @@
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
+ import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
17
+ import { BaseFunction } from '../../base-function';
18
+ export declare class DateFunction extends BaseFunction {
19
+ calculate(year: BaseValueObject, month: BaseValueObject, day: BaseValueObject): BaseValueObject;
20
+ }
@@ -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,20 @@
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
+ import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
17
+ import { BaseFunction } from '../../base-function';
18
+ export declare class Day extends BaseFunction {
19
+ calculate(serialNumber: BaseValueObject): BaseValueObject;
20
+ }
@@ -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,23 @@
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
+ import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
17
+ import { BaseFunction } from '../../base-function';
18
+ /**
19
+ * TODO@Dushusir: support plaine text date: =EDATE("2020-1-1",1), =EDATE("2020/1/1",1) and other formats
20
+ */
21
+ export declare class Edate extends BaseFunction {
22
+ calculate(startDate: BaseValueObject, months: BaseValueObject): BaseValueObject;
23
+ }
@@ -13,4 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const functionDate: never[];
16
+ import { DateFunction } from './date';
17
+ import { FUNCTION_NAMES_DATE } from './function-names';
18
+ export declare const functionDate: (FUNCTION_NAMES_DATE | typeof DateFunction)[][];
@@ -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,20 @@
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
+ import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
17
+ import { BaseFunction } from '../../base-function';
18
+ export declare class Month extends BaseFunction {
19
+ calculate(serialNumber: BaseValueObject): BaseValueObject;
20
+ }
@@ -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 {};