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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat(formula): add more functions (#2701)
wpxp1234568598e028c0ff
diff --git a/packages/engine-formula/src/engine/value-object/array-value-object.ts b/packages/engine-formula/src/engine/value-object/array-value-object.tsindex 893f5b0c0b..d03718f852 100644--- a/packages/engine-formula/src/engine/value-object/array-value-object.ts+++ b/packages/engine-formula/src/engine/value-object/array-value-object.ts@@ -1070,6 +1070,15 @@ export class ArrayValueObject extends BaseValueObject {});}+ override sinh(): BaseValueObject {+ return this.map((currentValue) => {+ if (currentValue.isError()) {+ return currentValue;+ }+ return currentValue.sinh();+ });+ }+override asin(): BaseValueObject {return this.map((currentValue) => {if (currentValue.isError()) {diff --git a/packages/engine-formula/src/engine/value-object/base-value-object.ts b/packages/engine-formula/src/engine/value-object/base-value-object.tsindex 37cb4c9863..ef1e58827e 100644--- a/packages/engine-formula/src/engine/value-object/base-value-object.ts+++ b/packages/engine-formula/src/engine/value-object/base-value-object.ts@@ -312,6 +312,11 @@ export class BaseValueObject extends ObjectClassType {return ErrorValueObject.create(ErrorType.VALUE);}+ sinh(): BaseValueObject {+ /** abstract */+ return ErrorValueObject.create(ErrorType.VALUE);+ }+asin(): BaseValueObject {/** abstract */return ErrorValueObject.create(ErrorType.VALUE);diff --git a/packages/engine-formula/src/engine/value-object/primitive-object.ts b/packages/engine-formula/src/engine/value-object/primitive-object.tsindex 1cf19429c3..ed914c80f2 100644--- a/packages/engine-formula/src/engine/value-object/primitive-object.ts+++ b/packages/engine-formula/src/engine/value-object/primitive-object.ts@@ -137,6 +137,10 @@ export class NullValueObject extends BaseValueObject {return NumberValueObject.create(0).sin();}+ override sinh(): BaseValueObject {+ return NumberValueObject.create(0).sinh();+ }+override asin(): BaseValueObject {return NumberValueObject.create(0).asin();}@@ -351,6 +355,10 @@ export class BooleanValueObject extends BaseValueObject {return this._convertToNumber().sin();}+ override sinh(): BaseValueObject {+ return this._convertToNumber().sinh();+ }+override asin(): BaseValueObject {return this._convertToNumber().asin();}@@ -926,6 +934,22 @@ export class NumberValueObject extends BaseValueObject {return NumberValueObject.create(result);}+ override sinh(): BaseValueObject {+ const currentValue = this.getValue();++ if (!Number.isFinite(currentValue)) {+ return ErrorValueObject.create(ErrorType.NUM);+ }++ const result = Math.sinh(currentValue);++ if (!Number.isFinite(result)) {+ return ErrorValueObject.create(ErrorType.NUM);+ }++ return NumberValueObject.create(result);+ }+override asin(): BaseValueObject {const currentValue = this.getValue();diff --git a/packages/engine-formula/src/functions/math/acoth/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/acoth/__tests__/index.spec.tsnew file mode 100644index 0000000000..ae9e80bfaf--- /dev/null+++ b/packages/engine-formula/src/functions/math/acoth/__tests__/index.spec.ts@@ -0,0 +1,90 @@+/**+ * 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 { FUNCTION_NAMES_MATH } from '../../function-names';+import { Acoth } from '../index';+import { BooleanValueObject, NullValueObject, 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 { ErrorValueObject } from '../../../../engine/value-object/base-value-object';++describe('Test acoth function', () => {+ const testFunction = new Acoth(FUNCTION_NAMES_MATH.ACOTH);++ describe('Acoth', () => {+ it('Value is normal number', () => {+ const value = NumberValueObject.create(1);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.NUM);+ });++ it('Value is number negative', () => {+ const value = NumberValueObject.create(-2);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(-0.5493061443340549);+ });++ it('Value is number string', () => {+ const value = StringValueObject.create('1.5');+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(0.8047189562170501);+ });++ it('Value is normal string', () => {+ const value = StringValueObject.create('test');+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.VALUE);+ });++ it('Value is boolean', () => {+ const value = BooleanValueObject.create(false);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.NUM);+ });+ it('Value is blank cell', () => {+ const value = NullValueObject.create();+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.NUM);+ });+ it('Value is error', () => {+ const value = ErrorValueObject.create(ErrorType.NAME);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.NAME);+ });++ it('Value is array', () => {+ const valueArray = 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(valueArray);+ expect(transformToValue(result.getArrayValue())).toStrictEqual([+ [ErrorType.NUM, ErrorType.VALUE, 1.1358387777654846, ErrorType.NUM, ErrorType.NUM, ErrorType.NUM],+ [ErrorType.NUM, 0.010000333353334718, 0.4566505965128946, ErrorType.VALUE, -0.34657359027997264, ErrorType.NAME],+ ]);+ });+ });+});diff --git a/packages/engine-formula/src/functions/math/acoth/index.ts b/packages/engine-formula/src/functions/math/acoth/index.tsnew file mode 100644index 0000000000..0b2793cc7f--- /dev/null+++ b/packages/engine-formula/src/functions/math/acoth/index.ts@@ -0,0 +1,75 @@+/**+ * 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 type { BaseValueObject } from '../../../engine/value-object/base-value-object';+import { ErrorValueObject } from '../../../engine/value-object/base-value-object';+import { NumberValueObject } from '../../../engine/value-object/primitive-object';+import { BaseFunction } from '../../base-function';++export class Acoth extends BaseFunction {+ override minParams = 1;++ override maxParams = 1;++ override calculate(variant: BaseValueObject) {+ if (variant.isString()) {+ variant = variant.convertToNumberObjectValue();+ }++ if (variant.isError()) {+ return variant;+ }++ if ((variant as BaseValueObject).isArray()) {+ return (variant as BaseValueObject).map((currentValue) => {+ if (currentValue.isError()) {+ return currentValue;+ }+ return acoth(currentValue as BaseValueObject);+ });+ }++ return acoth(variant as BaseValueObject);+ }+}++function acoth(num: BaseValueObject) {+ let currentValue = num.getValue();++ if (num.isBoolean()) {+ currentValue = currentValue ? 1 : 0;+ }++ if (!Number.isFinite(currentValue)) {+ return ErrorValueObject.create(ErrorType.VALUE);+ }++ currentValue = Number(currentValue);++ // The absolute value of Number must be greater than 1+ if (Math.abs(currentValue) <= 1) {+ return ErrorValueObject.create(ErrorType.NUM);+ }++ const result = (1 / 2) * Math.log((currentValue + 1) / (currentValue - 1));++ if (Number.isNaN(result)) {+ return ErrorValueObject.create(ErrorType.VALUE);+ }++ return NumberValueObject.create(result);+}diff --git a/packages/engine-formula/src/functions/math/base/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/base/__tests__/index.spec.tsnew file mode 100644index 0000000000..24e738589c--- /dev/null+++ b/packages/engine-formula/src/functions/math/base/__tests__/index.spec.ts@@ -0,0 +1,156 @@+/**+ * 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 { FUNCTION_NAMES_MATH } from '../../function-names';+import { Base } from '../index';+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';+import { ErrorType } from '../../../../basics/error-type';+import type { BaseValueObject } from '../../../../engine/value-object/base-value-object';+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';+import { ArrayValueObject, transformToValue, transformToValueObject } from '../../../../engine/value-object/array-value-object';++describe('Test base function', () => {+ const testFunction = new Base(FUNCTION_NAMES_MATH.BASE);++ describe('Base', () => {+ it('All value is normal', () => {+ const number = NumberValueObject.create(15);+ const radix = NumberValueObject.create(2);+ const minLength = NumberValueObject.create(10);+ const result = testFunction.calculate(number, radix, minLength) as BaseValueObject;+ expect(result.getValue()).toBe('0000001111');+ });++ it('number value is 2**53', () => {+ const number = NumberValueObject.create(2 ** 53);+ const radix = NumberValueObject.create(2);+ const result = testFunction.calculate(number, radix) as BaseValueObject;+ expect(result.getValue()).toBe(ErrorType.NUM);+ });++ it('radix value is 1.5', () => {+ const number = NumberValueObject.create(15);+ const radix = NumberValueObject.create(1.5);+ const result = testFunction.calculate(number, radix) as BaseValueObject;+ expect(result.getValue()).toBe(ErrorType.NUM);+ });++ it('radix value is 37', () => {+ const number = NumberValueObject.create(15);+ const radix = NumberValueObject.create(37);+ const result = testFunction.calculate(number, radix) as BaseValueObject;+ expect(result.getValue()).toBe(ErrorType.NUM);+ });++ it('minLength value is number negative', () => {+ const number = NumberValueObject.create(15);+ const radix = NumberValueObject.create(2);+ const minLength = NumberValueObject.create(-2);+ const result = testFunction.calculate(number, radix, minLength) as BaseValueObject;+ expect(result.getValue()).toBe(ErrorType.NUM);+ });++ it('value is number string', () => {+ const number = StringValueObject.create('15');+ const radix = NumberValueObject.create(2);+ const minLength = StringValueObject.create('7');+ const result = testFunction.calculate(number, radix, minLength) as BaseValueObject;+ expect(result.getValue()).toBe('0001111');+ });++ it('value is normal string', () => {+ const number = StringValueObject.create('test');+ const radix = NumberValueObject.create(2);+ const minLength = StringValueObject.create('7');+ const result = testFunction.calculate(number, radix, minLength) as BaseValueObject;+ expect(result.getValue()).toBe(ErrorType.VALUE);+ });++ it('Value is boolean', () => {+ const number = BooleanValueObject.create(true);+ const radix = NumberValueObject.create(2);+ const minLength = StringValueObject.create('7');+ const result = testFunction.calculate(number, radix, minLength) as BaseValueObject;+ expect(result.getValue()).toBe('0000001');+ });++ it('Value is blank cell', () => {+ const number = NullValueObject.create();+ const radix = NumberValueObject.create(2);+ const minLength = StringValueObject.create('7');+ const result = testFunction.calculate(number, radix, minLength) as BaseValueObject;+ expect(result.getValue()).toBe('0000000');+ });++ it('Value is error', () => {+ const number = ErrorValueObject.create(ErrorType.NAME);+ const radix = NumberValueObject.create(2);+ const minLength = StringValueObject.create('7');+ const result = testFunction.calculate(number, radix, minLength) as BaseValueObject;+ expect(result.getValue()).toBe(ErrorType.NAME);+ });++ it('Value is array', () => {+ const number = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ [1, ' ', 1.23, true, false, null, ErrorType.NAME],+ ]),+ rowCount: 1,+ columnCount: 7,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const radix = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ [0],+ ['100'],+ ['2.34'],+ ['test'],+ [-3],+ ]),+ rowCount: 5,+ columnCount: 1,+ unitId: '',+ sheetId: '',+ row: 8,+ column: 8,+ });+ const minLength = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ [-3, 0, 5],+ ]),+ rowCount: 1,+ columnCount: 3,+ unitId: '',+ sheetId: '',+ row: 11,+ column: 11,+ });+ const result = testFunction.calculate(number, radix, minLength);+ expect(transformToValue(result.getArrayValue())).toStrictEqual([+ [ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NA, ErrorType.NA, ErrorType.NA, ErrorType.NAME],+ [ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NA, ErrorType.NA, ErrorType.NA, ErrorType.NAME],+ [ErrorType.NUM, ErrorType.VALUE, '00001', ErrorType.NA, ErrorType.NA, ErrorType.NA, ErrorType.NAME],+ [ErrorType.VALUE, ErrorType.VALUE, ErrorType.VALUE, ErrorType.VALUE, ErrorType.VALUE, ErrorType.VALUE, ErrorType.NAME],+ [ErrorType.NUM, ErrorType.VALUE, ErrorType.NUM, ErrorType.NA, ErrorType.NA, ErrorType.NA, ErrorType.NAME],+ ]);+ });+ });+});diff --git a/packages/engine-formula/src/functions/math/base/index.ts b/packages/engine-formula/src/functions/math/base/index.tsnew file mode 100644index 0000000000..31955718ec--- /dev/null+++ b/packages/engine-formula/src/functions/math/base/index.ts@@ -0,0 +1,128 @@+/**+ * 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 type { ArrayValueObject } from '../../../engine/value-object/array-value-object';+import type { BaseValueObject } from '../../../engine/value-object/base-value-object';+import { ErrorValueObject } from '../../../engine/value-object/base-value-object';+import { StringValueObject } from '../../../engine/value-object/primitive-object';+import { BaseFunction } from '../../base-function';++export class Base extends BaseFunction {+ override minParams = 2;++ override maxParams = 3;++ override calculate(number: BaseValueObject, radix: BaseValueObject, minLength?: BaseValueObject) {+ if (number.isError()) {+ return number;+ }++ if (radix.isError()) {+ return radix;+ }++ if (minLength?.isError()) {+ return minLength;+ }++ // get max row length+ const maxRowLength = Math.max(+ number.isArray() ? (number as ArrayValueObject).getRowCount() : 1,+ radix.isArray() ? (radix as ArrayValueObject).getRowCount() : 1,+ minLength?.isArray() ? (minLength as ArrayValueObject).getRowCount() : 1+ );++ // get max column length+ const maxColumnLength = Math.max(+ number.isArray() ? (number as ArrayValueObject).getColumnCount() : 1,+ radix.isArray() ? (radix as ArrayValueObject).getColumnCount() : 1,+ minLength?.isArray() ? (minLength as ArrayValueObject).getColumnCount() : 1+ );++ const numberArray = expandArrayValueObject(maxRowLength, maxColumnLength, number, ErrorValueObject.create(ErrorType.NA));+ const radixArray = expandArrayValueObject(maxRowLength, maxColumnLength, radix, ErrorValueObject.create(ErrorType.NA));+ const minLengthArray = minLength ? expandArrayValueObject(maxRowLength, maxColumnLength, minLength, ErrorValueObject.create(ErrorType.NA)) : [];++ const resultArray = numberArray.map((NumberItemValueObject, rowIndex, columnIndex) => {+ let radixItemValueObject = radixArray.get(rowIndex, columnIndex) as BaseValueObject;+ let minLengthItemValueObject = minLength ? (minLengthArray as ArrayValueObject).get(rowIndex, columnIndex) : {};++ if (NumberItemValueObject.isString()) {+ NumberItemValueObject = NumberItemValueObject.convertToNumberObjectValue();+ }++ if (radixItemValueObject.isString()) {+ radixItemValueObject = radixItemValueObject.convertToNumberObjectValue();+ }++ if (minLength && (minLengthItemValueObject as BaseValueObject).isString()) {+ minLengthItemValueObject = (minLengthItemValueObject as BaseValueObject).convertToNumberObjectValue();+ }++ if (NumberItemValueObject.isString() || radixItemValueObject.isString() || (minLength && (minLengthItemValueObject as BaseValueObject).isString())) {+ return ErrorValueObject.create(ErrorType.VALUE);+ }++ if (NumberItemValueObject.isError()) {+ return NumberItemValueObject;+ }++ if (radixItemValueObject.isError()) {+ return radixItemValueObject as BaseValueObject;+ }++ if (minLength && (minLengthItemValueObject as BaseValueObject).isError()) {+ return minLengthItemValueObject as BaseValueObject;+ }++ // Any non-integer number entered as an argument is truncated to an integer.+ const NumberItemValue = Math.floor(+NumberItemValueObject.getValue());+ const radixItemValue = Math.floor(+radixItemValueObject.getValue());+ const minLengthItemValue = minLength ? Math.floor(+(minLengthItemValueObject as BaseValueObject).getValue()) : 0;++ // The number that you want to convert. Must be an integer greater than or equal to 0 and less than 2^53.+ if (NumberItemValue < 0 || NumberItemValue >= 2 ** 53) {+ return ErrorValueObject.create(ErrorType.NUM);+ }++ // The base radix that you want to convert the number into. Must be an integer greater than or equal to 2 and less than or equal to 36.+ if (radixItemValue < 2 || radixItemValue > 36) {+ return ErrorValueObject.create(ErrorType.NUM);+ }++ // The minimum length of the returned string. Must be an integer greater than or equal to 0.+ if (minLengthItemValue < 0) {+ return ErrorValueObject.create(ErrorType.NUM);+ }++ let result = NumberItemValue.toString(radixItemValue);++ if (minLength && result.length < minLengthItemValue) {+ result = new Array(minLengthItemValue - result.length + 1).join('0') + result;+ }++ return StringValueObject.create(result);+ });++ if ((resultArray as ArrayValueObject).getRowCount() === 1 && (resultArray as ArrayValueObject).getColumnCount() === 1) {+ return resultArray.getArrayValue()[0][0] as StringValueObject;+ }++ return resultArray;+ }+}diff --git a/packages/engine-formula/src/functions/math/cosh/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/cosh/__tests__/index.spec.tsnew file mode 100644index 0000000000..ee4bbf1553--- /dev/null+++ b/packages/engine-formula/src/functions/math/cosh/__tests__/index.spec.ts@@ -0,0 +1,90 @@+/**+ * 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 { FUNCTION_NAMES_MATH } from '../../function-names';+import { Cosh } from '../index';+import { BooleanValueObject, NullValueObject, 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 { ErrorValueObject } from '../../../../engine/value-object/base-value-object';++describe('Test cosh function', () => {+ const testFunction = new Cosh(FUNCTION_NAMES_MATH.COSH);++ describe('Cosh', () => {+ it('Value is normal number', () => {+ const value = NumberValueObject.create(1);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(1.5430806348152437);+ });++ it('Value is number negative', () => {+ const value = NumberValueObject.create(-2);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(3.7621956910836314);+ });++ it('Value is number string', () => {+ const value = StringValueObject.create('1.5');+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(2.352409615243247);+ });++ it('Value is normal string', () => {+ const value = StringValueObject.create('test');+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.VALUE);+ });++ it('Value is boolean', () => {+ const value = BooleanValueObject.create(false);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(1);+ });+ it('Value is blank cell', () => {+ const value = NullValueObject.create();+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(1);+ });+ it('Value is error', () => {+ const value = ErrorValueObject.create(ErrorType.NAME);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.NAME);+ });++ it('Value is array', () => {+ const valueArray = 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(valueArray);+ expect(transformToValue(result.getArrayValue())).toStrictEqual([+ [1.5430806348152437, ErrorType.VALUE, 1.8567610569852664, 1.5430806348152437, 1, 1],+ [1, 1.3440585709080678e+43, 5.238782100481168, ErrorType.VALUE, 10.067661995777765, ErrorType.NAME],+ ]);+ });+ });+});diff --git a/packages/engine-formula/src/functions/math/cosh/index.ts b/packages/engine-formula/src/functions/math/cosh/index.tsnew file mode 100644index 0000000000..ce0271a4ac--- /dev/null+++ b/packages/engine-formula/src/functions/math/cosh/index.ts@@ -0,0 +1,70 @@+/**+ * 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 type { BaseValueObject } from '../../../engine/value-object/base-value-object';+import { ErrorValueObject } from '../../../engine/value-object/base-value-object';+import { NumberValueObject } from '../../../engine/value-object/primitive-object';+import { BaseFunction } from '../../base-function';++export class Cosh extends BaseFunction {+ override minParams = 1;++ override maxParams = 1;++ override calculate(variant: BaseValueObject) {+ if (variant.isString()) {+ variant = variant.convertToNumberObjectValue();+ }++ if (variant.isError()) {+ return variant;+ }++ if ((variant as BaseValueObject).isArray()) {+ return (variant as BaseValueObject).map((currentValue) => {+ if (currentValue.isError()) {+ return currentValue;+ }+ return cosh(currentValue as BaseValueObject);+ });+ }++ return cosh(variant as BaseValueObject);+ }+}++function cosh(num: BaseValueObject) {+ let currentValue = num.getValue();++ if (num.isBoolean()) {+ currentValue = currentValue ? 1 : 0;+ }++ if (!Number.isFinite(currentValue)) {+ return ErrorValueObject.create(ErrorType.VALUE);+ }++ currentValue = Number(currentValue);++ const result = Math.cosh(currentValue);++ if (Number.isNaN(result)) {+ return ErrorValueObject.create(ErrorType.VALUE);+ }++ return NumberValueObject.create(result);+}diff --git a/packages/engine-formula/src/functions/math/cot/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/cot/__tests__/index.spec.tsnew file mode 100644index 0000000000..d8a75d215b--- /dev/null+++ b/packages/engine-formula/src/functions/math/cot/__tests__/index.spec.ts@@ -0,0 +1,96 @@+/**+ * 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 { FUNCTION_NAMES_MATH } from '../../function-names';+import { Cot } from '../index';+import { BooleanValueObject, NullValueObject, 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 { ErrorValueObject } from '../../../../engine/value-object/base-value-object';++describe('Test cot function', () => {+ const testFunction = new Cot(FUNCTION_NAMES_MATH.COT);++ describe('Cot', () => {+ it('Value is normal number', () => {+ const value = NumberValueObject.create(1);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(0.6420926159343306);+ });++ it('Value is number 2**27', () => {+ const value = NumberValueObject.create(2 ** 27);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.NUM);+ });++ it('Value is number negative', () => {+ const value = NumberValueObject.create(-2);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(0.45765755436028577);+ });++ it('Value is number string', () => {+ const value = StringValueObject.create('1.5');+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(0.07091484430265245);+ });++ it('Value is normal string', () => {+ const value = StringValueObject.create('test');+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.VALUE);+ });++ it('Value is boolean', () => {+ const value = BooleanValueObject.create(false);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.DIV_BY_ZERO);+ });+ it('Value is blank cell', () => {+ const value = NullValueObject.create();+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.DIV_BY_ZERO);+ });+ it('Value is error', () => {+ const value = ErrorValueObject.create(ErrorType.NAME);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.NAME);+ });++ it('Value is array', () => {+ const valueArray = 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(valueArray);+ expect(transformToValue(result.getArrayValue())).toStrictEqual([+ [0.6420926159343306, ErrorType.VALUE, 0.3546331016766021, 0.6420926159343306, ErrorType.DIV_BY_ZERO, ErrorType.DIV_BY_ZERO],+ [ErrorType.DIV_BY_ZERO, -1.702956919426469, -0.9681244414101432, ErrorType.VALUE, 7.015252551434534, ErrorType.NAME],+ ]);+ });+ });+});diff --git a/packages/engine-formula/src/functions/math/cot/index.ts b/packages/engine-formula/src/functions/math/cot/index.tsnew file mode 100644index 0000000000..a12c43e7f9--- /dev/null+++ b/packages/engine-formula/src/functions/math/cot/index.ts@@ -0,0 +1,68 @@+/**+ * 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 type { BaseValueObject } from '../../../engine/value-object/base-value-object';+import { ErrorValueObject } from '../../../engine/value-object/base-value-object';+import { BaseFunction } from '../../base-function';++export class Cot extends BaseFunction {+ override minParams = 1;++ override maxParams = 1;++ override calculate(variant: BaseValueObject) {+ if (variant.isString()) {+ variant = variant.convertToNumberObjectValue();+ }++ if (variant.isError()) {+ return variant;+ }++ if ((variant as BaseValueObject).isArray()) {+ return (variant as BaseValueObject).map((currentValue) => {+ if (currentValue.isString()) {+ currentValue = currentValue.convertToNumberObjectValue();+ }+ if (currentValue.isError()) {+ return currentValue;+ }+ return cot(currentValue as BaseValueObject);+ });+ }++ return cot(variant as BaseValueObject);+ }+}++function cot(num: BaseValueObject) {+ let currentValue = num.getValue();++ currentValue = Number(currentValue);++ // The absolute value of Number must be less than 2^27. If Number is outside its constraints, COT returns the #NUM! error value.+ if (Math.abs(currentValue) >= 2 ** 27) {+ return ErrorValueObject.create(ErrorType.NUM);+ }++ // COT(0) returns the #DIV/0! error value.+ if (currentValue === 0) {+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);+ }++ return num.tan().getReciprocal();+}diff --git a/packages/engine-formula/src/functions/math/coth/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/coth/__tests__/index.spec.tsnew file mode 100644index 0000000000..076a1e445c--- /dev/null+++ b/packages/engine-formula/src/functions/math/coth/__tests__/index.spec.ts@@ -0,0 +1,90 @@+/**+ * 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 { FUNCTION_NAMES_MATH } from '../../function-names';+import { Coth } from '../index';+import { BooleanValueObject, NullValueObject, 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 { ErrorValueObject } from '../../../../engine/value-object/base-value-object';++describe('Test coth function', () => {+ const testFunction = new Coth(FUNCTION_NAMES_MATH.COTH);++ describe('Coth', () => {+ it('Value is normal number', () => {+ const value = NumberValueObject.create(1);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(1.3130352854993315);+ });++ it('Value is number negative', () => {+ const value = NumberValueObject.create(-2);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(-1.0373147207275482);+ });++ it('Value is number string', () => {+ const value = StringValueObject.create('1.5');+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(1.104791392982512);+ });++ it('Value is normal string', () => {+ const value = StringValueObject.create('test');+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.VALUE);+ });++ it('Value is boolean', () => {+ const value = BooleanValueObject.create(false);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.DIV_BY_ZERO);+ });+ it('Value is blank cell', () => {+ const value = NullValueObject.create();+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.DIV_BY_ZERO);+ });+ it('Value is error', () => {+ const value = ErrorValueObject.create(ErrorType.NAME);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.NAME);+ });++ it('Value is array', () => {+ const valueArray = 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(valueArray);+ expect(transformToValue(result.getArrayValue())).toStrictEqual([+ [1.3130352854993315, ErrorType.VALUE, 1.1868318739223294, 1.3130352854993315, ErrorType.DIV_BY_ZERO, ErrorType.DIV_BY_ZERO],+ [ErrorType.DIV_BY_ZERO, 1, 1.0187318407849029, ErrorType.VALUE, -1.0049698233136892, ErrorType.NAME],+ ]);+ });+ });+});diff --git a/packages/engine-formula/src/functions/math/coth/index.ts b/packages/engine-formula/src/functions/math/coth/index.tsnew file mode 100644index 0000000000..c4e949537f--- /dev/null+++ b/packages/engine-formula/src/functions/math/coth/index.ts@@ -0,0 +1,63 @@+/**+ * 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 type { BaseValueObject } from '../../../engine/value-object/base-value-object';+import { ErrorValueObject } from '../../../engine/value-object/base-value-object';+import { BaseFunction } from '../../base-function';++export class Coth extends BaseFunction {+ override minParams = 1;++ override maxParams = 1;++ override calculate(variant: BaseValueObject) {+ if (variant.isString()) {+ variant = variant.convertToNumberObjectValue();+ }++ if (variant.isError()) {+ return variant;+ }++ if ((variant as BaseValueObject).isArray()) {+ return (variant as BaseValueObject).map((currentValue) => {+ if (currentValue.isString()) {+ currentValue = currentValue.convertToNumberObjectValue();+ }+ if (currentValue.isError()) {+ return currentValue;+ }+ return coth(currentValue as BaseValueObject);+ });+ }++ return coth(variant as BaseValueObject);+ }+}++function coth(num: BaseValueObject) {+ let currentValue = num.getValue();++ currentValue = Number(currentValue);++ // COTH(0) returns the #DIV/0! error value.+ if (currentValue === 0) {+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);+ }++ return num.tanh().getReciprocal();+}diff --git a/packages/engine-formula/src/functions/math/csc/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/csc/__tests__/index.spec.tsnew file mode 100644index 0000000000..fc0fc8025e--- /dev/null+++ b/packages/engine-formula/src/functions/math/csc/__tests__/index.spec.ts@@ -0,0 +1,96 @@+/**+ * 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 { FUNCTION_NAMES_MATH } from '../../function-names';+import { Csc } from '../index';+import { BooleanValueObject, NullValueObject, 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 { ErrorValueObject } from '../../../../engine/value-object/base-value-object';++describe('Test csc function', () => {+ const testFunction = new Csc(FUNCTION_NAMES_MATH.CSC);++ describe('Csc', () => {+ it('Value is normal number', () => {+ const value = NumberValueObject.create(1);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(1.1883951057781212);+ });++ it('Value is number 2**27', () => {+ const value = NumberValueObject.create(2 ** 27);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.NUM);+ });++ it('Value is number negative', () => {+ const value = NumberValueObject.create(-2);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(-1.0997501702946164);+ });++ it('Value is number string', () => {+ const value = StringValueObject.create('1.5');+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(1.0025113042467249);+ });++ it('Value is normal string', () => {+ const value = StringValueObject.create('test');+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.VALUE);+ });++ it('Value is boolean', () => {+ const value = BooleanValueObject.create(false);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.DIV_BY_ZERO);+ });+ it('Value is blank cell', () => {+ const value = NullValueObject.create();+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.DIV_BY_ZERO);+ });+ it('Value is error', () => {+ const value = ErrorValueObject.create(ErrorType.NAME);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.NAME);+ });++ it('Value is array', () => {+ const valueArray = 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(valueArray);+ expect(transformToValue(result.getArrayValue())).toStrictEqual([+ [1.1883951057781212, ErrorType.VALUE, 1.0610205637991976, 1.1883951057781212, ErrorType.DIV_BY_ZERO, ErrorType.DIV_BY_ZERO],+ [ErrorType.DIV_BY_ZERO, -1.9748575314241, 1.3918566499664047, ErrorType.VALUE, -7.086167395737187, ErrorType.NAME],+ ]);+ });+ });+});diff --git a/packages/engine-formula/src/functions/math/csc/index.ts b/packages/engine-formula/src/functions/math/csc/index.tsnew file mode 100644index 0000000000..7a09b9a1ed--- /dev/null+++ b/packages/engine-formula/src/functions/math/csc/index.ts@@ -0,0 +1,68 @@+/**+ * 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 type { BaseValueObject } from '../../../engine/value-object/base-value-object';+import { ErrorValueObject } from '../../../engine/value-object/base-value-object';+import { BaseFunction } from '../../base-function';++export class Csc extends BaseFunction {+ override minParams = 1;++ override maxParams = 1;++ override calculate(variant: BaseValueObject) {+ if (variant.isString()) {+ variant = variant.convertToNumberObjectValue();+ }++ if (variant.isError()) {+ return variant;+ }++ if ((variant as BaseValueObject).isArray()) {+ return (variant as BaseValueObject).map((currentValue) => {+ if (currentValue.isString()) {+ currentValue = currentValue.convertToNumberObjectValue();+ }+ if (currentValue.isError()) {+ return currentValue;+ }+ return csc(currentValue as BaseValueObject);+ });+ }++ return csc(variant as BaseValueObject);+ }+}++function csc(num: BaseValueObject) {+ let currentValue = num.getValue();++ currentValue = Number(currentValue);++ // The absolute value of Number must be less than 2^27. If Number is outside its constraints, COT returns the #NUM! error value.+ if (Math.abs(currentValue) >= 2 ** 27) {+ return ErrorValueObject.create(ErrorType.NUM);+ }++ // CSC(0) returns the #DIV/0! error value.+ if (currentValue === 0) {+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);+ }++ return num.sin().getReciprocal();+}diff --git a/packages/engine-formula/src/functions/math/csch/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/csch/__tests__/index.spec.tsnew file mode 100644index 0000000000..44043a8a3a--- /dev/null+++ b/packages/engine-formula/src/functions/math/csch/__tests__/index.spec.ts@@ -0,0 +1,96 @@+/**+ * 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 { FUNCTION_NAMES_MATH } from '../../function-names';+import { Csch } from '../index';+import { BooleanValueObject, NullValueObject, 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 { ErrorValueObject } from '../../../../engine/value-object/base-value-object';++describe('Test csch function', () => {+ const testFunction = new Csch(FUNCTION_NAMES_MATH.CSCH);++ describe('Csch', () => {+ it('Value is normal number', () => {+ const value = NumberValueObject.create(1);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(0.8509181282393216);+ });++ it('Value is number 2**27', () => {+ const value = NumberValueObject.create(2 ** 27);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(0);+ });++ it('Value is number negative', () => {+ const value = NumberValueObject.create(-2);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(-0.2757205647717832);+ });++ it('Value is number string', () => {+ const value = StringValueObject.create('1.5');+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(0.46964244059522464);+ });++ it('Value is normal string', () => {+ const value = StringValueObject.create('test');+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.VALUE);+ });++ it('Value is boolean', () => {+ const value = BooleanValueObject.create(false);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.DIV_BY_ZERO);+ });+ it('Value is blank cell', () => {+ const value = NullValueObject.create();+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.DIV_BY_ZERO);+ });+ it('Value is error', () => {+ const value = ErrorValueObject.create(ErrorType.NAME);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.NAME);+ });++ it('Value is array', () => {+ const valueArray = 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(valueArray);+ expect(transformToValue(result.getArrayValue())).toStrictEqual([+ [0.8509181282393216, ErrorType.VALUE, 0.6391947253834218, 0.8509181282393216, ErrorType.DIV_BY_ZERO, ErrorType.DIV_BY_ZERO],+ [ErrorType.DIV_BY_ZERO, 7.440151952041671e-44, 0.1944596704435054, ErrorType.VALUE, -0.09982156966882273, ErrorType.NAME],+ ]);+ });+ });+});diff --git a/packages/engine-formula/src/functions/math/csch/index.ts b/packages/engine-formula/src/functions/math/csch/index.tsnew file mode 100644index 0000000000..db222e41e8--- /dev/null+++ b/packages/engine-formula/src/functions/math/csch/index.ts@@ -0,0 +1,69 @@+/**+ * 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 type { BaseValueObject } from '../../../engine/value-object/base-value-object';+import { ErrorValueObject } from '../../../engine/value-object/base-value-object';+import { NumberValueObject } from '../../../engine/value-object/primitive-object';+import { BaseFunction } from '../../base-function';++export class Csch extends BaseFunction {+ override minParams = 1;++ override maxParams = 1;++ override calculate(variant: BaseValueObject) {+ if (variant.isString()) {+ variant = variant.convertToNumberObjectValue();+ }++ if (variant.isError()) {+ return variant;+ }++ if ((variant as BaseValueObject).isArray()) {+ return (variant as BaseValueObject).map((currentValue) => {+ if (currentValue.isString()) {+ currentValue = currentValue.convertToNumberObjectValue();+ }+ if (currentValue.isError()) {+ return currentValue;+ }+ return csch(currentValue as BaseValueObject);+ });+ }++ return csch(variant as BaseValueObject);+ }+}++function csch(num: BaseValueObject) {+ let currentValue = num.getValue();++ currentValue = Number(currentValue);++ // CSCH(0) returns the #DIV/0! error value.+ if (currentValue === 0) {+ return ErrorValueObject.create(ErrorType.DIV_BY_ZERO);+ }++ // sinh(number) = Infinity return 0+ if (!Number.isNaN(currentValue) && !Number.isFinite(Math.sinh(currentValue))) {+ return NumberValueObject.create(0);+ }++ return num.sinh().getReciprocal();+}diff --git a/packages/engine-formula/src/functions/math/function-map.ts b/packages/engine-formula/src/functions/math/function-map.tsindex dfa986deb4..41a22b9a7c 100644--- a/packages/engine-formula/src/functions/math/function-map.ts+++ b/packages/engine-formula/src/functions/math/function-map.ts@@ -18,16 +18,25 @@ import { Abs } from './abs';import { Acos } from './acos';import { Acosh } from './acosh';import { Acot } from './acot';+import { Acoth } from './acoth';import { Asin } from './asin';import { Asinh } from './asinh';import { Atan } from './atan';import { Atan2 } from './atan2';import { Atanh } from './atanh';+import { Base } from './base';import { Cos } from './cos';+import { Cosh } from './cosh';+import { Cot } from './cot';+import { Coth } from './coth';+import { Csc } from './csc';+import { Csch } from './csch';import { FUNCTION_NAMES_MATH } from './function-names';import { Mod } from './mod';import { Power } from './power';import { Product } from './product';+import { Sin } from './sin';+import { Sinh } from './sinh';import { Subtotal } from './subtotal';import { Sum } from './sum';import { Sumif } from './sumif';@@ -40,15 +49,24 @@ export const functionMath = [[Acos, FUNCTION_NAMES_MATH.ACOS],[Acosh, FUNCTION_NAMES_MATH.ACOSH],[Acot, FUNCTION_NAMES_MATH.ACOT],+ [Acoth, FUNCTION_NAMES_MATH.ACOTH],[Asin, FUNCTION_NAMES_MATH.ASIN],[Asinh, FUNCTION_NAMES_MATH.ASINH],[Atan, FUNCTION_NAMES_MATH.ATAN],[Atan2, FUNCTION_NAMES_MATH.ATAN2],[Atanh, FUNCTION_NAMES_MATH.ATANH],+ [Base, FUNCTION_NAMES_MATH.BASE],[Cos, FUNCTION_NAMES_MATH.COS],+ [Cosh, FUNCTION_NAMES_MATH.COSH],+ [Cot, FUNCTION_NAMES_MATH.COT],+ [Coth, FUNCTION_NAMES_MATH.COTH],+ [Csc, FUNCTION_NAMES_MATH.CSC],+ [Csch, FUNCTION_NAMES_MATH.CSCH],[Mod, FUNCTION_NAMES_MATH.MOD],[Power, FUNCTION_NAMES_MATH.POWER],[Product, FUNCTION_NAMES_MATH.PRODUCT],+ [Sin, FUNCTION_NAMES_MATH.SIN],+ [Sinh, FUNCTION_NAMES_MATH.SINH],[Subtotal, FUNCTION_NAMES_MATH.SUBTOTAL],[Sum, FUNCTION_NAMES_MATH.SUM],[Sumif, FUNCTION_NAMES_MATH.SUMIF],diff --git a/packages/engine-formula/src/functions/math/sin/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/sin/__tests__/index.spec.tsnew file mode 100644index 0000000000..2d03a09484--- /dev/null+++ b/packages/engine-formula/src/functions/math/sin/__tests__/index.spec.ts@@ -0,0 +1,90 @@+/**+ * 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 { FUNCTION_NAMES_MATH } from '../../function-names';+import { Sin } from '../index';+import { BooleanValueObject, NullValueObject, 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 { ErrorValueObject } from '../../../../engine/value-object/base-value-object';++describe('Test sin function', () => {+ const testFunction = new Sin(FUNCTION_NAMES_MATH.SIN);++ describe('Sin', () => {+ it('Value is normal number', () => {+ const value = NumberValueObject.create(1);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(0.8414709848078965);+ });++ it('Value is number valid', () => {+ const value = NumberValueObject.create(-2);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(-0.9092974268256817);+ });++ it('Value is number string', () => {+ const value = StringValueObject.create('1.5');+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(0.9974949866040544);+ });++ it('Value is normal string', () => {+ const value = StringValueObject.create('test');+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.VALUE);+ });++ it('Value is boolean', () => {+ const value = BooleanValueObject.create(false);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(0);+ });+ it('Value is blank cell', () => {+ const value = NullValueObject.create();+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(0);+ });+ it('Value is error', () => {+ const value = ErrorValueObject.create(ErrorType.NAME);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.NAME);+ });++ it('Value is array', () => {+ const valueArray = 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(valueArray);+ expect(transformToValue(result.getArrayValue())).toStrictEqual([+ [0.8414709848078965, ErrorType.VALUE, 0.9424888019316975, 0.8414709848078965, 0, 0],+ [0, -0.5063656411097588, 0.7184647930691261, ErrorType.VALUE, -0.1411200080598672, ErrorType.NAME],+ ]);+ });+ });+});diff --git a/packages/engine-formula/src/functions/math/sin/index.ts b/packages/engine-formula/src/functions/math/sin/index.tsnew file mode 100644index 0000000000..73702b7f94--- /dev/null+++ b/packages/engine-formula/src/functions/math/sin/index.ts@@ -0,0 +1,36 @@+/**+ * 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 type { BaseValueObject } from '../../../engine/value-object/base-value-object';+import { BaseFunction } from '../../base-function';++export class Sin extends BaseFunction {+ override minParams = 1;++ override maxParams = 1;++ override calculate(variant: BaseValueObject) {+ if (variant.isString()) {+ variant = variant.convertToNumberObjectValue();+ }++ if (variant.isError()) {+ return variant;+ }++ return variant.sin();+ }+}diff --git a/packages/engine-formula/src/functions/math/sinh/__tests__/index.spec.ts b/packages/engine-formula/src/functions/math/sinh/__tests__/index.spec.tsnew file mode 100644index 0000000000..22292b24de--- /dev/null+++ b/packages/engine-formula/src/functions/math/sinh/__tests__/index.spec.ts@@ -0,0 +1,90 @@+/**+ * 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 { FUNCTION_NAMES_MATH } from '../../function-names';+import { Sinh } from '../index';+import { BooleanValueObject, NullValueObject, 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 { ErrorValueObject } from '../../../../engine/value-object/base-value-object';++describe('Test sinh function', () => {+ const testFunction = new Sinh(FUNCTION_NAMES_MATH.SINH);++ describe('Sinh', () => {+ it('Value is normal number', () => {+ const value = NumberValueObject.create(1);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(1.1752011936438014);+ });++ it('Value is number valid', () => {+ const value = NumberValueObject.create(-2);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(-3.626860407847019);+ });++ it('Value is number string', () => {+ const value = StringValueObject.create('1.5');+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(2.1292794550948173);+ });++ it('Value is normal string', () => {+ const value = StringValueObject.create('test');+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.VALUE);+ });++ it('Value is boolean', () => {+ const value = BooleanValueObject.create(false);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(0);+ });+ it('Value is blank cell', () => {+ const value = NullValueObject.create();+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(0);+ });+ it('Value is error', () => {+ const value = ErrorValueObject.create(ErrorType.NAME);+ const result = testFunction.calculate(value);+ expect(result.getValue()).toBe(ErrorType.NAME);+ });++ it('Value is array', () => {+ const valueArray = 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(valueArray);+ expect(transformToValue(result.getArrayValue())).toStrictEqual([+ [1.1752011936438014, ErrorType.VALUE, 1.564468479304407, 1.1752011936438014, 0, 0],+ [0, 1.3440585709080678e+43, 5.142454462250675, ErrorType.VALUE, -10.017874927409903, ErrorType.NAME],+ ]);+ });+ });+});diff --git a/packages/engine-formula/src/functions/math/sinh/index.ts b/packages/engine-formula/src/functions/math/sinh/index.tsnew file mode 100644index 0000000000..05598c2fd1--- /dev/null+++ b/packages/engine-formula/src/functions/math/sinh/index.ts@@ -0,0 +1,36 @@+/**+ * 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 type { BaseValueObject } from '../../../engine/value-object/base-value-object';+import { BaseFunction } from '../../base-function';++export class Sinh extends BaseFunction {+ override minParams = 1;++ override maxParams = 1;++ override calculate(variant: BaseValueObject) {+ if (variant.isString()) {+ variant = variant.convertToNumberObjectValue();+ }++ if (variant.isError()) {+ return variant;+ }++ return variant.sinh();+ }+}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.tsindex 118669dd5b..7502ec2190 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@@ -80,8 +80,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: 'number', detail: 'The absolute value of Number must be greater than 1.' },},},AGGREGATE: {@@ -188,8 +187,9 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: 'number', detail: 'The number that you want to convert. Must be an integer greater than or equal to 0 and less than 2^53.' },+ radix: { name: 'radix', detail: 'The base radix that you want to convert the number into. Must be an integer greater than or equal to 2 and less than or equal to 36.' },+ minLength: { name: 'min_length', detail: 'The minimum length of the returned string. Must be an integer greater than or equal to 0.' },},},CEILING: {@@ -285,8 +285,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: 'number', detail: 'Any real number for which you want to find the hyperbolic cosine.' },},},COT: {@@ -299,8 +298,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: 'number', detail: 'The angle in radians for which you want the cotangent.' },},},COTH: {@@ -313,8 +311,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: 'number', detail: 'Any real number for which you want to find the hyperbolic cotangent.' },},},CSC: {@@ -327,8 +324,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: 'number', detail: 'The angle in radians for which you want the cosecant.' },},},CSCH: {@@ -341,8 +337,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: 'number', detail: 'The angle in radians for which you want the hyperbolic cosecant.' },},},DECIMAL: {@@ -943,8 +938,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: 'number', detail: 'The angle in radians for which you want the sine.' },},},SINH: {@@ -957,8 +951,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: 'number', detail: 'Any real number.' },},},SQRT: {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.tsindex b3ee6a4ac0..31f1be8c56 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@@ -80,8 +80,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数値', detail: '数値の絶対値は 1 より大きい値である必要があります。' },},},AGGREGATE: {@@ -188,8 +187,9 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数値', detail: '変換する数値を指定します。 0 以上、2^53 未満の整数である必要があります。' },+ radix: { name: '基数', detail: ' 数値を変換する基数 (底) の数値を指定します。 2 以上、36 以下の整数である必要があります。' },+ minLength: { name: '最小の長さです', detail: '返される文字列の最小長を指定します。 0 以上の整数である必要があります。' },},},CEILING: {@@ -285,8 +285,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数値', detail: ' 双曲線余弦を求める実数を指定します。' },},},COT: {@@ -299,8 +298,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数値', detail: '余接を求める角度を、ラジアンを単位として指定します。' },},},COTH: {@@ -313,8 +311,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数値', detail: '双曲線余接を求める実数を指定します。' },},},CSC: {@@ -327,8 +324,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数値', detail: '余割を求める角度を、ラジアンを単位として指定します。' },},},CSCH: {@@ -341,8 +337,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数値', detail: '双曲線余割を求める角度を、ラジアンを単位として指定します。' },},},DECIMAL: {@@ -943,8 +938,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数値', detail: 'サインを求める角度をラジアンで指定します。' },},},SINH: {@@ -957,8 +951,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数値', detail: '実数を指定します。' },},},SQRT: {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.tsindex 62d8504224..6b50413ee5 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@@ -70,7 +70,7 @@ export default {},},ACOTH: {- description: '返回一个数的双曲反余切值',+ description: '返回数字的反双曲余切值。',abstract: '返回一个数的双曲反余切值',links: [{@@ -79,8 +79,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数值', detail: 'Number 的绝对值必须大于 1。' },},},AGGREGATE: {@@ -187,8 +186,9 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数值', detail: '要转换的数字。 必须是大于或等于 0 且小于 2^53 的整数。' },+ radix: { name: '基数', detail: '要将数字转换为的基数。 必须是大于或等于 2 且小于或等于 36 的整数。' },+ minLength: { name: '最小长度', detail: '返回的字符串的最小长度。 必须是大于或等于 0 的整数。' },},},CEILING: {@@ -284,13 +284,12 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数值', detail: '想要求双曲余弦的任意实数。' },},},COT: {- description: '返回角度的余弦值',- abstract: '返回角度的余弦值',+ description: '返回以弧度表示的角度的余切值。',+ abstract: '指定角度的余切值(以弧度表示)',links: [{title: '教学',@@ -298,8 +297,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数值', detail: '需要余切值的角度(以弧度为单位)。' },},},COTH: {@@ -312,12 +310,11 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数值', detail: '想要求双曲余切的任意实数。' },},},CSC: {- description: '返回角度的余割值',+ description: '返回角度的余割值,以弧度表示。',abstract: '返回角度的余割值',links: [{@@ -326,8 +323,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数值', detail: '想要求余割的角度,以弧度表示。' },},},CSCH: {@@ -340,8 +336,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数值', detail: '想要求双曲余割值的角度,以弧度表示。' },},},DECIMAL: {@@ -944,8 +939,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数值', detail: '需要求正弦的角度,以弧度表示。' },},},SINH: {@@ -958,8 +952,7 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ number: { name: '数值', detail: '任意实数。' },},},SQRT: {diff --git a/packages/sheets-formula/src/services/function-list/math.ts b/packages/sheets-formula/src/services/function-list/math.tsindex a0611d37f8..643817567b 100644--- a/packages/sheets-formula/src/services/function-list/math.ts+++ b/packages/sheets-formula/src/services/function-list/math.ts@@ -85,16 +85,9 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [abstract: 'formula.functionList.ACOTH.abstract',functionParameter: [{- name: 'formula.functionList.ACOTH.functionParameter.number1.name',- detail: 'formula.functionList.ACOTH.functionParameter.number1.detail',- example: 'A1:A20',- require: 1,- repeat: 0,- },- {- name: 'formula.functionList.ACOTH.functionParameter.number2.name',- detail: 'formula.functionList.ACOTH.functionParameter.number2.detail',- example: 'A1:A20',+ name: 'formula.functionList.ACOTH.functionParameter.number.name',+ detail: 'formula.functionList.ACOTH.functionParameter.number.detail',+ example: '6',require: 1,repeat: 0,},@@ -233,19 +226,26 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [abstract: 'formula.functionList.BASE.abstract',functionParameter: [{- name: 'formula.functionList.BASE.functionParameter.number1.name',- detail: 'formula.functionList.BASE.functionParameter.number1.detail',- example: 'A1:A20',+ name: 'formula.functionList.BASE.functionParameter.number.name',+ detail: 'formula.functionList.BASE.functionParameter.number.detail',+ example: '15',require: 1,repeat: 0,},{- name: 'formula.functionList.BASE.functionParameter.number2.name',- detail: 'formula.functionList.BASE.functionParameter.number2.detail',- example: 'A1:A20',+ name: 'formula.functionList.BASE.functionParameter.radix.name',+ detail: 'formula.functionList.BASE.functionParameter.radix.detail',+ example: '2',require: 1,repeat: 0,},+ {+ name: 'formula.functionList.BASE.functionParameter.minLength.name',+ detail: 'formula.functionList.BASE.functionParameter.minLength.detail',+ example: '10',+ require: 0,+ repeat: 0,+ },],},{@@ -380,16 +380,9 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [abstract: 'formula.functionList.COSH.abstract',functionParameter: [{- name: 'formula.functionList.COSH.functionParameter.number1.name',- detail: 'formula.functionList.COSH.functionParameter.number1.detail',- example: 'A1:A20',- require: 1,- repeat: 0,- },- {- name: 'formula.functionList.COSH.functionParameter.number2.name',- detail: 'formula.functionList.COSH.functionParameter.number2.detail',- example: 'A1:A20',+ name: 'formula.functionList.COSH.functionParameter.number.name',+ detail: 'formula.functionList.COSH.functionParameter.number.detail',+ example: '4',require: 1,repeat: 0,},@@ -402,16 +395,9 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [abstract: 'formula.functionList.COT.abstract',functionParameter: [{- name: 'formula.functionList.COT.functionParameter.number1.name',- detail: 'formula.functionList.COT.functionParameter.number1.detail',- example: 'A1:A20',- require: 1,- repeat: 0,- },- {- name: 'formula.functionList.COT.functionParameter.number2.name',- detail: 'formula.functionList.COT.functionParameter.number2.detail',- example: 'A1:A20',+ name: 'formula.functionList.COT.functionParameter.number.name',+ detail: 'formula.functionList.COT.functionParameter.number.detail',+ example: '30',require: 1,repeat: 0,},@@ -424,16 +410,9 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [abstract: 'formula.functionList.COTH.abstract',functionParameter: [{- name: 'formula.functionList.COTH.functionParameter.number1.name',- detail: 'formula.functionList.COTH.functionParameter.number1.detail',- example: 'A1:A20',- require: 1,- repeat: 0,- },- {- name: 'formula.functionList.COTH.functionParameter.number2.name',- detail: 'formula.functionList.COTH.functionParameter.number2.detail',- example: 'A1:A20',+ name: 'formula.functionList.COTH.functionParameter.number.name',+ detail: 'formula.functionList.COTH.functionParameter.number.detail',+ example: '2',require: 1,repeat: 0,},@@ -446,16 +425,9 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [abstract: 'formula.functionList.CSC.abstract',functionParameter: [{- name: 'formula.functionList.CSC.functionParameter.number1.name',- detail: 'formula.functionList.CSC.functionParameter.number1.detail',- example: 'A1:A20',- require: 1,- repeat: 0,- },- {- name: 'formula.functionList.CSC.functionParameter.number2.name',- detail: 'formula.functionList.CSC.functionParameter.number2.detail',- example: 'A1:A20',+ name: 'formula.functionList.CSC.functionParameter.number.name',+ detail: 'formula.functionList.CSC.functionParameter.number.detail',+ example: '15',require: 1,repeat: 0,},@@ -468,16 +440,9 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [abstract: 'formula.functionList.CSCH.abstract',functionParameter: [{- name: 'formula.functionList.CSCH.functionParameter.number1.name',- detail: 'formula.functionList.CSCH.functionParameter.number1.detail',- example: 'A1:A20',- require: 1,- repeat: 0,- },- {- name: 'formula.functionList.CSCH.functionParameter.number2.name',- detail: 'formula.functionList.CSCH.functionParameter.number2.detail',- example: 'A1:A20',+ name: 'formula.functionList.CSCH.functionParameter.number.name',+ detail: 'formula.functionList.CSCH.functionParameter.number.detail',+ example: '1.5',require: 1,repeat: 0,},@@ -1414,16 +1379,9 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [abstract: 'formula.functionList.SIN.abstract',functionParameter: [{- name: 'formula.functionList.SIN.functionParameter.number1.name',- detail: 'formula.functionList.SIN.functionParameter.number1.detail',- example: 'A1:A20',- require: 1,- repeat: 0,- },- {- name: 'formula.functionList.SIN.functionParameter.number2.name',- detail: 'formula.functionList.SIN.functionParameter.number2.detail',- example: 'A1:A20',+ name: 'formula.functionList.SIN.functionParameter.number.name',+ detail: 'formula.functionList.SIN.functionParameter.number.detail',+ example: '30*PI()/180',require: 1,repeat: 0,},@@ -1436,16 +1394,9 @@ export const FUNCTION_LIST_MATH: IFunctionInfo[] = [abstract: 'formula.functionList.SINH.abstract',functionParameter: [{- name: 'formula.functionList.SINH.functionParameter.number1.name',- detail: 'formula.functionList.SINH.functionParameter.number1.detail',- example: 'A1:A20',- require: 1,- repeat: 0,- },- {- name: 'formula.functionList.SINH.functionParameter.number2.name',- detail: 'formula.functionList.SINH.functionParameter.number2.detail',- example: 'A1:A20',+ name: 'formula.functionList.SINH.functionParameter.number.name',+ detail: 'formula.functionList.SINH.functionParameter.number.detail',+ example: '0.0342*1.03',require: 1,repeat: 0,},