Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat(formula): add some math formulas (#3381)

wpxp123456e736b8ad9d2c
diff --git a/packages/engine-formula/src/basics/__tests__/math.spec.ts b/packages/engine-formula/src/basics/__tests__/math.spec.ts
new file mode 100644
index 0000000000..1cb67e4d58
--- /dev/null
+++ b/packages/engine-formula/src/basics/__tests__/math.spec.ts
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+import { calculateCombin, calculateFactorial } from '../math';
+
+describe('Test math', () => {
+ it('Factorial test', () => {
+ expect(calculateFactorial(0)).toBe(1);
+ expect(calculateFactorial(1)).toBe(1);
+ expect(calculateFactorial(1.9)).toBe(1);
+ expect(calculateFactorial(5)).toBe(120);
+ expect(calculateFactorial(-1)).toBe(Number.NaN);
+ expect(calculateFactorial(171)).toBe(Infinity);
+ });
+
+ it('Combin test', () => {
+ expect(calculateCombin(8, 2)).toBe(28);
+ expect(calculateCombin(1000000, 2000)).toBe(Infinity);
+ });
+});
diff --git a/packages/engine-formula/src/basics/math.ts b/packages/engine-formula/src/basics/math.ts
new file mode 100644
index 0000000000..be79c40e8d
--- /dev/null
+++ b/packages/engine-formula/src/basics/math.ts
@@ -0,0 +1,129 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export function calculateFactorial(n: number, step: number = 1): number {
+ let _n = Math.floor(n);
+
+ if (n < 0) {
+ return Number.NaN;
+ }
+
+ let result = 1;
+
+ while (_n > 1 && Number.isFinite(result)) {
+ result *= _n;
+ _n -= step;
+ }
+
+ return result;
+}
+
+export function calculateCombin(n: number, k: number): number {
+ const t = Math.min(n - k, k);
+
+ let result = 1;
+
+ for (let i = 1; i <= t; i++) {
+ if (!Number.isFinite(result)) {
+ break;
+ }
+
+ result *= n - i + 1;
+ result /= i;
+ }
+
+ return result;
+}
+
+export function calculateGcd(a: number, b: number): number {
+ let _a = Math.floor(a);
+ let _b = Math.floor(b);
+
+ while (_b !== 0) {
+ const t = _b;
+ _b = _a % _b;
+ _a = t;
+ }
+
+ return _a;
+}
+
+export function calculateLcm(a: number, b: number): number {
+ const den = calculateGcd(a, b);
+
+ if (den === 0) {
+ return 0;
+ }
+
+ return Math.abs(a * b) / den;
+}
+
+export function calculateMdeterm(matrix: number[][]): number {
+ const n = matrix.length;
+
+ if (n === 1) {
+ return matrix[0][0];
+ }
+
+ if (n === 2) {
+ return matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0];
+ }
+
+ let det = 0;
+
+ for (let col = 0; col < n; col++) {
+ det += ((col % 2 === 0 ? 1 : -1) * matrix[0][col] * calculateMdeterm(minor(matrix, 0, col)));
+ }
+
+ return det;
+}
+
+export function calculateMinverse(matrix: number[][]): number[][] | null {
+ const det = calculateMdeterm(matrix);
+
+ if (det === 0) {
+ return null; // 矩阵不可逆
+ }
+
+ if (matrix.length === 1) {
+ return [[1 / det]];
+ }
+
+ const adjugate = adjoint(matrix);
+ const inverseMatrix = adjugate.map((row) => row.map((value) => value / det));
+
+ return inverseMatrix;
+}
+
+function minor(matrix: number[][], row: number, col: number): number[][] {
+ return matrix
+ .filter((_, r) => r !== row)
+ .map((row) => row.filter((_, c) => c !== col));
+}
+
+function adjoint(matrix: number[][]): number[][] {
+ const n = matrix.length;
+ const adj = Array.from({ length: n }, () => new Array(n).fill(0));
+
+ for (let i = 0; i < n; i++) {
+ for (let j = 0; j < n; j++) {
+ const sign = ((i + j) % 2 === 0 ? 1 : -1);
+ adj[j][i] = sign * calculateMdeterm(minor(matrix, i, j));
+ }
+ }
+
+ return adj;
+}
diff --git a/packages/engine-formula/src/functions/math/combin/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/combin/__tests__/index.spec.ts
new file mode 100644
index 0000000000..4ecf289c81
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/combin/__tests__/index.spec.ts
@@ -0,0 +1,111 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_MATH } from '../../function-names';
+import { Combin } from '../index';
+
+describe('Test combin function', () => {
+ const testFunction = new Combin(FUNCTION_NAMES_MATH.COMBIN);
+
+ describe('Combin', () => {
+ it('Value is normal number', () => {
+ const number = NumberValueObject.create(8);
+ const numberChosen = NumberValueObject.create(2);
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toBe(28);
+ });
+
+ it('Value is big number', () => {
+ const number = NumberValueObject.create(1000000);
+ const numberChosen = NumberValueObject.create(2000);
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is number negative', () => {
+ const number = NumberValueObject.create(8);
+ const numberChosen = NumberValueObject.create(-2);
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is number string', () => {
+ const number = NumberValueObject.create(8);
+ const numberChosen = StringValueObject.create('1.5');
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toBe(8);
+ });
+
+ it('Value is normal string', () => {
+ const number = NumberValueObject.create(8);
+ const numberChosen = StringValueObject.create('test');
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const number = NumberValueObject.create(8);
+ const numberChosen = BooleanValueObject.create(true);
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toBe(8);
+ });
+ it('Value is blank cell', () => {
+ const number = NumberValueObject.create(8);
+ const numberChosen = NullValueObject.create();
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toBe(1);
+ });
+ it('Value is error', () => {
+ const number = ErrorValueObject.create(ErrorType.NAME);
+ const numberChosen = NumberValueObject.create(2);
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+
+ const number2 = NumberValueObject.create(8);
+ const numberChosen2 = ErrorValueObject.create(ErrorType.NAME);
+ const result2 = testFunction.calculate(number2, numberChosen2);
+ expect(getObjectValue(result2)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const number = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const numberChosen = NumberValueObject.create(2);
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toStrictEqual([
+ [ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NUM, ErrorType.NUM, ErrorType.NUM],
+ [ErrorType.NUM, 4950, 1, ErrorType.VALUE, ErrorType.NUM, ErrorType.NAME],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/math/combin/index.ts b/packages/engine-formula/src/functions/math/combin/index.ts
new file mode 100644
index 0000000000..27d2e18400
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/combin/index.ts
@@ -0,0 +1,86 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { calculateCombin } from '../../../basics/math';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class Combin extends BaseFunction {
+ override minParams = 2;
+
+ override maxParams = 2;
+
+ override calculate(number: BaseValueObject, numberChosen: BaseValueObject): BaseValueObject {
+ const maxRowLength = Math.max(
+ number.isArray() ? (number as ArrayValueObject).getRowCount() : 1,
+ numberChosen.isArray() ? (numberChosen as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ number.isArray() ? (number as ArrayValueObject).getColumnCount() : 1,
+ numberChosen.isArray() ? (numberChosen as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const numberArray = expandArrayValueObject(maxRowLength, maxColumnLength, number, ErrorValueObject.create(ErrorType.NA));
+ const numberChosenArray = expandArrayValueObject(maxRowLength, maxColumnLength, numberChosen, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = numberArray.mapValue((numberObject, rowIndex, columnIndex) => {
+ let _numberObject = numberObject;
+ let numberChosenObject = numberChosenArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ if (_numberObject.isString()) {
+ _numberObject = _numberObject.convertToNumberObjectValue();
+ }
+
+ if (numberChosenObject.isString()) {
+ numberChosenObject = numberChosenObject.convertToNumberObjectValue();
+ }
+
+ if (_numberObject.isError()) {
+ return _numberObject;
+ }
+
+ if (numberChosenObject.isError()) {
+ return numberChosenObject;
+ }
+
+ const numberValue = Math.floor(+_numberObject.getValue());
+ const numberChosenValue = Math.floor(+numberChosenObject.getValue());
+
+ if (numberValue < 0 || numberChosenValue < 0 || numberValue < numberChosenValue) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ const result = calculateCombin(numberValue, numberChosenValue);
+
+ if (Number.isNaN(result) || !Number.isFinite(result)) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ return NumberValueObject.create(result);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+}
diff --git a/packages/engine-formula/src/functions/math/combina/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/combina/__tests__/index.spec.ts
new file mode 100644
index 0000000000..3111d52325
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/combina/__tests__/index.spec.ts
@@ -0,0 +1,111 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_MATH } from '../../function-names';
+import { Combina } from '../index';
+
+describe('Test combina function', () => {
+ const testFunction = new Combina(FUNCTION_NAMES_MATH.COMBINA);
+
+ describe('Combina', () => {
+ it('Value is normal number', () => {
+ const number = NumberValueObject.create(8);
+ const numberChosen = NumberValueObject.create(2);
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toBe(36);
+ });
+
+ it('Value is big number', () => {
+ const number = NumberValueObject.create(1000000);
+ const numberChosen = NumberValueObject.create(2000);
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is number negative', () => {
+ const number = NumberValueObject.create(8);
+ const numberChosen = NumberValueObject.create(-2);
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is number string', () => {
+ const number = NumberValueObject.create(8);
+ const numberChosen = StringValueObject.create('1.5');
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toBe(8);
+ });
+
+ it('Value is normal string', () => {
+ const number = NumberValueObject.create(8);
+ const numberChosen = StringValueObject.create('test');
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const number = NumberValueObject.create(8);
+ const numberChosen = BooleanValueObject.create(true);
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toBe(8);
+ });
+ it('Value is blank cell', () => {
+ const number = NumberValueObject.create(8);
+ const numberChosen = NullValueObject.create();
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toBe(1);
+ });
+ it('Value is error', () => {
+ const number = ErrorValueObject.create(ErrorType.NAME);
+ const numberChosen = NumberValueObject.create(2);
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+
+ const number2 = NumberValueObject.create(8);
+ const numberChosen2 = ErrorValueObject.create(ErrorType.NAME);
+ const result2 = testFunction.calculate(number2, numberChosen2);
+ expect(getObjectValue(result2)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const number = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const numberChosen = NumberValueObject.create(2);
+ const result = testFunction.calculate(number, numberChosen);
+ expect(getObjectValue(result)).toStrictEqual([
+ [1, ErrorType.VALUE, 1, 1, ErrorType.NUM, ErrorType.NUM],
+ [ErrorType.NUM, 5050, 3, ErrorType.VALUE, ErrorType.NUM, ErrorType.NAME],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/math/combina/index.ts b/packages/engine-formula/src/functions/math/combina/index.ts
new file mode 100644
index 0000000000..9203c6e9eb
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/combina/index.ts
@@ -0,0 +1,86 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { calculateCombin } from '../../../basics/math';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class Combina extends BaseFunction {
+ override minParams = 2;
+
+ override maxParams = 2;
+
+ override calculate(number: BaseValueObject, numberChosen: BaseValueObject): BaseValueObject {
+ const maxRowLength = Math.max(
+ number.isArray() ? (number as ArrayValueObject).getRowCount() : 1,
+ numberChosen.isArray() ? (numberChosen as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ number.isArray() ? (number as ArrayValueObject).getColumnCount() : 1,
+ numberChosen.isArray() ? (numberChosen as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const numberArray = expandArrayValueObject(maxRowLength, maxColumnLength, number, ErrorValueObject.create(ErrorType.NA));
+ const numberChosenArray = expandArrayValueObject(maxRowLength, maxColumnLength, numberChosen, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = numberArray.mapValue((numberObject, rowIndex, columnIndex) => {
+ let _numberObject = numberObject;
+ let numberChosenObject = numberChosenArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ if (_numberObject.isString()) {
+ _numberObject = _numberObject.convertToNumberObjectValue();
+ }
+
+ if (numberChosenObject.isString()) {
+ numberChosenObject = numberChosenObject.convertToNumberObjectValue();
+ }
+
+ if (_numberObject.isError()) {
+ return _numberObject;
+ }
+
+ if (numberChosenObject.isError()) {
+ return numberChosenObject;
+ }
+
+ const numberValue = Math.floor(+_numberObject.getValue());
+ const numberChosenValue = Math.floor(+numberChosenObject.getValue());
+
+ if (numberValue < 0 || numberChosenValue < 0 || (numberValue === 0 && numberValue < numberChosenValue)) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ const result = calculateCombin(numberValue + numberChosenValue - 1, numberValue - 1);
+
+ if (Number.isNaN(result) || !Number.isFinite(result)) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ return NumberValueObject.create(result);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+}
diff --git a/packages/engine-formula/src/functions/math/fact/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/fact/__tests__/index.spec.ts
new file mode 100644
index 0000000000..2863b431d4
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/fact/__tests__/index.spec.ts
@@ -0,0 +1,97 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_MATH } from '../../function-names';
+import { Fact } from '../index';
+
+describe('Test fact function', () => {
+ const testFunction = new Fact(FUNCTION_NAMES_MATH.FACT);
+
+ describe('Fact', () => {
+ it('Value is normal number', () => {
+ const number = NumberValueObject.create(8);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(40320);
+ });
+
+ it('Value is big number', () => {
+ const number = NumberValueObject.create(1000000);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is number negative', () => {
+ const number = NumberValueObject.create(-8);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is number string', () => {
+ const number = StringValueObject.create('1.5');
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(1);
+ });
+
+ it('Value is normal string', () => {
+ const number = StringValueObject.create('test');
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const number = BooleanValueObject.create(true);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(1);
+ });
+ it('Value is blank cell', () => {
+ const number = NullValueObject.create();
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(1);
+ });
+ it('Value is error', () => {
+ const number = ErrorValueObject.create(ErrorType.NAME);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const number = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toStrictEqual([
+ [1, ErrorType.VALUE, 1, 1, 1, 1],
+ [1, 9.332621544394418e+157, 2, ErrorType.VALUE, ErrorType.NUM, ErrorType.NAME],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/math/fact/index.ts b/packages/engine-formula/src/functions/math/fact/index.ts
new file mode 100644
index 0000000000..0aca4e2152
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/fact/index.ts
@@ -0,0 +1,58 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { calculateFactorial } from '../../../basics/math';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class Fact extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 1;
+
+ override calculate(number: BaseValueObject): BaseValueObject {
+ if (number.isArray()) {
+ return (number as ArrayValueObject).mapValue((numberObject) => this._handleSingleObject(numberObject));
+ }
+
+ return this._handleSingleObject(number);
+ }
+
+ private _handleSingleObject(number: BaseValueObject): BaseValueObject {
+ let _number = number;
+
+ if (_number.isString()) {
+ _number = _number.convertToNumberObjectValue();
+ }
+
+ if (_number.isError()) {
+ return _number;
+ }
+
+ const numberValue = Math.floor(+_number.getValue());
+
+ const result = calculateFactorial(numberValue);
+
+ if (Number.isNaN(result) || !Number.isFinite(result)) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/math/factdouble/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/factdouble/__tests__/index.spec.ts
new file mode 100644
index 0000000000..9cfcf492d9
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/factdouble/__tests__/index.spec.ts
@@ -0,0 +1,108 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_MATH } from '../../function-names';
+import { Factdouble } from '../index';
+
+describe('Test factdouble function', () => {
+ const testFunction = new Factdouble(FUNCTION_NAMES_MATH.FACTDOUBLE);
+
+ describe('Factdouble', () => {
+ it('Value is normal number', () => {
+ const number = NumberValueObject.create(8);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(384);
+ });
+
+ it('Value is big number', () => {
+ const number = NumberValueObject.create(1000000);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is number negative', () => {
+ const number = NumberValueObject.create(-8);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is number string', () => {
+ const number = StringValueObject.create('1.5');
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(1);
+ });
+
+ it('Value is normal string', () => {
+ const number = StringValueObject.create('test');
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const number = BooleanValueObject.create(true);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(1);
+ });
+ it('Value is blank cell', () => {
+ const number = NullValueObject.create();
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(1);
+ });
+ it('Value is error', () => {
+ const number = ErrorValueObject.create(ErrorType.NAME);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const number = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toStrictEqual(ErrorType.VALUE);
+
+ const number2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [3],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result2 = testFunction.calculate(number2);
+ expect(getObjectValue(result2)).toStrictEqual(3);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/math/factdouble/index.ts b/packages/engine-formula/src/functions/math/factdouble/index.ts
new file mode 100644
index 0000000000..100ba3f1e7
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/factdouble/index.ts
@@ -0,0 +1,67 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { calculateFactorial } from '../../../basics/math';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class Factdouble extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 1;
+
+ override calculate(number: BaseValueObject): BaseValueObject {
+ let _number = number;
+
+ if (number.isArray()) {
+ const rowCount = (number as ArrayValueObject).getRowCount();
+ const columnCount = (number as ArrayValueObject).getColumnCount();
+
+ if (rowCount > 1 || columnCount > 1) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ _number = (number as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return this._handleSingleObject(_number);
+ }
+
+ private _handleSingleObject(number: BaseValueObject): BaseValueObject {
+ let _number = number;
+
+ if (_number.isString()) {
+ _number = _number.convertToNumberObjectValue();
+ }
+
+ if (_number.isError()) {
+ return _number;
+ }
+
+ const numberValue = Math.floor(+_number.getValue());
+
+ const result = calculateFactorial(numberValue, 2);
+
+ if (Number.isNaN(result) || !Number.isFinite(result)) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/math/function-map.ts b/packages/engine-formula/src/functions/math/function-map.ts
index 8e85183bf6..2cead63f69 100644
--- a/packages/engine-formula/src/functions/math/function-map.ts
+++ b/packages/engine-formula/src/functions/math/function-map.ts
@@ -29,6 +29,8 @@ import { Base } from './base';
import { Ceiling } from './ceiling';
import { CeilingMath } from './ceiling-math';
import { CeilingPrecise } from './ceiling-precise';
+import { Combin } from './combin';
+import { Combina } from './combina';
import { Cos } from './cos';
import { Cosh } from './cosh';
import { Cot } from './cot';
@@ -39,18 +41,29 @@ import { Decimal } from './decimal';
import { Degrees } from './degrees';
import { Even } from './even';
import { Exp } from './exp';
+import { Fact } from './fact';
+import { Factdouble } from './factdouble';
import { Floor } from './floor';
import { FloorMath } from './floor-math';
import { FloorPrecise } from './floor-precise';
+import { Gcd } from './gcd';
+import { Int } from './int';
+import { Lcm } from './lcm';
import { Ln } from './ln';
import { Log } from './log';
import { Log10 } from './log10';
+import { Mdeterm } from './mdeterm';
+import { Minverse } from './minverse';
+import { Mmult } from './mmult';
import { Mod } from './mod';
import { Mround } from './mround';
+import { Multinomial } from './multinomial';
+import { Munit } from './munit';
import { Odd } from './odd';
import { Pi } from './pi';
import { Power } from './power';
import { Product } from './product';
+import { Quotient } from './quotient';
import { Radians } from './radians';
import { Rand } from './rand';
import { Randarray } from './randarray';
@@ -60,6 +73,9 @@ import { Rounddown } from './rounddown';
import { Roundup } from './roundup';
import { Sec } from './sec';
import { Sech } from './sech';
+import { Seriessum } from './seriessum';
+import { Sequence } from './sequence';
+import { Sign } from './sign';
import { Sin } from './sin';
import { Sinh } from './sinh';
import { Sqrt } from './sqrt';
@@ -92,6 +108,8 @@ export const functionMath = [
[Ceiling, FUNCTION_NAMES_MATH.CEILING],
[CeilingMath, FUNCTION_NAMES_MATH.CEILING_MATH],
[CeilingPrecise, FUNCTION_NAMES_MATH.CEILING_PRECISE],
+ [Combin, FUNCTION_NAMES_MATH.COMBIN],
+ [Combina, FUNCTION_NAMES_MATH.COMBINA],
[Cos, FUNCTION_NAMES_MATH.COS],
[Cosh, FUNCTION_NAMES_MATH.COSH],
[Cot, FUNCTION_NAMES_MATH.COT],
@@ -102,18 +120,29 @@ export const functionMath = [
[Degrees, FUNCTION_NAMES_MATH.DEGREES],
[Even, FUNCTION_NAMES_MATH.EVEN],
[Exp, FUNCTION_NAMES_MATH.EXP],
+ [Fact, FUNCTION_NAMES_MATH.FACT],
+ [Factdouble, FUNCTION_NAMES_MATH.FACTDOUBLE],
[Floor, FUNCTION_NAMES_MATH.FLOOR],
[FloorMath, FUNCTION_NAMES_MATH.FLOOR_MATH],
[FloorPrecise, FUNCTION_NAMES_MATH.FLOOR_PRECISE],
+ [Gcd, FUNCTION_NAMES_MATH.GCD],
+ [Int, FUNCTION_NAMES_MATH.INT],
+ [Lcm, FUNCTION_NAMES_MATH.LCM],
[Ln, FUNCTION_NAMES_MATH.LN],
[Log, FUNCTION_NAMES_MATH.LOG],
[Log10, FUNCTION_NAMES_MATH.LOG10],
+ [Mdeterm, FUNCTION_NAMES_MATH.MDETERM],
+ [Minverse, FUNCTION_NAMES_MATH.MINVERSE],
+ [Mmult, FUNCTION_NAMES_MATH.MMULT],
[Mod, FUNCTION_NAMES_MATH.MOD],
[Mround, FUNCTION_NAMES_MATH.MROUND],
+ [Multinomial, FUNCTION_NAMES_MATH.MULTINOMIAL],
+ [Munit, FUNCTION_NAMES_MATH.MUNIT],
[Odd, FUNCTION_NAMES_MATH.ODD],
[Pi, FUNCTION_NAMES_MATH.PI],
[Power, FUNCTION_NAMES_MATH.POWER],
[Product, FUNCTION_NAMES_MATH.PRODUCT],
+ [Quotient, FUNCTION_NAMES_MATH.QUOTIENT],
[Radians, FUNCTION_NAMES_MATH.RADIANS],
[Rand, FUNCTION_NAMES_MATH.RAND],
[Randarray, FUNCTION_NAMES_MATH.RANDARRAY],
@@ -123,6 +152,9 @@ export const functionMath = [
[Roundup, FUNCTION_NAMES_MATH.ROUNDUP],
[Sec, FUNCTION_NAMES_MATH.SEC],
[Sech, FUNCTION_NAMES_MATH.SECH],
+ [Seriessum, FUNCTION_NAMES_MATH.SERIESSUM],
+ [Sequence, FUNCTION_NAMES_MATH.SEQUENCE],
+ [Sign, FUNCTION_NAMES_MATH.SIGN],
[Sin, FUNCTION_NAMES_MATH.SIN],
[Sinh, FUNCTION_NAMES_MATH.SINH],
[Sqrt, FUNCTION_NAMES_MATH.SQRT],
diff --git a/packages/engine-formula/src/functions/math/gcd/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/gcd/__tests__/index.spec.ts
new file mode 100644
index 0000000000..971c858d32
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/gcd/__tests__/index.spec.ts
@@ -0,0 +1,102 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_MATH } from '../../function-names';
+import { Gcd } from '../index';
+
+describe('Test gcd function', () => {
+ const testFunction = new Gcd(FUNCTION_NAMES_MATH.GCD);
+
+ describe('Gcd', () => {
+ it('Value is normal number', () => {
+ const number1 = NumberValueObject.create(5);
+ const number2 = NumberValueObject.create(2);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(1);
+ });
+
+ it('Value is big number', () => {
+ const number1 = NumberValueObject.create(1000000);
+ const number2 = NumberValueObject.create(3222);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(2);
+ });
+
+ it('Value is number negative', () => {
+ const number1 = NumberValueObject.create(-8);
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is number string', () => {
+ const number1 = StringValueObject.create('1.5');
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(1);
+ });
+
+ it('Value is normal string', () => {
+ const number1 = StringValueObject.create('test');
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const number1 = BooleanValueObject.create(true);
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+ it('Value is blank cell', () => {
+ const number1 = NullValueObject.create();
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(8);
+ });
+ it('Value is error', () => {
+ const number1 = ErrorValueObject.create(ErrorType.NAME);
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const number = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, null, ' ', 1.23, true, false],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toStrictEqual(ErrorType.VALUE);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/math/gcd/index.ts b/packages/engine-formula/src/functions/math/gcd/index.ts
new file mode 100644
index 0000000000..681b074486
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/gcd/index.ts
@@ -0,0 +1,115 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { calculateGcd } from '../../../basics/math';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class Gcd extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 255;
+
+ override calculate(...variants: BaseValueObject[]): BaseValueObject {
+ let result = 0;
+
+ for (let i = 0; i < variants.length; i++) {
+ const variant = variants[i];
+
+ if (variant.isNull()) {
+ continue;
+ }
+
+ if (variant.isArray()) {
+ let isError = false;
+ let errorObject: ErrorValueObject = ErrorValueObject.create(ErrorType.VALUE);
+
+ (variant as ArrayValueObject).iterator((valueObject) => {
+ if (valueObject?.isNull()) {
+ return true;
+ }
+
+ const { isError: _isError, errorObject: _errorObject, number } = this._handleSingleObject(valueObject as BaseValueObject);
+
+ if (_isError) {
+ isError = true;
+ errorObject = _errorObject as ErrorValueObject;
+ return false;
+ }
+
+ result = calculateGcd(result, number as number);
+ });
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+ } else {
+ const { isError, errorObject, number } = this._handleSingleObject(variant);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ result = calculateGcd(result, number as number);
+ }
+ }
+
+ return NumberValueObject.create(result);
+ }
+
+ private _handleSingleObject(number: BaseValueObject) {
+ if (number.isBoolean()) {
+ return {
+ isError: true,
+ errorObject: ErrorValueObject.create(ErrorType.VALUE),
+ number: null,
+ };
+ }
+
+ let _number = number;
+
+ if (number.isString()) {
+ _number = _number.convertToNumberObjectValue();
+ }
+
+ if (_number.isError()) {
+ return {
+ isError: true,
+ errorObject: _number as ErrorValueObject,
+ number: null,
+ };
+ }
+
+ const numberValue = Math.floor(+_number.getValue());
+
+ if (numberValue < 0 || numberValue >= 2 ** 53) {
+ return {
+ isError: true,
+ errorObject: ErrorValueObject.create(ErrorType.NUM),
+ number: null,
+ };
+ }
+
+ return {
+ isError: false,
+ errorObject: null,
+ number: numberValue,
+ };
+ }
+}
diff --git a/packages/engine-formula/src/functions/math/int/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/int/__tests__/index.spec.ts
new file mode 100644
index 0000000000..4d1a3609a7
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/int/__tests__/index.spec.ts
@@ -0,0 +1,91 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_MATH } from '../../function-names';
+import { Int } from '../index';
+
+describe('Test int function', () => {
+ const testFunction = new Int(FUNCTION_NAMES_MATH.INT);
+
+ describe('Int', () => {
+ it('Value is normal number', () => {
+ const number = NumberValueObject.create(8.9);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(8);
+ });
+
+ it('Value is number negative', () => {
+ const number = NumberValueObject.create(-8.9);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(-9);
+ });
+
+ it('Value is number string', () => {
+ const number = StringValueObject.create('1.5');
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(1);
+ });
+
+ it('Value is normal string', () => {
+ const number = StringValueObject.create('test');
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const number = BooleanValueObject.create(true);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(1);
+ });
+ it('Value is blank cell', () => {
+ const number = NullValueObject.create();
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(0);
+ });
+ it('Value is error', () => {
+ const number = ErrorValueObject.create(ErrorType.NAME);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const number = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3.4, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toStrictEqual([
+ [1, ErrorType.VALUE, 1, 1, 0, 0],
+ [0, 100, 2, ErrorType.VALUE, -4, ErrorType.NAME],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/math/int/index.ts b/packages/engine-formula/src/functions/math/int/index.ts
new file mode 100644
index 0000000000..87c9ddce24
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/int/index.ts
@@ -0,0 +1,50 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
+
+export class Int extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 1;
+
+ override calculate(number: BaseValueObject): BaseValueObject {
+ if (number.isArray()) {
+ return (number as ArrayValueObject).mapValue((numberObject) => this._handleSingleObject(numberObject));
+ }
+
+ return this._handleSingleObject(number);
+ }
+
+ private _handleSingleObject(number: BaseValueObject): BaseValueObject {
+ let _number = number;
+
+ if (_number.isString()) {
+ _number = _number.convertToNumberObjectValue();
+ }
+
+ if (_number.isError()) {
+ return _number;
+ }
+
+ const numberValue = Math.floor(+_number.getValue());
+
+ return NumberValueObject.create(numberValue);
+ }
+}
diff --git a/packages/engine-formula/src/functions/math/lcm/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/lcm/__tests__/index.spec.ts
new file mode 100644
index 0000000000..b66d14918e
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/lcm/__tests__/index.spec.ts
@@ -0,0 +1,122 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_MATH } from '../../function-names';
+import { Lcm } from '../index';
+
+describe('Test lcm function', () => {
+ const testFunction = new Lcm(FUNCTION_NAMES_MATH.LCM);
+
+ describe('Lcm', () => {
+ it('Value is normal number', () => {
+ const number1 = NumberValueObject.create(5);
+ const number2 = NumberValueObject.create(2);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(10);
+
+ const number3 = NumberValueObject.create(0);
+ const number4 = NumberValueObject.create(0);
+ const result2 = testFunction.calculate(number3, number4);
+ expect(getObjectValue(result2)).toBe(0);
+ });
+
+ it('Value is big number', () => {
+ const number1 = NumberValueObject.create(1000000);
+ const number2 = NumberValueObject.create(3222);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(1611000000);
+ });
+
+ it('Value is number negative', () => {
+ const number1 = NumberValueObject.create(-8);
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is number string', () => {
+ const number1 = StringValueObject.create('1.5');
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(8);
+ });
+
+ it('Value is normal string', () => {
+ const number1 = StringValueObject.create('test');
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const number1 = BooleanValueObject.create(true);
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+ it('Value is blank cell', () => {
+ const number1 = NullValueObject.create();
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(8);
+ });
+ it('Value is error', () => {
+ const number1 = ErrorValueObject.create(ErrorType.NAME);
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const number = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toStrictEqual(ErrorType.VALUE);
+
+ const number2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [null, null, null, null, null, null],
+ [null, null, null, null, null, null],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result2 = testFunction.calculate(number2);
+ expect(getObjectValue(result2)).toStrictEqual(0);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/math/lcm/index.ts b/packages/engine-formula/src/functions/math/lcm/index.ts
new file mode 100644
index 0000000000..027ab08d52
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/lcm/index.ts
@@ -0,0 +1,126 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { calculateLcm } from '../../../basics/math';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class Lcm extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 255;
+
+ override calculate(...variants: BaseValueObject[]): BaseValueObject {
+ let result = 1;
+ let noCalculate = true;
+
+ for (let i = 0; i < variants.length; i++) {
+ const variant = variants[i];
+
+ if (variant.isNull()) {
+ continue;
+ }
+
+ if (variant.isArray()) {
+ let isError = false;
+ let errorObject: ErrorValueObject = ErrorValueObject.create(ErrorType.VALUE);
+
+ (variant as ArrayValueObject).iterator((valueObject) => {
+ if (valueObject?.isNull()) {
+ return true;
+ }
+
+ const { isError: _isError, errorObject: _errorObject, number } = this._handleSingleObject(valueObject as BaseValueObject);
+
+ if (_isError) {
+ isError = true;
+ errorObject = _errorObject as ErrorValueObject;
+ return false;
+ }
+
+ result = calculateLcm(result, number as number);
+ noCalculate = false;
+ });
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+ } else {
+ const { isError, errorObject, number } = this._handleSingleObject(variant);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ result = calculateLcm(result, number as number);
+ noCalculate = false;
+ }
+ }
+
+ if (noCalculate) {
+ return NumberValueObject.create(0);
+ }
+
+ if (Number.isNaN(result) || !Number.isFinite(result) || result >= 2 ** 53) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ return NumberValueObject.create(result);
+ }
+
+ private _handleSingleObject(number: BaseValueObject) {
+ if (number.isBoolean()) {
+ return {
+ isError: true,
+ errorObject: ErrorValueObject.create(ErrorType.VALUE),
+ number: null,
+ };
+ }
+
+ let _number = number;
+
+ if (number.isString()) {
+ _number = _number.convertToNumberObjectValue();
+ }
+
+ if (_number.isError()) {
+ return {
+ isError: true,
+ errorObject: _number as ErrorValueObject,
+ number: null,
+ };
+ }
+
+ const numberValue = Math.floor(+_number.getValue());
+
+ if (numberValue < 0) {
+ return {
+ isError: true,
+ errorObject: ErrorValueObject.create(ErrorType.NUM),
+ number: null,
+ };
+ }
+
+ return {
+ isError: false,
+ errorObject: null,
+ number: numberValue,
+ };
+ }
+}
diff --git a/packages/engine-formula/src/functions/math/mdeterm/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/mdeterm/__tests__/index.spec.ts
new file mode 100644
index 0000000000..b3867fc037
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/mdeterm/__tests__/index.spec.ts
@@ -0,0 +1,125 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_MATH } from '../../function-names';
+import { Mdeterm } from '../index';
+
+describe('Test mdeterm function', () => {
+ const testFunction = new Mdeterm(FUNCTION_NAMES_MATH.MDETERM);
+
+ describe('Mdeterm', () => {
+ it('Value is normal number', () => {
+ const array = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, 2, 3],
+ [4, 5, 6],
+ [7, 8, 9],
+ ]),
+ rowCount: 3,
+ columnCount: 3,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array);
+ expect(getObjectValue(result)).toBe(0);
+
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1.5, 2, 3],
+ [2, 5, 6],
+ [7, 8, 9],
+ ]),
+ rowCount: 3,
+ columnCount: 3,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result2 = testFunction.calculate(array2);
+ expect(getObjectValue(result2)).toBe(-13.5);
+
+ const array3 = NumberValueObject.create(1);
+ const result3 = testFunction.calculate(array3);
+ expect(getObjectValue(result3)).toBe(1);
+ });
+
+ it('ArrayRowCount !== arrayColumnCount', () => {
+ const array = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, 2, 3],
+ [4, 5, 6],
+ ]),
+ rowCount: 2,
+ columnCount: 3,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is normal string', () => {
+ const array = StringValueObject.create('test');
+ const result = testFunction.calculate(array);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const array = BooleanValueObject.create(true);
+ const result = testFunction.calculate(array);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+ it('Value is blank cell', () => {
+ const array = NullValueObject.create();
+ const result = testFunction.calculate(array);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+ it('Value is error', () => {
+ const array = ErrorValueObject.create(ErrorType.NAME);
+ const result = testFunction.calculate(array);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const array = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3.4, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array);
+ expect(getObjectValue(result)).toStrictEqual(ErrorType.VALUE);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/math/mdeterm/index.ts b/packages/engine-formula/src/functions/math/mdeterm/index.ts
new file mode 100644
index 0000000000..c6abc702cf
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/mdeterm/index.ts
@@ -0,0 +1,73 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { calculateMdeterm } from '../../../basics/math';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class Mdeterm extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 1;
+
+ override calculate(array: BaseValueObject): BaseValueObject {
+ const arrayRowCount = array.isArray() ? (array as ArrayValueObject).getRowCount() : 1;
+ const arrayColumnCount = array.isArray() ? (array as ArrayValueObject).getColumnCount() : 1;
+
+ const matrix: number[][] = [];
+
+ for (let r = 0; r < arrayRowCount; r++) {
+ const row: number[] = [];
+
+ for (let c = 0; c < arrayColumnCount; c++) {
+ let valueObject = array.isArray() ? (array as ArrayValueObject).get(r, c) as BaseValueObject : array;
+
+ if (valueObject.isError()) {
+ return valueObject;
+ }
+
+ if (valueObject.isNull() || valueObject.isBoolean()) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ if (valueObject.isString()) {
+ valueObject = valueObject.convertToNumberObjectValue();
+ }
+
+ if (valueObject.isError()) {
+ return valueObject;
+ }
+
+ const value = +valueObject.getValue();
+
+ row.push(value);
+ }
+
+ matrix.push(row);
+ }
+
+ if (arrayRowCount !== arrayColumnCount) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ const result = calculateMdeterm(matrix);
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/math/minverse/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/minverse/__tests__/index.spec.ts
new file mode 100644
index 0000000000..0e1aab6788
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/minverse/__tests__/index.spec.ts
@@ -0,0 +1,131 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_MATH } from '../../function-names';
+import { Minverse } from '../index';
+
+describe('Test minverse function', () => {
+ const testFunction = new Minverse(FUNCTION_NAMES_MATH.MINVERSE);
+
+ describe('Minverse', () => {
+ it('Value is normal number', () => {
+ const array = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, 2, 3],
+ [4, 5, 6],
+ [7, 8, 9],
+ ]),
+ rowCount: 3,
+ columnCount: 3,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1.5, 2, 3],
+ [2, 5, 6],
+ [7, 8, 9],
+ ]),
+ rowCount: 3,
+ columnCount: 3,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result2 = testFunction.calculate(array2);
+ expect(getObjectValue(result2)).toStrictEqual([
+ [0.2222222222222222, -0.4444444444444444, 0.2222222222222222],
+ [-1.7777777777777777, 0.5555555555555556, 0.2222222222222222],
+ [1.4074074074074074, -0.14814814814814814, -0.25925925925925924],
+ ]);
+
+ const array3 = NumberValueObject.create(1);
+ const result3 = testFunction.calculate(array3);
+ expect(getObjectValue(result3)).toStrictEqual([
+ [1],
+ ]);
+ });
+
+ it('ArrayRowCount !== arrayColumnCount', () => {
+ const array = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, 2, 3],
+ [4, 5, 6],
+ ]),
+ rowCount: 2,
+ columnCount: 3,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is normal string', () => {
+ const array = StringValueObject.create('test');
+ const result = testFunction.calculate(array);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const array = BooleanValueObject.create(true);
+ const result = testFunction.calculate(array);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+ it('Value is blank cell', () => {
+ const array = NullValueObject.create();
+ const result = testFunction.calculate(array);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+ it('Value is error', () => {
+ const array = ErrorValueObject.create(ErrorType.NAME);
+ const result = testFunction.calculate(array);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const array = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3.4, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array);
+ expect(getObjectValue(result)).toStrictEqual(ErrorType.VALUE);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/math/minverse/index.ts b/packages/engine-formula/src/functions/math/minverse/index.ts
new file mode 100644
index 0000000000..ab925cc3af
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/minverse/index.ts
@@ -0,0 +1,76 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { calculateMinverse } from '../../../basics/math';
+import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { BaseFunction } from '../../base-function';
+
+export class Minverse extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 1;
+
+ override calculate(array: BaseValueObject): BaseValueObject {
+ const arrayRowCount = array.isArray() ? (array as ArrayValueObject).getRowCount() : 1;
+ const arrayColumnCount = array.isArray() ? (array as ArrayValueObject).getColumnCount() : 1;
+
+ const matrix: number[][] = [];
+
+ for (let r = 0; r < arrayRowCount; r++) {
+ const row: number[] = [];
+
+ for (let c = 0; c < arrayColumnCount; c++) {
+ let valueObject = array.isArray() ? (array as ArrayValueObject).get(r, c) as BaseValueObject : array;
+
+ if (valueObject.isError()) {
+ return valueObject;
+ }
+
+ if (valueObject.isNull() || valueObject.isBoolean()) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ if (valueObject.isString()) {
+ valueObject = valueObject.convertToNumberObjectValue();
+ }
+
+ if (valueObject.isError()) {
+ return valueObject;
+ }
+
+ const value = +valueObject.getValue();
+
+ row.push(value);
+ }
+
+ matrix.push(row);
+ }
+
+ if (arrayRowCount !== arrayColumnCount) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ const result = calculateMinverse(matrix);
+
+ if (result === null) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ return ArrayValueObject.createByArray(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/math/mmult/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/mmult/__tests__/index.spec.ts
new file mode 100644
index 0000000000..4e74126617
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/mmult/__tests__/index.spec.ts
@@ -0,0 +1,124 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_MATH } from '../../function-names';
+import { Mmult } from '../index';
+
+describe('Test mmult function', () => {
+ const testFunction = new Mmult(FUNCTION_NAMES_MATH.MMULT);
+
+ describe('Mmult', () => {
+ it('Value is normal number', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, 2],
+ [4, 5],
+ ]),
+ rowCount: 2,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, 2, 3],
+ [4, 5, 6],
+ ]),
+ rowCount: 2,
+ columnCount: 3,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toStrictEqual([
+ [9, 12, 15],
+ [24, 33, 42],
+ ]);
+ });
+
+ it('Array1ColumnCount !== array2RowCount', () => {
+ const array1 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, 2],
+ [4, 5],
+ ]),
+ rowCount: 2,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const array2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, 2],
+ [3, 4],
+ [5, 6],
+ ]),
+ rowCount: 3,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toStrictEqual(ErrorType.VALUE);
+ });
+
+ it('Value is normal string', () => {
+ const array1 = StringValueObject.create('test');
+ const array2 = NumberValueObject.create(1);
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const array1 = BooleanValueObject.create(true);
+ const array2 = NumberValueObject.create(1);
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+ it('Value is blank cell', () => {
+ const array1 = NullValueObject.create();
+ const array2 = NumberValueObject.create(1);
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+ it('Value is error', () => {
+ const array1 = ErrorValueObject.create(ErrorType.NAME);
+ const array2 = NumberValueObject.create(1);
+ const result = testFunction.calculate(array1, array2);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+
+ const array3 = NumberValueObject.create(1);
+ const array4 = ErrorValueObject.create(ErrorType.NAME);
+ const result2 = testFunction.calculate(array3, array4);
+ expect(getObjectValue(result2)).toBe(ErrorType.NAME);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/math/mmult/index.ts b/packages/engine-formula/src/functions/math/mmult/index.ts
new file mode 100644
index 0000000000..cea4bead8e
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/mmult/index.ts
@@ -0,0 +1,113 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { BaseFunction } from '../../base-function';
+
+export class Mmult extends BaseFunction {
+ override minParams = 2;
+
+ override maxParams = 2;
+
+ override calculate(array1: BaseValueObject, array2: BaseValueObject): BaseValueObject {
+ const array1RowCount = array1.isArray() ? (array1 as ArrayValueObject).getRowCount() : 1;
+ const array1ColumnCount = array1.isArray() ? (array1 as ArrayValueObject).getColumnCount() : 1;
+
+ const array2RowCount = array2.isArray() ? (array2 as ArrayValueObject).getRowCount() : 1;
+ const array2ColumnCount = array2.isArray() ? (array2 as ArrayValueObject).getColumnCount() : 1;
+
+ if (array1ColumnCount !== array2RowCount) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ const matrix1 = this._getMatrix(array1, array1RowCount, array1ColumnCount);
+ const matrix2 = this._getMatrix(array2, array2RowCount, array2ColumnCount);
+
+ if (matrix1 instanceof ErrorValueObject) {
+ return matrix1;
+ }
+
+ if (matrix2 instanceof ErrorValueObject) {
+ return matrix2;
+ }
+
+ const result = this._getResult(matrix1, matrix2, array1RowCount, array1ColumnCount, array2ColumnCount);
+
+ return ArrayValueObject.createByArray(result);
+ }
+
+ private _getMatrix(array: BaseValueObject, rowCount: number, columnCount: number): number[][] | ErrorValueObject {
+ const matrix: number[][] = [];
+
+ for (let r = 0; r < rowCount; r++) {
+ const row: number[] = [];
+
+ for (let c = 0; c < columnCount; c++) {
+ let valueObject = array.isArray() ? (array as ArrayValueObject).get(r, c) as BaseValueObject : array;
+
+ if (valueObject.isError()) {
+ return valueObject as ErrorValueObject;
+ }
+
+ if (valueObject.isNull() || valueObject.isBoolean()) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ if (valueObject.isString()) {
+ valueObject = valueObject.convertToNumberObjectValue();
+ }
+
+ if (valueObject.isError()) {
+ return valueObject as ErrorValueObject;
+ }
+
+ const value = +valueObject.getValue();
+
+ row.push(value);
+ }
+
+ matrix.push(row);
+ }
+
+ return matrix;
+ }
+
+ private _getResult(
+ matrix1: number[][],
+ matrix2: number[][],
+ array1RowCount: number,
+ array1ColumnCount: number,
+ array2ColumnCount: number
+ ): number[][] {
+ const result = Array.from({ length: array1RowCount }, () => new Array(array2ColumnCount).fill(0));
+
+ for (let r = 0; r < array1RowCount; r++) {
+ for (let c = 0; c < array2ColumnCount; c++) {
+ let value = 0;
+
+ for (let k = 0; k < array1ColumnCount; k++) {
+ value += matrix1[r][k] * matrix2[k][c];
+ }
+
+ result[r][c] = value;
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/packages/engine-formula/src/functions/math/mod/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/mod/__tests__/index.spec.ts
index 4950983d91..f58f4db4a3 100644
--- a/packages/engine-formula/src/functions/math/mod/__tests__/index.spec.ts
+++ b/packages/engine-formula/src/functions/math/mod/__tests__/index.spec.ts
@@ -16,12 +16,12 @@
import { describe, expect, it } from 'vitest';
-import { FUNCTION_NAMES_MATH } from '../../function-names';
-import { Mod } from '../index';
-import { NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
-import { ArrayValueObject, transformToValue, transformToValueObject } from '../../../../engine/value-object/array-value-object';
import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValue, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
import { stripArrayValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_MATH } from '../../function-names';
+import { Mod } from '../index';
describe('Test mod function', () => {
const testFunction = new Mod(FUNCTION_NAMES_MATH.MOD);
diff --git a/packages/engine-formula/src/functions/math/mod/index.ts b/packages/engine-formula/src/functions/math/mod/index.ts
index e7a02ea8b0..57bcebaf62 100644
--- a/packages/engine-formula/src/functions/math/mod/index.ts
+++ b/packages/engine-formula/src/functions/math/mod/index.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
import { BaseFunction } from '../../base-function';
+import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
export class Mod extends BaseFunction {
override minParams = 2;
diff --git a/packages/engine-formula/src/functions/math/multinomial/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/multinomial/__tests__/index.spec.ts
new file mode 100644
index 0000000000..a85941421a
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/multinomial/__tests__/index.spec.ts
@@ -0,0 +1,119 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_MATH } from '../../function-names';
+import { Multinomial } from '../index';
+
+describe('Test multinomial function', () => {
+ const testFunction = new Multinomial(FUNCTION_NAMES_MATH.MULTINOMIAL);
+
+ describe('Multinomial', () => {
+ it('Value is normal number', () => {
+ const number1 = NumberValueObject.create(5);
+ const number2 = NumberValueObject.create(2);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(21);
+ });
+
+ it('Value is big number', () => {
+ const number1 = NumberValueObject.create(1000000);
+ const number2 = NumberValueObject.create(3222);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is number negative', () => {
+ const number1 = NumberValueObject.create(-8);
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+
+ it('Value is number string', () => {
+ const number1 = StringValueObject.create('1.5');
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(9);
+ });
+
+ it('Value is normal string', () => {
+ const number1 = StringValueObject.create('test');
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const number1 = BooleanValueObject.create(true);
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is blank cell', () => {
+ const number1 = NullValueObject.create();
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(1);
+ });
+
+ it('Value is error', () => {
+ const number1 = ErrorValueObject.create(ErrorType.NAME);
+ const number2 = NumberValueObject.create(8);
+ const result = testFunction.calculate(number1, number2);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const number = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, null, ' ', 1.23, true, false],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toStrictEqual(ErrorType.VALUE);
+
+ const number2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [10, 20, 40, 60],
+ [80, 1, 2, 3],
+ ]),
+ rowCount: 2,
+ columnCount: 4,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result2 = testFunction.calculate(number2);
+ expect(getObjectValue(result2)).toStrictEqual(ErrorType.NUM);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/math/multinomial/index.ts b/packages/engine-formula/src/functions/math/multinomial/index.ts
new file mode 100644
index 0000000000..8aa63ea91e
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/multinomial/index.ts
@@ -0,0 +1,132 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { calculateFactorial } from '../../../basics/math';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+
+export class Multinomial extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 255;
+
+ override calculate(...variants: BaseValueObject[]): BaseValueObject {
+ let sum = 0;
+ let den = 1;
+
+ for (let i = 0; i < variants.length; i++) {
+ const variant = variants[i];
+
+ if (variant.isNull()) {
+ continue;
+ }
+
+ if (variant.isArray()) {
+ let isError = false;
+ let errorObject: ErrorValueObject = ErrorValueObject.create(ErrorType.VALUE);
+
+ (variant as ArrayValueObject).iterator((valueObject) => {
+ if (valueObject?.isNull()) {
+ return true;
+ }
+
+ const { isError: _isError, errorObject: _errorObject, number } = this._handleSingleObject(valueObject as BaseValueObject);
+
+ if (_isError) {
+ isError = true;
+ errorObject = _errorObject as ErrorValueObject;
+ return false;
+ }
+
+ sum += number as number;
+
+ if (sum > 170) {
+ isError = true;
+ errorObject = ErrorValueObject.create(ErrorType.NUM);
+ return false;
+ }
+
+ den *= calculateFactorial(number as number);
+ });
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+ } else {
+ const { isError, errorObject, number } = this._handleSingleObject(variant);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ sum += number as number;
+
+ if (sum > 170) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ den *= calculateFactorial(number as number);
+ }
+ }
+
+ const result = calculateFactorial(sum) / den;
+
+ return NumberValueObject.create(result);
+ }
+
+ private _handleSingleObject(number: BaseValueObject) {
+ if (number.isBoolean()) {
+ return {
+ isError: true,
+ errorObject: ErrorValueObject.create(ErrorType.VALUE),
+ number: null,
+ };
+ }
+
+ let _number = number;
+
+ if (number.isString()) {
+ _number = _number.convertToNumberObjectValue();
+ }
+
+ if (_number.isError()) {
+ return {
+ isError: true,
+ errorObject: _number as ErrorValueObject,
+ number: null,
+ };
+ }
+
+ const numberValue = Math.floor(+_number.getValue());
+
+ if (numberValue < 0) {
+ return {
+ isError: true,
+ errorObject: ErrorValueObject.create(ErrorType.NUM),
+ number: null,
+ };
+ }
+
+ return {
+ isError: false,
+ errorObject: null,
+ number: numberValue,
+ };
+ }
+}
diff --git a/packages/engine-formula/src/functions/math/munit/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/munit/__tests__/index.spec.ts
new file mode 100644
index 0000000000..8088cdeb18
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/munit/__tests__/index.spec.ts
@@ -0,0 +1,109 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_MATH } from '../../function-names';
+import { Munit } from '../index';
+
+describe('Test munit function', () => {
+ const testFunction = new Munit(FUNCTION_NAMES_MATH.MUNIT);
+
+ describe('Munit', () => {
+ it('Value is normal number', () => {
+ const dimension = NumberValueObject.create(3);
+ const result = testFunction.calculate(dimension);
+ expect(getObjectValue(result)).toStrictEqual([
+ [1, 0, 0],
+ [0, 1, 0],
+ [0, 0, 1],
+ ]);
+ });
+
+ it('Value is number string', () => {
+ const dimension = StringValueObject.create('1.5');
+ const result = testFunction.calculate(dimension);
+ expect(getObjectValue(result)).toStrictEqual([
+ [1],
+ ]);
+ });
+
+ it('Value is normal string', () => {
+ const dimension = StringValueObject.create('test');
+ const result = testFunction.calculate(dimension);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const dimension = BooleanValueObject.create(true);
+ const result = testFunction.calculate(dimension);
+ expect(getObjectValue(result)).toStrictEqual([
+ [1],
+ ]);
+ });
+ it('Value is blank cell', () => {
+ const dimension = NullValueObject.create();
+ const result = testFunction.calculate(dimension);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+ it('Value is error', () => {
+ const dimension = ErrorValueObject.create(ErrorType.NAME);
+ const result = testFunction.calculate(dimension);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const dimension = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3.4, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(dimension);
+ expect(getObjectValue(result)).toStrictEqual([
+ [1, ErrorType.VALUE, 1, 1, ErrorType.VALUE, ErrorType.VALUE],
+ [ErrorType.VALUE, 1, 1, ErrorType.VALUE, ErrorType.VALUE, ErrorType.NAME],
+ ]);
+
+ const dimension2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result2 = testFunction.calculate(dimension2);
+ expect(getObjectValue(result2)).toStrictEqual([
+ [1],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/math/munit/index.ts b/packages/engine-formula/src/functions/math/munit/index.ts
new file mode 100644
index 0000000000..2e458fb0e3
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/munit/index.ts
@@ -0,0 +1,85 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { BaseFunction } from '../../base-function';
+
+export class Munit extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 1;
+
+ override calculate(dimension: BaseValueObject): BaseValueObject {
+ if (dimension.isArray()) {
+ const rowCount = (dimension as ArrayValueObject).getRowCount();
+ const columnCount = (dimension as ArrayValueObject).getColumnCount();
+
+ const resultArray = (dimension as ArrayValueObject).mapValue((dimensionObject) => {
+ const result = this._handleSingleObject(dimensionObject);
+
+ if (result.isError()) {
+ return result;
+ }
+
+ if (rowCount > 1 || columnCount > 1) {
+ return (result as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return result;
+ });
+
+ if (rowCount === 1 && columnCount === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ return this._handleSingleObject(dimension);
+ }
+
+ private _handleSingleObject(dimension: BaseValueObject): BaseValueObject {
+ let _dimension = dimension;
+
+ if (_dimension.isString()) {
+ _dimension = _dimension.convertToNumberObjectValue();
+ }
+
+ if (_dimension.isError()) {
+ return _dimension;
+ }
+
+ const dimensionValue = Math.floor(+_dimension.getValue());
+
+ if (dimensionValue <= 0) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ const result: Array<Array<0 | 1>> = [];
+
+ for (let r = 0; r < dimensionValue; r++) {
+ result[r] = [];
+
+ for (let c = 0; c < dimensionValue; c++) {
+ result[r][c] = r === c ? 1 : 0;
+ }
+ }
+
+ return ArrayValueObject.createByArray(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/math/quotient/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/quotient/__tests__/index.spec.ts
new file mode 100644
index 0000000000..b964887271
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/quotient/__tests__/index.spec.ts
@@ -0,0 +1,98 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_MATH } from '../../function-names';
+import { Quotient } from '../index';
+
+describe('Test quotient function', () => {
+ const testFunction = new Quotient(FUNCTION_NAMES_MATH.QUOTIENT);
+
+ describe('Quotient', () => {
+ it('Value is normal number', () => {
+ const numerator = NumberValueObject.create(5);
+ const denominator = NumberValueObject.create(2);
+ const result = testFunction.calculate(numerator, denominator);
+ expect(getObjectValue(result)).toBe(2);
+ });
+
+ it('Value is number negative', () => {
+ const numerator = NumberValueObject.create(-10);
+ const denominator = NumberValueObject.create(3);
+ const result = testFunction.calculate(numerator, denominator);
+ expect(getObjectValue(result)).toBe(-3);
+ });
+
+ it('Value is number string', () => {
+ const numerator = StringValueObject.create('1.5');
+ const denominator = NumberValueObject.create(2);
+ const result = testFunction.calculate(numerator, denominator);
+ expect(getObjectValue(result)).toBe(0);
+ });
+
+ it('Value is normal string', () => {
+ const numerator = StringValueObject.create('test');
+ const denominator = NumberValueObject.create(2);
+ const result = testFunction.calculate(numerator, denominator);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const numerator = BooleanValueObject.create(true);
+ const denominator = NumberValueObject.create(2);
+ const result = testFunction.calculate(numerator, denominator);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is blank cell', () => {
+ const numerator = NumberValueObject.create(5);
+ const denominator = NullValueObject.create();
+ const result = testFunction.calculate(numerator, denominator);
+ expect(getObjectValue(result)).toBe(ErrorType.DIV_BY_ZERO);
+ });
+
+ it('Value is error', () => {
+ const numerator = ErrorValueObject.create(ErrorType.NAME);
+ const denominator = NumberValueObject.create(2);
+ const result = testFunction.calculate(numerator, denominator);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const numerator = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const denominator = NumberValueObject.create(2);
+ const result = testFunction.calculate(numerator, denominator);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/math/quotient/index.ts b/packages/engine-formula/src/functions/math/quotient/index.ts
new file mode 100644
index 0000000000..ee356bf0a3
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/quotient/index.ts
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { checkVariantsErrorIsArrayOrBoolean } from '../../../engine/utils/check-variant-error';
+import { ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
+
+export class Quotient extends BaseFunction {
+ override minParams = 2;
+
+ override maxParams = 2;
+
+ override calculate(numerator: BaseValueObject, denominator: BaseValueObject): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(numerator, denominator);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [numeratorObject, denominatorObject] = variants as BaseValueObject[];
+
+ const numeratorValue = +numeratorObject.getValue();
+ const denominatorValue = +denominatorObject.getValue();
+
+ if (Number.isNaN(numeratorValue) || Number.isNaN(denominatorValue)) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ if (denominatorValue === 0) {
+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);
+ }
+
+ const result = Math.trunc(numeratorValue / denominatorValue);
+
+ return NumberValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/math/sequence/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/sequence/__tests__/index.spec.ts
new file mode 100644
index 0000000000..e87322596b
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/sequence/__tests__/index.spec.ts
@@ -0,0 +1,160 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_MATH } from '../../function-names';
+import { Sequence } from '../index';
+
+describe('Test sequence function', () => {
+ const testFunction = new Sequence(FUNCTION_NAMES_MATH.SEQUENCE);
+
+ describe('Sequence', () => {
+ it('Value is normal number', () => {
+ const rows = NumberValueObject.create(4);
+ const columns = NumberValueObject.create(5);
+ const start = NumberValueObject.create(2);
+ const step = NumberValueObject.create(2);
+ const result = testFunction.calculate(rows, columns, start, step);
+ expect(getObjectValue(result)).toStrictEqual([
+ [2, 4, 6, 8, 10],
+ [12, 14, 16, 18, 20],
+ [22, 24, 26, 28, 30],
+ [32, 34, 36, 38, 40],
+ ]);
+ });
+
+ it('Value is number negative', () => {
+ const rows = NumberValueObject.create(-1);
+ const columns = NumberValueObject.create(5);
+ const start = NumberValueObject.create(2);
+ const step = NumberValueObject.create(2);
+ const result = testFunction.calculate(rows, columns, start, step);
+ expect(getObjectValue(result)).toStrictEqual(ErrorType.VALUE);
+ });
+
+ it('Value is number string', () => {
+ const rows = StringValueObject.create('1.5');
+ const columns = NumberValueObject.create(5);
+ const start = NumberValueObject.create(2);
+ const step = NumberValueObject.create(2);
+ const result = testFunction.calculate(rows, columns, start, step);
+ expect(getObjectValue(result)).toStrictEqual([
+ [2, 4, 6, 8, 10],
+ ]);
+ });
+
+ it('Value is normal string', () => {
+ const rows = StringValueObject.create('test');
+ const columns = NumberValueObject.create(5);
+ const start = NumberValueObject.create(2);
+ const step = NumberValueObject.create(2);
+ const result = testFunction.calculate(rows, columns, start, step);
+ expect(getObjectValue(result)).toStrictEqual(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const rows = BooleanValueObject.create(true);
+ const columns = NumberValueObject.create(5);
+ const start = NumberValueObject.create(2);
+ const step = NumberValueObject.create(2);
+ const result = testFunction.calculate(rows, columns, start, step);
+ expect(getObjectValue(result)).toStrictEqual([
+ [2, 4, 6, 8, 10],
+ ]);
+ });
+
+ it('Value is blank cell', () => {
+ const rows = NumberValueObject.create(4);
+ const columns = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [null],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const start = NumberValueObject.create(2);
+ const step = NumberValueObject.create(2);
+ const result = testFunction.calculate(rows, columns, start, step);
+ expect(getObjectValue(result)).toStrictEqual(ErrorType.CALC);
+ });
+
+ it('Value is null', () => {
+ const rows = NullValueObject.create();
+ const columns = NullValueObject.create();
+ const start = NullValueObject.create();
+ const step = NullValueObject.create();
+ const result = testFunction.calculate(rows, columns, start, step);
+ expect(getObjectValue(result)).toStrictEqual([
+ [1],
+ ]);
+ });
+
+ it('Value is error', () => {
+ const rows = ErrorValueObject.create(ErrorType.NAME);
+ const columns = NumberValueObject.create(5);
+ const start = NumberValueObject.create(2);
+ const step = NumberValueObject.create(2);
+ const result = testFunction.calculate(rows, columns, start, step);
+ expect(getObjectValue(result)).toStrictEqual(ErrorType.NAME);
+
+ const rows2 = NumberValueObject.create(4);
+ const columns2 = ErrorValueObject.create(ErrorType.NAME);
+ const result2 = testFunction.calculate(rows2, columns2, start, step);
+ expect(getObjectValue(result2)).toStrictEqual(ErrorType.NAME);
+
+ const start2 = ErrorValueObject.create(ErrorType.NAME);
+ const result3 = testFunction.calculate(rows2, columns, start2, step);
+ expect(getObjectValue(result3)).toStrictEqual(ErrorType.NAME);
+
+ const step2 = ErrorValueObject.create(ErrorType.NAME);
+ const result4 = testFunction.calculate(rows2, columns, start, step2);
+ expect(getObjectValue(result4)).toStrictEqual(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const rows = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const columns = NumberValueObject.create(5);
+ const start = NumberValueObject.create(2);
+ const step = NumberValueObject.create(2);
+ const result = testFunction.calculate(rows, columns, start, step);
+ expect(getObjectValue(result)).toStrictEqual([
+ [2, ErrorType.VALUE, 2, 2, ErrorType.CALC, ErrorType.CALC],
+ [ErrorType.CALC, 2, 2, ErrorType.VALUE, ErrorType.VALUE, ErrorType.NAME],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/math/sequence/index.ts b/packages/engine-formula/src/functions/math/sequence/index.ts
new file mode 100644
index 0000000000..9f352fb4da
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/sequence/index.ts
@@ -0,0 +1,148 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { expandArrayValueObject } from '../../../engine/utils/array-object';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
+
+export class Sequence extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 4;
+
+ override calculate(rows: BaseValueObject, columns?: BaseValueObject, start?: BaseValueObject, step?: BaseValueObject): BaseValueObject {
+ let _rows = rows;
+ let _columns = columns ?? NumberValueObject.create(1);
+ let _start = start ?? NumberValueObject.create(1);
+ let _step = step ?? NumberValueObject.create(1);
+
+ if (_rows.isNull()) {
+ _rows = NumberValueObject.create(1);
+ }
+
+ if (_columns.isNull()) {
+ _columns = NumberValueObject.create(1);
+ }
+
+ if (_start.isNull()) {
+ _start = NumberValueObject.create(1);
+ }
+
+ if (_step.isNull()) {
+ _step = NumberValueObject.create(1);
+ }
+
+ const maxRowLength = Math.max(
+ _rows.isArray() ? (_rows as ArrayValueObject).getRowCount() : 1,
+ _columns.isArray() ? (_columns as ArrayValueObject).getRowCount() : 1,
+ _start.isArray() ? (_start as ArrayValueObject).getRowCount() : 1,
+ _step.isArray() ? (_step as ArrayValueObject).getRowCount() : 1
+ );
+
+ const maxColumnLength = Math.max(
+ _rows.isArray() ? (_rows as ArrayValueObject).getColumnCount() : 1,
+ _columns.isArray() ? (_columns as ArrayValueObject).getColumnCount() : 1,
+ _start.isArray() ? (_start as ArrayValueObject).getColumnCount() : 1,
+ _step.isArray() ? (_step as ArrayValueObject).getColumnCount() : 1
+ );
+
+ const rowsArray = expandArrayValueObject(maxRowLength, maxColumnLength, _rows, ErrorValueObject.create(ErrorType.NA));
+ const columnsArray = expandArrayValueObject(maxRowLength, maxColumnLength, _columns, ErrorValueObject.create(ErrorType.NA));
+ const startArray = expandArrayValueObject(maxRowLength, maxColumnLength, _start, ErrorValueObject.create(ErrorType.NA));
+ const stepArray = expandArrayValueObject(maxRowLength, maxColumnLength, _step, ErrorValueObject.create(ErrorType.NA));
+
+ const resultArray = rowsArray.mapValue((rowsObject, rowIndex, columnIndex) => {
+ const columnsObject = columnsArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const startObject = startArray.get(rowIndex, columnIndex) as BaseValueObject;
+ const stepObject = stepArray.get(rowIndex, columnIndex) as BaseValueObject;
+
+ if (rowsObject.isError()) {
+ return rowsObject;
+ }
+
+ if (columnsObject.isError()) {
+ return columnsObject;
+ }
+
+ if (startObject.isError()) {
+ return startObject;
+ }
+
+ if (stepObject.isError()) {
+ return stepObject;
+ }
+
+ return this._getResult(rowsObject, columnsObject, startObject, stepObject, maxRowLength, maxColumnLength);
+ });
+
+ if (maxRowLength === 1 && maxColumnLength === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ private _getResult(
+ rowsObject: BaseValueObject,
+ columnsObject: BaseValueObject,
+ startObject: BaseValueObject,
+ stepObject: BaseValueObject,
+ maxRowLength: number,
+ maxColumnLength: number
+ ): BaseValueObject {
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rowsObject, columnsObject, startObject, stepObject);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [_rowsObject, _columnsObject, _startObject, _stepObject] = variants as BaseValueObject[];
+
+ const rowsValue = Math.floor(+_rowsObject.getValue());
+ const columnsValue = Math.floor(+_columnsObject.getValue());
+ const startValue = +_startObject.getValue();
+ const stepValue = +_stepObject.getValue();
+
+ if (rowsValue < 0 || columnsValue < 0) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ if (rowsValue === 0 || columnsValue === 0) {
+ return ErrorValueObject.create(ErrorType.CALC);
+ }
+
+ const result: number[][] = [];
+
+ for (let r = 0; r < rowsValue; r++) {
+ result[r] = [];
+
+ for (let c = 0; c < columnsValue; c++) {
+ result[r][c] = startValue + (r * columnsValue + c) * stepValue;
+ }
+ }
+
+ if (maxRowLength > 1 || maxColumnLength > 1) {
+ return NumberValueObject.create(result[0][0]);
+ }
+
+ return ArrayValueObject.createByArray(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/math/seriessum/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/seriessum/__tests__/index.spec.ts
new file mode 100644
index 0000000000..01311952f1
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/seriessum/__tests__/index.spec.ts
@@ -0,0 +1,211 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_MATH } from '../../function-names';
+import { Seriessum } from '../index';
+
+describe('Test seriessum function', () => {
+ const testFunction = new Seriessum(FUNCTION_NAMES_MATH.SERIESSUM);
+
+ describe('Seriessum', () => {
+ it('Value is normal number', () => {
+ const x = NumberValueObject.create(0.785398163);
+ const n = NumberValueObject.create(0);
+ const m = NumberValueObject.create(2);
+ const coefficients = ArrayValueObject.create('{1, -0.5, 0.041666667, -0.001388889}');
+ const result = testFunction.calculate(x, n, m, coefficients);
+ expect(getObjectValue(result)).toBe(0.7071032152046538);
+
+ const coefficients2 = NumberValueObject.create(1);
+ const result2 = testFunction.calculate(x, n, m, coefficients2);
+ expect(getObjectValue(result2)).toBe(1);
+ });
+
+ it('Value is number negative', () => {
+ const x = NumberValueObject.create(0.785398163);
+ const n = NumberValueObject.create(-1);
+ const m = NumberValueObject.create(2);
+ const coefficients = ArrayValueObject.create('{1, -0.5, 0.041666667, -0.001388889}');
+ const result = testFunction.calculate(x, n, m, coefficients);
+ expect(getObjectValue(result)).toBe(0.9003117762635432);
+ });
+
+ it('Value is number string', () => {
+ const x = NumberValueObject.create(0.785398163);
+ const n = StringValueObject.create('1.5');
+ const m = NumberValueObject.create(2);
+ const coefficients = ArrayValueObject.create('{1, -0.5, 0.041666667, -0.001388889}');
+ const result = testFunction.calculate(x, n, m, coefficients);
+ expect(getObjectValue(result)).toBe(0.49217282836063);
+ });
+
+ it('Value is normal string', () => {
+ const x = StringValueObject.create('test');
+ const n = NumberValueObject.create(0);
+ const m = NumberValueObject.create(2);
+ const coefficients = ArrayValueObject.create('{1, -0.5, 0.041666667, -0.001388889}');
+ const result = testFunction.calculate(x, n, m, coefficients);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const x = BooleanValueObject.create(true);
+ const n = NumberValueObject.create(0);
+ const m = NumberValueObject.create(2);
+ const coefficients = ArrayValueObject.create('{1, -0.5, 0.041666667, -0.001388889}');
+ const result = testFunction.calculate(x, n, m, coefficients);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+ });
+
+ it('Value is blank cell', () => {
+ const x = NumberValueObject.create(0.785398163);
+ const n = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [null],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const m = NumberValueObject.create(2);
+ const coefficients = ArrayValueObject.create('{1, -0.5, 0.041666667, -0.001388889}');
+ const result = testFunction.calculate(x, n, m, coefficients);
+ expect(getObjectValue(result)).toBe(0.7071032152046538);
+ });
+
+ it('Value is null', () => {
+ const x = NumberValueObject.create(0.785398163);
+ const n = NullValueObject.create();
+ const m = NumberValueObject.create(2);
+ const coefficients = ArrayValueObject.create('{1, -0.5, 0.041666667, -0.001388889}');
+ const result = testFunction.calculate(x, n, m, coefficients);
+ expect(getObjectValue(result)).toBe(ErrorType.NA);
+ });
+
+ it('Value is error', () => {
+ const x = ErrorValueObject.create(ErrorType.NAME);
+ const n = NumberValueObject.create(0);
+ const m = NumberValueObject.create(2);
+ const coefficients = ArrayValueObject.create('{1, -0.5, 0.041666667, -0.001388889}');
+ const result = testFunction.calculate(x, n, m, coefficients);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+
+ const x2 = NumberValueObject.create(0.785398163);
+ const coefficients2 = ErrorValueObject.create(ErrorType.NAME);
+ const result2 = testFunction.calculate(x2, n, m, coefficients2);
+ expect(getObjectValue(result2)).toBe(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const x = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const n = NumberValueObject.create(0);
+ const m = NumberValueObject.create(2);
+ const coefficients = ArrayValueObject.create('{1, -0.5, 0.041666667, -0.001388889}');
+ const result = testFunction.calculate(x, n, m, coefficients);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+
+ const x2 = NumberValueObject.create(0.785398163);
+ const coefficients2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result2 = testFunction.calculate(x2, n, m, coefficients2);
+ expect(getObjectValue(result2)).toBe(ErrorType.VALUE);
+
+ const coefficients3 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ErrorType.NAME, 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, ' '],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result3 = testFunction.calculate(x2, n, m, coefficients3);
+ expect(getObjectValue(result3)).toBe(ErrorType.NAME);
+
+ const coefficients4 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, true, ' ', 1.23, false, null],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result4 = testFunction.calculate(x2, n, m, coefficients4);
+ expect(getObjectValue(result4)).toBe(ErrorType.VALUE);
+ });
+
+ it('Result is NaN or Infinity', () => {
+ const x = NumberValueObject.create(9000);
+ const n = NumberValueObject.create(-0.5);
+ const m = NumberValueObject.create(90000);
+ const coefficients = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [0.785398163, 0.785398163],
+ [9000, 1],
+ [-0.5, -0.5],
+ [0.041666667, 0.041666667],
+ [-0.001388889, -0.001388889],
+ ]),
+ rowCount: 5,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(x, n, m, coefficients);
+ expect(getObjectValue(result)).toBe(ErrorType.NUM);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/math/seriessum/index.ts b/packages/engine-formula/src/functions/math/seriessum/index.ts
new file mode 100644
index 0000000000..ee4edc9904
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/seriessum/index.ts
@@ -0,0 +1,138 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ErrorType } from '../../../basics/error-type';
+import { checkVariantsErrorIsArrayOrBoolean, checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
+
+export class Seriessum extends BaseFunction {
+ override minParams = 4;
+
+ override maxParams = 4;
+
+ override calculate(x: BaseValueObject, n: BaseValueObject, m: BaseValueObject, coefficients: BaseValueObject): BaseValueObject {
+ if (x.isNull() || n.isNull() || m.isNull() || coefficients.isNull()) {
+ return ErrorValueObject.create(ErrorType.NA);
+ }
+
+ const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(x, n, m);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const { isError: isError2, errorObject: errorObject2, variants: variants2 } = checkVariantsErrorIsStringToNumber(...variants as BaseValueObject[]);
+
+ if (isError2) {
+ return errorObject2 as ErrorValueObject;
+ }
+
+ const [xObject, nObject, mObject] = variants2 as BaseValueObject[];
+
+ const xValue = +xObject.getValue();
+ const nValue = +nObject.getValue();
+ const mValue = +mObject.getValue();
+
+ const coefficientsArray: number[] = [];
+
+ if (coefficients.isArray()) {
+ let isError_coefficients = false;
+ let errorObject_coefficients: ErrorValueObject = ErrorValueObject.create(ErrorType.VALUE);
+
+ (coefficients as ArrayValueObject).iterator((coefficientsObject) => {
+ const { isError: _isError, errorObject: _errorObject, coefficientsObject: _coefficientsObject } = this._handleSingleObject(coefficientsObject as BaseValueObject);
+
+ if (_isError) {
+ isError_coefficients = true;
+ errorObject_coefficients = _errorObject as ErrorValueObject;
+ return false;
+ }
+
+ const coefficientsValue = +(_coefficientsObject as BaseValueObject).getValue();
+
+ coefficientsArray.push(coefficientsValue);
+ });
+
+ if (isError_coefficients) {
+ return errorObject_coefficients;
+ }
+ } else {
+ const { isError: _isError, errorObject: _errorObject, coefficientsObject: _coefficientsObject } = this._handleSingleObject(coefficients);
+
+ if (_isError) {
+ return _errorObject as ErrorValueObject;
+ }
+
+ const coefficientsValue = +(_coefficientsObject as BaseValueObject).getValue();
+
+ coefficientsArray.push(coefficientsValue);
+ }
+
+ let result = 0;
+
+ for (let i = 0; i < coefficientsArray.length; i++) {
+ result += coefficientsArray[i] * (xValue ** (nValue + i * mValue));
+ }
+
+ if (Number.isNaN(result) || !Number.isFinite(result)) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ return NumberValueObject.create(result);
+ }
+
+ private _handleSingleObject(coefficientsObject: BaseValueObject) {
+ if (coefficientsObject.isError()) {
+ return {
+ isError: true,
+ errorObject: coefficientsObject as ErrorValueObject,
+ coefficientsObject: null,
+ };
+ }
+
+ if (coefficientsObject?.isBoolean()) {
+ return {
+ isError: true,
+ errorObject: ErrorValueObject.create(ErrorType.VALUE),
+ coefficientsObject: null,
+ };
+ }
+
+ let _coefficientsObject = coefficientsObject as BaseValueObject;
+
+ if (_coefficientsObject.isString()) {
+ _coefficientsObject = _coefficientsObject.convertToNumberObjectValue();
+ }
+
+ if (_coefficientsObject.isError()) {
+ return {
+ isError: true,
+ errorObject: _coefficientsObject as ErrorValueObject,
+ coefficientsObject: null,
+ };
+ }
+
+ return {
+ isError: false,
+ errorObject: null,
+ coefficientsObject: _coefficientsObject,
+ };
+ }
+}
diff --git a/packages/engine-formula/src/functions/math/sign/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/sign/__tests__/index.spec.ts
new file mode 100644
index 0000000000..5a1b1ac5a6
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/sign/__tests__/index.spec.ts
@@ -0,0 +1,109 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_MATH } from '../../function-names';
+import { Sign } from '../index';
+
+describe('Test sign function', () => {
+ const testFunction = new Sign(FUNCTION_NAMES_MATH.SIGN);
+
+ describe('Sign', () => {
+ it('Value is normal number', () => {
+ const number = NumberValueObject.create(4);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toStrictEqual(1);
+ });
+
+ it('Value is number negative', () => {
+ const number = NumberValueObject.create(-4);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toStrictEqual(-1);
+ });
+
+ it('Value is number string', () => {
+ const number = StringValueObject.create('1.5');
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toStrictEqual(1);
+ });
+
+ it('Value is normal string', () => {
+ const number = StringValueObject.create('test');
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toStrictEqual(ErrorType.VALUE);
+ });
+
+ it('Value is boolean', () => {
+ const number = BooleanValueObject.create(true);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toStrictEqual(1);
+ });
+
+ it('Value is blank cell', () => {
+ const number = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [null],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toStrictEqual(0);
+ });
+
+ it('Value is null', () => {
+ const number = NullValueObject.create();
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toStrictEqual(0);
+ });
+
+ it('Value is error', () => {
+ const number = ErrorValueObject.create(ErrorType.NAME);
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toStrictEqual(ErrorType.NAME);
+ });
+
+ it('Value is array', () => {
+ const number = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, ' ', 1.23, true, false, null],
+ [0, '100', '2.34', 'test', -3, ErrorType.NAME],
+ ]),
+ rowCount: 2,
+ columnCount: 6,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(number);
+ expect(getObjectValue(result)).toStrictEqual([
+ [1, ErrorType.VALUE, 1, 1, 0, 0],
+ [0, 1, 1, ErrorType.VALUE, -1, ErrorType.NAME],
+ ]);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/math/sign/index.ts b/packages/engine-formula/src/functions/math/sign/index.ts
new file mode 100644
index 0000000000..1a2cc9f71b
--- /dev/null
+++ b/packages/engine-formula/src/functions/math/sign/index.ts
@@ -0,0 +1,67 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import type { BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+
+export class Sign extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 1;
+
+ override calculate(number: BaseValueObject): BaseValueObject {
+ if (number.isArray()) {
+ const resultArray = number.mapValue((numberObject) => this._handleSingleObject(numberObject));
+
+ if ((resultArray as ArrayValueObject).getRowCount() === 1 && (resultArray as ArrayValueObject).getColumnCount() === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ return this._handleSingleObject(number);
+ }
+
+ private _handleSingleObject(number: BaseValueObject): BaseValueObject {
+ if (number.isError()) {
+ return number;
+ }
+
+ const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(number);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ const [numberObject] = variants as BaseValueObject[];
+
+ const numberValue = +numberObject.getValue();
+
+ if (numberValue > 0) {
+ return NumberValueObject.create(1);
+ }
+
+ if (numberValue < 0) {
+ return NumberValueObject.create(-1);
+ }
+
+ return NumberValueObject.create(0);
+ }
+}
diff --git a/packages/sheets-formula/src/locale/function-list/math/en-US.ts b/packages/sheets-formula/src/locale/function-list/math/en-US.ts
index 7476aa03e5..04bb071caf 100644
--- a/packages/sheets-formula/src/locale/function-list/math/en-US.ts
+++ b/packages/sheets-formula/src/locale/function-list/math/en-US.ts
@@ -245,8 +245,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: 'number', detail: 'The number of items.' },
+ numberChosen: { name: 'number_chosen', detail: 'The number of items in each combination.' },
},
},
COMBINA: {
@@ -259,8 +259,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: 'number', detail: 'The number of items.' },
+ numberChosen: { name: 'number_chosen', detail: 'The number of items in each combination.' },
},
},
COS: {
@@ -404,8 +404,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: 'number', detail: 'The nonnegative number for which you want the factorial. If number is not an integer, it is truncated.' },
},
},
FACTDOUBLE: {
@@ -418,8 +417,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: 'number', detail: 'The nonnegative number for which you want the double factorial. If number is not an integer, it is truncated.' },
},
},
FLOOR: {
@@ -475,8 +473,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number1: { name: 'number1', detail: 'To find the first number of the greatest common divisor, you can also use a single array or a reference to an array instead of the comma-separated parameters.' },
+ number2: { name: 'number2', detail: 'The second number whose greatest common divisor is to be found. Up to 255 numbers can be specified in this way.' },
},
},
INT: {
@@ -489,8 +487,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: 'number', detail: 'The real number you want to round down to an integer.' },
},
},
ISO_CEILING: {
@@ -517,8 +514,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number1: { name: 'number1', detail: 'To find the first number of the least common multiple, you can also use a single array or a reference to an array instead of the comma-separated parameters.' },
+ number2: { name: 'number2', detail: 'The second number whose least common multiple is to be found. Up to 255 numbers can be specified in this way.' },
},
},
LET: {
@@ -585,8 +582,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array: { name: 'array', detail: 'A numeric array with an equal number of rows and columns.' },
},
},
MINVERSE: {
@@ -599,8 +595,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array: { name: 'array', detail: 'A numeric array with an equal number of rows and columns.' },
},
},
MMULT: {
@@ -613,8 +608,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: 'array1', detail: 'The arrays you want to multiply.' },
+ array2: { name: 'array2', detail: 'The arrays you want to multiply.' },
},
},
MOD: {
@@ -655,8 +650,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number1: { name: 'number1', detail: 'The first value or range to use in the calculation.' },
+ number2: { name: 'number2', detail: 'Additional values ​​or ranges to use in calculations.' },
},
},
MUNIT: {
@@ -669,8 +664,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ dimension: { name: 'dimension', detail: 'Dimension is an integer specifying the dimension of the unit matrix that you want to return. It returns an array. The dimension has to be greater than zero.' },
},
},
ODD: {
@@ -736,8 +730,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ numerator: { name: 'numerator', detail: 'The dividend.' },
+ denominator: { name: 'denominator', detail: 'The divisor.' },
},
},
RADIANS: {
@@ -888,8 +882,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: 'The input value to the power series.' },
+ n: { name: 'n', detail: 'The initial power to which you want to raise x.' },
+ m: { name: 'm', detail: 'The step by which to increase n for each term in the series.' },
+ coefficients: { name: 'coefficients', detail: 'A set of coefficients by which each successive power of x is multiplied.' },
},
},
SEQUENCE: {
@@ -902,8 +898,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ rows: { name: 'rows', detail: 'The number of rows to return.' },
+ columns: { name: 'columns', detail: 'The number of columns to return.' },
+ start: { name: 'start', detail: 'The first number in the sequence.' },
+ step: { name: 'step', detail: 'The amount to increment each subsequent value in the array.' },
},
},
SIGN: {
@@ -916,8 +914,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: 'number', detail: 'Any real number.' },
},
},
SIN: {
diff --git a/packages/sheets-formula/src/locale/function-list/math/ja-JP.ts b/packages/sheets-formula/src/locale/function-list/math/ja-JP.ts
index df580673a6..cece45811a 100644
--- a/packages/sheets-formula/src/locale/function-list/math/ja-JP.ts
+++ b/packages/sheets-formula/src/locale/function-list/math/ja-JP.ts
@@ -245,8 +245,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '総数', detail: '抜き取る対象の全体の数を指定します。' },
+ numberChosen: { name: '抜き取り数', detail: '抜き取る組み合わせ 1 組に含まれる項目の数を指定します。' },
},
},
COMBINA: {
@@ -259,8 +259,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '総数', detail: '抜き取る対象の全体の数を指定します。' },
+ numberChosen: { name: '抜き取り数', detail: '抜き取る組み合わせ 1 組に含まれる項目の数を指定します。' },
},
},
COS: {
@@ -404,8 +404,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '数値', detail: '階乗を求める正の数値を指定します。 数値が整数でない場合は、小数点以下が切り捨てられます。' },
},
},
FACTDOUBLE: {
@@ -418,8 +417,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '数値', detail: '二重階乗を求める正の数値を指定します。 数値が整数でない場合は、小数点以下が切り捨てられます。' },
},
},
FLOOR: {
@@ -475,8 +473,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number1: { name: '数値1', detail: '計算に使用する最初の値または範囲。' },
+ number2: { name: '数値2', detail: '計算に使用する追加の値または範囲。' },
},
},
INT: {
@@ -489,8 +487,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '数値', detail: '切り捨てて整数にする実数を指定します。' },
},
},
ISO_CEILING: {
@@ -517,8 +514,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number1: { name: '数値1', detail: '計算に使用する最初の値または範囲。' },
+ number2: { name: '数値2', detail: '計算に使用する追加の値または範囲。' },
},
},
LET: {
@@ -585,8 +582,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array: { name: '配列', detail: '行数と列数が等しい数値配列 (正方行列) を指定します。' },
},
},
MINVERSE: {
@@ -599,8 +595,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array: { name: '配列', detail: '行数と列数が等しい数値配列 (正方行列) を指定します。' },
},
},
MMULT: {
@@ -613,8 +608,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '配列1', detail: '行列積を求める 2 つの配列を指定します。' },
+ array2: { name: '配列2', detail: '行列積を求める 2 つの配列を指定します。' },
},
},
MOD: {
@@ -655,8 +650,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number1: { name: '数値1', detail: '計算に使用する最初の値または範囲。' },
+ number2: { name: '数値2', detail: '計算に使用する追加の値または範囲。' },
},
},
MUNIT: {
@@ -669,8 +664,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ dimension: { name: 'ディメンション', detail: 'ディメンションは、返す必要がある単位行列の次元を指定する整数です。 配列を返します。 ディメンションを 0 より大きい値にする必要があります。' },
},
},
ODD: {
@@ -736,8 +730,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ numerator: { name: '分子', detail: '被除数 (割られる数) を指定します。' },
+ denominator: { name: '分母', detail: '除数 (割る数) を指定します。' },
},
},
RADIANS: {
@@ -888,8 +882,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: 'べき級数に代入する値を指定します。' },
+ n: { name: 'n', detail: 'x のべき乗の初期値を指定します。' },
+ m: { name: 'm', detail: '級数の各項に対する n の増分を指定します。' },
+ coefficients: { name: '係数', detail: 'x の (n+m) 乗の乗数を指定します。' },
},
},
SEQUENCE: {
@@ -902,8 +898,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ rows: { name: '行の数', detail: '返す行の数。' },
+ columns: { name: '列の数', detail: '返す列の数。' },
+ start: { name: '最初の数値', detail: '数列の最初の数値。' },
+ step: { name: '値の増', detail: '配列内の後続の各値の増分量。' },
},
},
SIGN: {
@@ -916,8 +914,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '数値', detail: '実数を指定します。' },
},
},
SIN: {
diff --git a/packages/sheets-formula/src/locale/function-list/math/vi-VN.ts b/packages/sheets-formula/src/locale/function-list/math/vi-VN.ts
index c7ce1a851d..6f31cb06dd 100644
--- a/packages/sheets-formula/src/locale/function-list/math/vi-VN.ts
+++ b/packages/sheets-formula/src/locale/function-list/math/vi-VN.ts
@@ -204,6 +204,34 @@ export default {
significance: { name: 'bội số', detail: 'Bội số mà bạn muốn làm tròn đến.' },
},
},
+ COMBIN: {
+ description: 'Trả về số tổ hợp cho số mục nhất định. Hãy dùng COMBIN để xác định tổng số nhóm có thể có cho số hạng mục nhất định.',
+ abstract: 'Trả về số tổ hợp cho số mục nhất định. Hãy dùng COMBIN để xác định tổng số nhóm có thể có cho số hạng mục nhất định.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/combin-%E5%87%BD%E6%95%B0-12a3f276-0a21-423a-8de6-06990aaf638a',
+ },
+ ],
+ functionParameter: {
+ number: { name: 'tổng cộng', detail: 'Số hạng mục.' },
+ numberChosen: { name: 'số lượng mẫu', detail: 'Số hạng mục trong mỗi tổ hợp.' },
+ },
+ },
+ COMBINA: {
+ description: 'Trả về số lần kết hợp (có kèm những lần lặp lại) đối với số lượng mục cho trước.',
+ abstract: 'Trả về số lần kết hợp (có kèm những lần lặp lại) đối với số lượng mục cho trước.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/combina-%E5%87%BD%E6%95%B0-efb49eaa-4f4c-4cd2-8179-0ddfcf9d035d',
+ },
+ ],
+ functionParameter: {
+ number: { name: 'tổng cộng', detail: 'Số hạng mục.' },
+ numberChosen: { name: 'số lượng mẫu', detail: 'Số hạng mục trong mỗi tổ hợp.' },
+ },
+ },
COS: {
description: 'Trả về cosin của góc đã cho.',
abstract: 'Trả về cosin của góc đã cho.',
@@ -335,6 +363,32 @@ export default {
number: { name: 'số', detail: 'Số mũ áp dụng cho cơ số e.' },
},
},
+ FACT: {
+ description: 'Trả về giai thừa của một số.',
+ abstract: 'Trả về giai thừa của một số.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/fact-%E5%87%BD%E6%95%B0-ca8588c2-15f2-41c0-8e8c-c11bd471a4f3',
+ },
+ ],
+ functionParameter: {
+ number: { name: 'số', detail: 'Số không âm mà bạn muốn tìm giai thừa của nó. Nếu number không phải là số nguyên thì nó bị cắt cụt.' },
+ },
+ },
+ FACTDOUBLE: {
+ description: 'Trả về giai thừa kép của một số.',
+ abstract: 'Trả về giai thừa kép của một số.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/factdouble-%E5%87%BD%E6%95%B0-e67697ac-d214-48eb-b7b7-cce2589ecac8',
+ },
+ ],
+ functionParameter: {
+ number: { name: 'số', detail: 'Giá trị để trả về giai thừa kép của nó. Nếu number không phải là số nguyên thì nó bị cắt cụt.' },
+ },
+ },
FLOOR: {
description: 'Làm tròn số theo giá trị tuyệt đối giảm dần',
abstract: 'Làm tròn số theo giá trị tuyệt đối giảm dần',
@@ -378,6 +432,47 @@ export default {
significance: { name: 'bội số', detail: 'Bội số mà bạn muốn làm tròn đến.' },
},
},
+ GCD: {
+ description: 'Trả về ước số chung lớn nhất của hai hoặc nhiều số nguyên.',
+ abstract: 'Trả về ước số chung lớn nhất của hai hoặc nhiều số nguyên.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/gcd-%E5%87%BD%E6%95%B0-d5107a51-69e3-461f-8e4c-ddfc21b5073a',
+ },
+ ],
+ functionParameter: {
+ number1: { name: 'số1', detail: 'Giá trị hoặc dải ô đầu tiên được sử dụng để tính toán.' },
+ number2: { name: 'số2', detail: 'Các giá trị hoặc phạm vi bổ sung để sử dụng cho việc tính toán.' },
+ },
+ },
+ INT: {
+ description: 'Làm tròn số xuống tới số nguyên gần nhất.',
+ abstract: 'Làm tròn số xuống tới số nguyên gần nhất.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/int-%E5%87%BD%E6%95%B0-a6c4af9e-356d-4369-ab6a-cb1fd9d343ef',
+ },
+ ],
+ functionParameter: {
+ number: { name: 'số', detail: 'Số thực mà bạn muốn làm tròn xuống một số nguyên.' },
+ },
+ },
+ LCM: {
+ description: 'Trả về bội số chung ít nhất của các số nguyên.',
+ abstract: 'Trả về bội số chung ít nhất của các số nguyên.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/lcm-%E5%87%BD%E6%95%B0-7152b67a-8bb5-4075-ae5c-06ede5563c94',
+ },
+ ],
+ functionParameter: {
+ number1: { name: 'số1', detail: 'Giá trị hoặc dải ô đầu tiên được sử dụng để tính toán.' },
+ number2: { name: 'số2', detail: 'Các giá trị hoặc phạm vi bổ sung để sử dụng cho việc tính toán.' },
+ },
+ },
LN: {
description: 'Trả về lô-ga-rit tự nhiên của một số.',
abstract: 'Trả về lô-ga-rit tự nhiên của một số.',
@@ -418,6 +513,46 @@ export default {
number: { name: 'số', detail: 'Số thực dương mà bạn muốn tính lô-ga-rít cơ số 10 của nó.' },
},
},
+ MDETERM: {
+ description: 'Trả về định thức ma trận của một mảng.',
+ abstract: 'Trả về định thức ma trận của một mảng.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/mdeterm-%E5%87%BD%E6%95%B0-e7bfa857-3834-422b-b871-0ffd03717020',
+ },
+ ],
+ functionParameter: {
+ array: { name: 'mảng', detail: 'Một mảng số với số hàng và số cột bằng nhau.' },
+ },
+ },
+ MINVERSE: {
+ description: 'Trả về ma trận nghịch đảo của một mảng',
+ abstract: 'Trả về ma trận nghịch đảo của một mảng',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/minverse-%E5%87%BD%E6%95%B0-11f55086-adde-4c9f-8eb9-59da2d72efc6',
+ },
+ ],
+ functionParameter: {
+ array: { name: 'mảng', detail: 'Một mảng số với số hàng và số cột bằng nhau.' },
+ },
+ },
+ MMULT: {
+ description: 'Trả về tích ma trận của hai mảng',
+ abstract: 'Trả về tích ma trận của hai mảng',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/mmult-%E5%87%BD%E6%95%B0-40593ed7-a3cd-4b6b-b9a3-e4ad3c7245eb',
+ },
+ ],
+ functionParameter: {
+ array1: { name: 'mảng1', detail: 'Những mảng mà bạn muốn nhân.' },
+ array2: { name: 'mảng2', detail: 'Những mảng mà bạn muốn nhân.' },
+ },
+ },
MOD: {
description: 'Trả về số dư sau khi chia một số cho ước số. Kết quả có cùng dấu với ước số.',
abstract: 'Trả về số dư sau khi chia một số cho ước số.',
@@ -446,6 +581,33 @@ export default {
multiple: { name: 'bội số', detail: 'Số mà bạn muốn làm tròn số tới bội số của nó.' },
},
},
+ MULTINOMIAL: {
+ description: 'Trả về đa thức của một tập hợp số',
+ abstract: 'Trả về đa thức của một tập hợp số',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/multinomial-%E5%87%BD%E6%95%B0-6fa6373c-6533-41a2-a45e-a56db1db1bf6',
+ },
+ ],
+ functionParameter: {
+ number1: { name: 'số1', detail: 'Giá trị hoặc dải ô đầu tiên được sử dụng để tính toán.' },
+ number2: { name: 'số2', detail: 'Các giá trị hoặc phạm vi bổ sung để sử dụng cho việc tính toán.' },
+ },
+ },
+ MUNIT: {
+ description: 'Trả về ma trận đơn vị cho chiều đã xác định.',
+ abstract: 'Trả về ma trận đơn vị cho chiều đã xác định.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/munit-%E5%87%BD%E6%95%B0-c9fe916a-dc26-4105-997d-ba22799853a3',
+ },
+ ],
+ functionParameter: {
+ dimension: { name: 'kích thước', detail: 'Chiều là một số nguyên định rõ chiều của ma trận đơn vị mà bạn muốn trả về. Hàm trả về một mảng. Chiều phải lớn hơn 0.' },
+ },
+ },
ODD: {
description: 'Trả về số được làm tròn lên tới số nguyên lẻ gần nhất.',
abstract: 'Trả về số được làm tròn lên tới số nguyên lẻ gần nhất.',
@@ -499,6 +661,20 @@ export default {
number2: { name: 'số 2', detail: 'Các số hoặc phạm vi bổ sung mà bạn muốn nhân, tối đa 255 đối số.' },
},
},
+ QUOTIENT: {
+ description: 'Trả về phần nguyên của một phép chia.',
+ abstract: 'Trả về phần nguyên của một phép chia.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/quotient-%E5%87%BD%E6%95%B0-9f7bf099-2a18-4282-8fa4-65290cc99dee',
+ },
+ ],
+ functionParameter: {
+ numerator: { name: 'tử số', detail: 'Số bị chia.' },
+ denominator: { name: 'mẫu số', detail: 'Số chia.' },
+ },
+ },
RADIANS: {
description: 'Chuyển đổi độ thành radian.',
abstract: 'Chuyển đổi độ thành radian.',
@@ -623,6 +799,51 @@ export default {
number: { name: 'số', detail: 'Đối số number là góc tính bằng radian mà bạn muốn tìm sec hyperbolic cho nó.' },
},
},
+ SERIESSUM: {
+ description: 'Trả về tổng của một chuỗi lũy thừa dựa trên công thức.',
+ abstract: 'Trả về tổng của một chuỗi lũy thừa dựa trên công thức.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/seriessum-%E5%87%BD%E6%95%B0-a3ab25b5-1093-4f5b-b084-96c49087f637',
+ },
+ ],
+ functionParameter: {
+ x: { name: 'x', detail: 'Giá trị đầu vào cho chuỗi lũy thừa.' },
+ n: { name: 'n', detail: 'Lũy thừa ban đầu bạn muốn tăng x lên.' },
+ m: { name: 'm', detail: 'Số bước lũy thừa sẽ tăng cho mỗi toán hạng trong chuỗi.' },
+ coefficients: { name: 'hệ số', detail: 'Bộ hệ số mà mỗi lũy thừa liên tiếp của x được nhân với nó.' },
+ },
+ },
+ SEQUENCE: {
+ description: 'Hàm SEQUENCE cho phép bạn tạo một danh sách các số liên tiếp trong một mảng, chẳng hạn như 1, 2, 3, 4.',
+ abstract: 'Hàm SEQUENCE cho phép bạn tạo một danh sách các số liên tiếp trong một mảng, chẳng hạn như 1, 2, 3, 4.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/sequence-%E5%87%BD%E6%95%B0-57467a98-57e0-4817-9f14-2eb78519ca90',
+ },
+ ],
+ functionParameter: {
+ rows: { name: 'hàng', detail: 'Số hàng cần trả về.' },
+ columns: { name: 'cột', detail: 'Số cột cần trả về.' },
+ start: { name: 'bắt đầu', detail: 'Số đầu tiên trong trình tự.' },
+ step: { name: 'khoảng cách', detail: 'Số lượng cần tăng cho mỗi giá trị tiếp theo trong mảng.' },
+ },
+ },
+ SIGN: {
+ description: 'Xác định dấu của một số.',
+ abstract: 'Xác định dấu của một số.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/sign-%E5%87%BD%E6%95%B0-109c932d-fcdc-4023-91f1-2dd0e916a1d8',
+ },
+ ],
+ functionParameter: {
+ number: { name: 'số', detail: 'Bất kỳ số thực nào.' },
+ },
+ },
SIN: {
description: 'Trả về sin của một góc đã cho.',
abstract: 'Trả về sin của một góc đã cho.',
diff --git a/packages/sheets-formula/src/locale/function-list/math/zh-CN.ts b/packages/sheets-formula/src/locale/function-list/math/zh-CN.ts
index bd41a8f58f..3ca9da61f3 100644
--- a/packages/sheets-formula/src/locale/function-list/math/zh-CN.ts
+++ b/packages/sheets-formula/src/locale/function-list/math/zh-CN.ts
@@ -244,8 +244,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '总数', detail: '项目的数量。' },
+ numberChosen: { name: '样品数量', detail: '每一组合中项目的数量。' },
},
},
COMBINA: {
@@ -258,8 +258,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '总数', detail: '项目的数量。' },
+ numberChosen: { name: '样品数量', detail: '每一组合中项目的数量。' },
},
},
COS: {
@@ -403,8 +403,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '数值', detail: '要计算其阶乘的非负数。 如果 number 不是整数,将被截尾取整。' },
},
},
FACTDOUBLE: {
@@ -417,8 +416,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '数值', detail: '要计算其双倍阶乘的非负数。 如果 number 不是整数,将被截尾取整。' },
},
},
FLOOR: {
@@ -474,8 +472,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number1: { name: '数值1', detail: '用于计算的第一项数值或范围。' },
+ number2: { name: '数值2', detail: '用于计算的其他数值或范围。' },
},
},
INT: {
@@ -488,8 +486,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '数值', detail: '需要进行向下舍入取整的实数。' },
},
},
ISO_CEILING: {
@@ -516,8 +513,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number1: { name: '数值1', detail: '用于计算的第一项数值或范围。' },
+ number2: { name: '数值2', detail: '用于计算的其他数值或范围。' },
},
},
LET: {
@@ -584,8 +581,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array: { name: '数组', detail: '行数和列数相等的数值数组。' },
},
},
MINVERSE: {
@@ -598,8 +594,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array: { name: '数组', detail: '行数和列数相等的数值数组。' },
},
},
MMULT: {
@@ -612,8 +607,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '数组1', detail: '要进行矩阵乘法运算的两个数组。' },
+ array2: { name: '数组2', detail: '要进行矩阵乘法运算的两个数组。' },
},
},
MOD: {
@@ -654,8 +649,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number1: { name: '数值1', detail: '用于计算的第一项数值或范围。' },
+ number2: { name: '数值2', detail: '用于计算的其他数值或范围。' },
},
},
MUNIT: {
@@ -668,8 +663,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ dimension: { name: '维度', detail: '是一个整数,用于指定要返回的单位矩阵的维度。 它返回一个数组。 维度必须大于零。' },
},
},
ODD: {
@@ -735,8 +729,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ numerator: { name: '分子', detail: '被除数。' },
+ denominator: { name: '分母', detail: '除数。' },
},
},
RADIANS: {
@@ -887,8 +881,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: '幂级数的输入值。' },
+ n: { name: 'n', detail: 'x 的首项乘幂。' },
+ m: { name: 'm', detail: '级数中每一项的乘幂 n 的步长增加值。' },
+ coefficients: { name: '系数', detail: '与 x 的每个连续乘幂相乘的一组系数。' },
},
},
SEQUENCE: {
@@ -901,8 +897,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ rows: { name: '行数', detail: '要返回的行数。' },
+ columns: { name: '列数', detail: '要返回的列数。' },
+ start: { name: '起始数字', detail: '序列中第一个数字。' },
+ step: { name: '递增值', detail: '数组中每个连续值递增的值。' },
},
},
SIGN: {
@@ -915,8 +913,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '数值', detail: '任意实数。' },
},
},
SIN: {
diff --git a/packages/sheets-formula/src/locale/function-list/math/zh-TW.ts b/packages/sheets-formula/src/locale/function-list/math/zh-TW.ts
index 0c73519629..9549225aae 100644
--- a/packages/sheets-formula/src/locale/function-list/math/zh-TW.ts
+++ b/packages/sheets-formula/src/locale/function-list/math/zh-TW.ts
@@ -244,8 +244,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '總數', detail: '這是項目數。' },
+ numberChosen: { name: '樣品數量', detail: '這是每個組合中的項目數。' },
},
},
COMBINA: {
@@ -258,8 +258,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '總數', detail: '這是項目數。' },
+ numberChosen: { name: '樣品數量', detail: '這是每個組合中的項目數。' },
},
},
COS: {
@@ -403,8 +403,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '數值', detail: '這是您要階乘的非負數數字。 如果數字不是整數,則只會取整數。' },
},
},
FACTDOUBLE: {
@@ -417,8 +416,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '數值', detail: '這是您要雙倍階乘的非負數數字。 如果數字不是整數,則只會取整數。' },
},
},
FLOOR: {
@@ -474,8 +472,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number1: { name: '數值1', detail: '用於計算的第一項數值或範圍。' },
+ number2: { name: '數值2', detail: '用於計算的其他數值或範圍。' },
},
},
INT: {
@@ -488,8 +486,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '數值', detail: '這是要將數字向下捨去到最接近的整數的實數。' },
},
},
ISO_CEILING: {
@@ -516,8 +513,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number1: { name: '數值1', detail: '用於計算的第一項數值或範圍。' },
+ number2: { name: '數值2', detail: '用於計算的其他數值或範圍。' },
},
},
LET: {
@@ -584,8 +581,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array: { name: '陣列', detail: '這是具有相同列數與欄數的數值陣列。' },
},
},
MINVERSE: {
@@ -598,8 +594,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array: { name: '陣列', detail: '這是具有相同列數與欄數的數值陣列。' },
},
},
MMULT: {
@@ -612,8 +607,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ array1: { name: '陣列1', detail: '這是您要相乘的陣列。' },
+ array2: { name: '陣列2', detail: '這是您要相乘的陣列。' },
},
},
MOD: {
@@ -654,8 +649,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number1: { name: '數值1', detail: '用於計算的第一項數值或範圍。' },
+ number2: { name: '數值2', detail: '用於計算的其他數值或範圍。' },
},
},
MUNIT: {
@@ -668,8 +663,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ dimension: { name: '维度', detail: '是指定要傳回之單位矩陣維度的整數。 它會傳回陣列。 維度必須大於零。' },
},
},
ODD: {
@@ -735,8 +729,8 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ numerator: { name: '分子', detail: '這是被除數。' },
+ denominator: { name: '分母', detail: '這是除數。' },
},
},
RADIANS: {
@@ -886,8 +880,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ x: { name: 'x', detail: '這是冪級數的輸入值。' },
+ n: { name: 'n', detail: '這是要增加 x 的初始乘冪。' },
+ m: { name: 'm', detail: '這是要將級數中的每一項增加 n 所用的間距。' },
+ coefficients: { name: '係數集', detail: '這是一組由 x 的每一個連續乘冪相乘的係數集。' },
},
},
SEQUENCE: {
@@ -900,8 +896,10 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ rows: { name: '列數', detail: '要傳回的列數。' },
+ columns: { name: '欄數', detail: '要傳回的欄數。' },
+ start: { name: '起始數字', detail: '連續值的第一個數字。' },
+ step: { name: '遞增量', detail: '陣列中每個連續值遞增的量。' },
},
},
SIGN: {
@@ -914,8 +912,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ number: { name: '數值', detail: '這是任意實數。' },
},
},
SIN: {
diff --git a/packages/sheets-formula/src/services/function-list/math.ts b/packages/sheets-formula/src/services/function-list/math.ts
index 6c5410783f..1c4aec040e 100644
--- a/packages/sheets-formula/src/services/function-list/math.ts
+++ b/packages/sheets-formula/src/services/function-list/math.ts
@@ -328,16 +328,16 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [
abstract: 'formula.functionList.COMBIN.abstract',
functionParameter: [
{
- name: 'formula.functionList.COMBIN.functionParameter.number1.name',
- detail: 'formula.functionList.COMBIN.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.COMBIN.functionParameter.number.name',
+ detail: 'formula.functionList.COMBIN.functionParameter.number.detail',
+ example: '8',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.COMBIN.functionParameter.number2.name',
- detail: 'formula.functionList.COMBIN.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.COMBIN.functionParameter.numberChosen.name',
+ detail: 'formula.functionList.COMBIN.functionParameter.numberChosen.detail',
+ example: '2',
require: 1,
repeat: 0,
},
@@ -350,16 +350,16 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [
abstract: 'formula.functionList.COMBINA.abstract',
functionParameter: [
{
- name: 'formula.functionList.COMBINA.functionParameter.number1.name',
- detail: 'formula.functionList.COMBINA.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.COMBINA.functionParameter.number.name',
+ detail: 'formula.functionList.COMBINA.functionParameter.number.detail',
+ example: '8',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.COMBINA.functionParameter.number2.name',
- detail: 'formula.functionList.COMBINA.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.COMBINA.functionParameter.numberChosen.name',
+ detail: 'formula.functionList.COMBINA.functionParameter.numberChosen.detail',
+ example: '2',
require: 1,
repeat: 0,
},
@@ -529,16 +529,9 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [
abstract: 'formula.functionList.FACT.abstract',
functionParameter: [
{
- name: 'formula.functionList.FACT.functionParameter.number1.name',
- detail: 'formula.functionList.FACT.functionParameter.number1.detail',
- example: 'A1:A20',
- require: 1,
- repeat: 0,
- },
- {
- name: 'formula.functionList.FACT.functionParameter.number2.name',
- detail: 'formula.functionList.FACT.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.FACT.functionParameter.number.name',
+ detail: 'formula.functionList.FACT.functionParameter.number.detail',
+ example: '5',
require: 1,
repeat: 0,
},
@@ -551,16 +544,9 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [
abstract: 'formula.functionList.FACTDOUBLE.abstract',
functionParameter: [
{
- name: 'formula.functionList.FACTDOUBLE.functionParameter.number1.name',
- detail: 'formula.functionList.FACTDOUBLE.functionParameter.number1.detail',
- example: 'A1:A20',
- require: 1,
- repeat: 0,
- },
- {
- name: 'formula.functionList.FACTDOUBLE.functionParameter.number2.name',
- detail: 'formula.functionList.FACTDOUBLE.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.FACTDOUBLE.functionParameter.number.name',
+ detail: 'formula.functionList.FACTDOUBLE.functionParameter.number.detail',
+ example: '6',
require: 1,
repeat: 0,
},
@@ -648,16 +634,16 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [
{
name: 'formula.functionList.GCD.functionParameter.number1.name',
detail: 'formula.functionList.GCD.functionParameter.number1.detail',
- example: 'A1:A20',
+ example: '5',
require: 1,
repeat: 0,
},
{
name: 'formula.functionList.GCD.functionParameter.number2.name',
detail: 'formula.functionList.GCD.functionParameter.number2.detail',
- example: 'A1:A20',
- require: 1,
- repeat: 0,
+ example: '2',
+ require: 0,
+ repeat: 1,
},
],
},
@@ -668,16 +654,9 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [
abstract: 'formula.functionList.INT.abstract',
functionParameter: [
{
- name: 'formula.functionList.INT.functionParameter.number1.name',
- detail: 'formula.functionList.INT.functionParameter.number1.detail',
- example: 'A1:A20',
- require: 1,
- repeat: 0,
- },
- {
- name: 'formula.functionList.INT.functionParameter.number2.name',
- detail: 'formula.functionList.INT.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.INT.functionParameter.number.name',
+ detail: 'formula.functionList.INT.functionParameter.number.detail',
+ example: '8.9',
require: 1,
repeat: 0,
},
@@ -714,16 +693,16 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [
{
name: 'formula.functionList.LCM.functionParameter.number1.name',
detail: 'formula.functionList.LCM.functionParameter.number1.detail',
- example: 'A1:A20',
+ example: '5',
require: 1,
repeat: 0,
},
{
name: 'formula.functionList.LCM.functionParameter.number2.name',
detail: 'formula.functionList.LCM.functionParameter.number2.detail',
- example: 'A1:A20',
- require: 1,
- repeat: 0,
+ example: '2',
+ require: 0,
+ repeat: 1,
},
],
},
@@ -808,16 +787,9 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [
abstract: 'formula.functionList.MDETERM.abstract',
functionParameter: [
{
- name: 'formula.functionList.MDETERM.functionParameter.number1.name',
- detail: 'formula.functionList.MDETERM.functionParameter.number1.detail',
- example: 'A1:A20',
- require: 1,
- repeat: 0,
- },
- {
- name: 'formula.functionList.MDETERM.functionParameter.number2.name',
- detail: 'formula.functionList.MDETERM.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.MDETERM.functionParameter.array.name',
+ detail: 'formula.functionList.MDETERM.functionParameter.array.detail',
+ example: '{3,6,1;1,1,0;3,10,2}',
require: 1,
repeat: 0,
},
@@ -830,16 +802,9 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [
abstract: 'formula.functionList.MINVERSE.abstract',
functionParameter: [
{
- name: 'formula.functionList.MINVERSE.functionParameter.number1.name',
- detail: 'formula.functionList.MINVERSE.functionParameter.number1.detail',
- example: 'A1:A20',
- require: 1,
- repeat: 0,
- },
- {
- name: 'formula.functionList.MINVERSE.functionParameter.number2.name',
- detail: 'formula.functionList.MINVERSE.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.MINVERSE.functionParameter.array.name',
+ detail: 'formula.functionList.MINVERSE.functionParameter.array.detail',
+ example: '{3,6,1;1,1,0;3,10,2}',
require: 1,
repeat: 0,
},
@@ -852,16 +817,16 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [
abstract: 'formula.functionList.MMULT.abstract',
functionParameter: [
{
- name: 'formula.functionList.MMULT.functionParameter.number1.name',
- detail: 'formula.functionList.MMULT.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.MMULT.functionParameter.array1.name',
+ detail: 'formula.functionList.MMULT.functionParameter.array1.detail',
+ example: 'A2:B3',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.MMULT.functionParameter.number2.name',
- detail: 'formula.functionList.MMULT.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.MMULT.functionParameter.array2.name',
+ detail: 'formula.functionList.MMULT.functionParameter.array2.detail',
+ example: 'A5:B6',
require: 1,
repeat: 0,
},
@@ -920,16 +885,16 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [
{
name: 'formula.functionList.MULTINOMIAL.functionParameter.number1.name',
detail: 'formula.functionList.MULTINOMIAL.functionParameter.number1.detail',
- example: 'A1:A20',
+ example: '5',
require: 1,
repeat: 0,
},
{
name: 'formula.functionList.MULTINOMIAL.functionParameter.number2.name',
detail: 'formula.functionList.MULTINOMIAL.functionParameter.number2.detail',
- example: 'A1:A20',
- require: 1,
- repeat: 0,
+ example: '2',
+ require: 0,
+ repeat: 1,
},
],
},
@@ -940,16 +905,9 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [
abstract: 'formula.functionList.MUNIT.abstract',
functionParameter: [
{
- name: 'formula.functionList.MUNIT.functionParameter.number1.name',
- detail: 'formula.functionList.MUNIT.functionParameter.number1.detail',
- example: 'A1:A20',
- require: 1,
- repeat: 0,
- },
- {
- name: 'formula.functionList.MUNIT.functionParameter.number2.name',
- detail: 'formula.functionList.MUNIT.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.MUNIT.functionParameter.dimension.name',
+ detail: 'formula.functionList.MUNIT.functionParameter.dimension.detail',
+ example: '3',
require: 1,
repeat: 0,
},
@@ -1029,16 +987,16 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [
abstract: 'formula.functionList.QUOTIENT.abstract',
functionParameter: [
{
- name: 'formula.functionList.QUOTIENT.functionParameter.number1.name',
- detail: 'formula.functionList.QUOTIENT.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.QUOTIENT.functionParameter.numerator.name',
+ detail: 'formula.functionList.QUOTIENT.functionParameter.numerator.detail',
+ example: '5',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.QUOTIENT.functionParameter.number2.name',
- detail: 'formula.functionList.QUOTIENT.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.QUOTIENT.functionParameter.denominator.name',
+ detail: 'formula.functionList.QUOTIENT.functionParameter.denominator.detail',
+ example: '2',
require: 1,
repeat: 0,
},
@@ -1257,16 +1215,30 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [
abstract: 'formula.functionList.SERIESSUM.abstract',
functionParameter: [
{
- name: 'formula.functionList.SERIESSUM.functionParameter.number1.name',
- detail: 'formula.functionList.SERIESSUM.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.SERIESSUM.functionParameter.x.name',
+ detail: 'formula.functionList.SERIESSUM.functionParameter.x.detail',
+ example: '0.785398163',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.SERIESSUM.functionParameter.number2.name',
- detail: 'formula.functionList.SERIESSUM.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.SERIESSUM.functionParameter.n.name',
+ detail: 'formula.functionList.SERIESSUM.functionParameter.n.detail',
+ example: '0',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.SERIESSUM.functionParameter.m.name',
+ detail: 'formula.functionList.SERIESSUM.functionParameter.m.detail',
+ example: '2',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.SERIESSUM.functionParameter.coefficients.name',
+ detail: 'formula.functionList.SERIESSUM.functionParameter.coefficients.detail',
+ example: '{1,-0.5,0.041666667,-0.001388889}',
require: 1,
repeat: 0,
},
@@ -1279,17 +1251,31 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [
abstract: 'formula.functionList.SEQUENCE.abstract',
functionParameter: [
{
- name: 'formula.functionList.SEQUENCE.functionParameter.number1.name',
- detail: 'formula.functionList.SEQUENCE.functionParameter.number1.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.SEQUENCE.functionParameter.rows.name',
+ detail: 'formula.functionList.SEQUENCE.functionParameter.rows.detail',
+ example: '4',
require: 1,
repeat: 0,
},
{
- name: 'formula.functionList.SEQUENCE.functionParameter.number2.name',
- detail: 'formula.functionList.SEQUENCE.functionParameter.number2.detail',
- example: 'A1:A20',
- require: 1,
+ name: 'formula.functionList.SEQUENCE.functionParameter.columns.name',
+ detail: 'formula.functionList.SEQUENCE.functionParameter.columns.detail',
+ example: '5',
+ require: 0,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.SEQUENCE.functionParameter.start.name',
+ detail: 'formula.functionList.SEQUENCE.functionParameter.start.detail',
+ example: '1',
+ require: 0,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.SEQUENCE.functionParameter.step.name',
+ detail: 'formula.functionList.SEQUENCE.functionParameter.step.detail',
+ example: '1',
+ require: 0,
repeat: 0,
},
],
@@ -1301,16 +1287,9 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [
abstract: 'formula.functionList.SIGN.abstract',
functionParameter: [
{
- name: 'formula.functionList.SIGN.functionParameter.number1.name',
- detail: 'formula.functionList.SIGN.functionParameter.number1.detail',
- example: 'A1:A20',
- require: 1,
- repeat: 0,
- },
- {
- name: 'formula.functionList.SIGN.functionParameter.number2.name',
- detail: 'formula.functionList.SIGN.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.SIGN.functionParameter.number.name',
+ detail: 'formula.functionList.SIGN.functionParameter.number.detail',
+ example: '10',
require: 1,
repeat: 0,
},