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 averagea,concat function (#2606)
Dushusir346b33a8067f
diff --git a/packages/engine-formula/src/functions/statistical/average/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/average/__tests__/index.spec.tsindex ef8317b43c..25bede936f 100644--- a/packages/engine-formula/src/functions/statistical/average/__tests__/index.spec.ts+++ b/packages/engine-formula/src/functions/statistical/average/__tests__/index.spec.ts@@ -104,5 +104,57 @@ describe('Test average function', () => {const result = testFunction.calculate(var1, var2);expect(result.getValue()).toBe(14.795714285714286);});++ it('Var1 is array includes string only', () => {+ const var1 = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ ['Hello'],+ ['Univer'],+ ]),+ rowCount: 2,+ columnCount: 1,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const result = testFunction.calculate(var1);+ expect(result.getValue()).toBe(ErrorType.DIV_BY_ZERO);+ });++ it('Var1 is array includes blank cells only', () => {+ const var1 = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ [null],+ [null],+ ]),+ rowCount: 2,+ columnCount: 1,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const result = testFunction.calculate(var1);+ expect(result.getValue()).toBe(ErrorType.DIV_BY_ZERO);+ });++ it('Var1 is array includes blank cells and string', () => {+ const var1 = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ [null],+ [null],+ ['Hello'],+ ]),+ rowCount: 3,+ columnCount: 1,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const result = testFunction.calculate(var1);+ expect(result.getValue()).toBe(ErrorType.DIV_BY_ZERO);+ });});});diff --git a/packages/engine-formula/src/functions/statistical/average/index.ts b/packages/engine-formula/src/functions/statistical/average/index.tsindex 95bd6480b0..0ff127f22f 100644--- a/packages/engine-formula/src/functions/statistical/average/index.ts+++ b/packages/engine-formula/src/functions/statistical/average/index.ts@@ -29,7 +29,7 @@ export class Average extends BaseFunction {for (let i = 0; i < variants.length; i++) {let variant = variants[i];- if (variant.isString()) {+ if (variant.isString() || variant.isBoolean()) {variant = variant.convertToNumberObjectValue();}diff --git a/packages/engine-formula/src/functions/statistical/averagea/__tests__/index.spec.ts b/packages/engine-formula/src/functions/statistical/averagea/__tests__/index.spec.tsnew file mode 100644index 0000000000..33f47620d1--- /dev/null+++ b/packages/engine-formula/src/functions/statistical/averagea/__tests__/index.spec.ts@@ -0,0 +1,194 @@+/**+ * 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_STATISTICAL } from '../../function-names';+import { Averagea } from '../index';+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';+import { ArrayValueObject, 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 averagea function', () => {+ const testFunction = new Averagea(FUNCTION_NAMES_STATISTICAL.AVERAGEA);++ describe('Averagea', () => {+ it('Var1 is number, var2 is number', () => {+ const var1 = NumberValueObject.create(1);+ const var2 = NumberValueObject.create(2);+ const result = testFunction.calculate(var1, var2);+ expect(result.getValue()).toBe(1.5);+ });+ it('Var1 is number, var2 is string', () => {+ const var1 = NumberValueObject.create(1);+ const var2 = StringValueObject.create('test');+ const result = testFunction.calculate(var1, var2);+ expect(result.getValue()).toBe(ErrorType.VALUE);+ });+ it('Var1 is number, var2 is string number', () => {+ const var1 = NumberValueObject.create(1);+ const var2 = StringValueObject.create('2');+ const result = testFunction.calculate(var1, var2);+ expect(result.getValue()).toBe(1.5);+ });+ it('Var1 is number, var2 is boolean', () => {+ const var1 = NumberValueObject.create(2);++ let var2 = BooleanValueObject.create(true);+ let result = testFunction.calculate(var1, var2);+ expect(result.getValue()).toBe(1.5);++ var2 = BooleanValueObject.create(false);+ result = testFunction.calculate(var1, var2);+ expect(result.getValue()).toBe(1);+ });+ it('Var1 is number, var2 is null', () => {+ const var1 = NumberValueObject.create(1);+ const var2 = NullValueObject.create();+ const result = testFunction.calculate(var1, var2);+ expect(result.getValue()).toBe(1);+ });+ it('Var1 is number, var2 is error', () => {+ const var1 = NumberValueObject.create(1);+ const var2 = ErrorValueObject.create(ErrorType.NA);+ const result = testFunction.calculate(var1, var2);+ expect(result.getValue()).toBe(ErrorType.NA);+ });++ it('Var1 is number, var2 is array includes error', () => {+ const var1 = NumberValueObject.create(1);+ const var2 = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ [1, null],+ [0, ErrorType.VALUE],+ ]),+ rowCount: 2,+ columnCount: 2,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const result = testFunction.calculate(var1, var2);+ expect(result.getValue()).toBe(ErrorType.VALUE);+ });++ it('Var1 array, ignore blank cells', () => {+ const var1 = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ [null, 1],+ [null, 2],+ ]),+ rowCount: 2,+ columnCount: 2,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const result = testFunction.calculate(var1);+ expect(result.getValue()).toBe(1.5);+ });++ it('Var1 array, string as 0', () => {+ const var1 = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ ['Hello', 1],+ ['Univer', 2],+ ]),+ rowCount: 2,+ columnCount: 2,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const result = testFunction.calculate(var1);+ expect(result.getValue()).toBe(0.75);+ });++ it('Var1 is number, var2 is array not includes error', () => {+ const var1 = NumberValueObject.create(2);+ const var2 = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ [1, ' ', 1.23, true, false, null],+ [0, '100', '2.34', 'test', -3, null],+ ]),+ rowCount: 2,+ columnCount: 6,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const result = testFunction.calculate(var1, var2);+ expect(result.getValue()).toBe(9.506363636363638);+ });++ it('Var1 is array includes string only', () => {+ const var1 = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ ['Hello'],+ ['Univer'],+ ]),+ rowCount: 2,+ columnCount: 1,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const result = testFunction.calculate(var1);+ expect(result.getValue()).toBe(0);+ });++ it('Var1 is array includes blank cells only', () => {+ const var1 = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ [null],+ [null],+ ]),+ rowCount: 2,+ columnCount: 1,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const result = testFunction.calculate(var1);+ expect(result.getValue()).toBe(ErrorType.DIV_BY_ZERO);+ });++ it('Var1 is array includes blank cells and string', () => {+ const var1 = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ [null],+ [null],+ ['Hello'],+ ]),+ rowCount: 3,+ columnCount: 1,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const result = testFunction.calculate(var1);+ expect(result.getValue()).toBe(0);+ });+ });+});diff --git a/packages/engine-formula/src/functions/statistical/averagea/index.ts b/packages/engine-formula/src/functions/statistical/averagea/index.tsnew file mode 100644index 0000000000..42e6a0aeca--- /dev/null+++ b/packages/engine-formula/src/functions/statistical/averagea/index.ts@@ -0,0 +1,78 @@+/**+ * 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 { ArrayValueObject } from '../../../engine/value-object/array-value-object';+import type { BaseValueObject } from '../../../engine/value-object/base-value-object';+import { NumberValueObject } from '../../../engine/value-object/primitive-object';+import { BaseFunction } from '../../base-function';++export class Averagea extends BaseFunction {+ override minParams = 1;++ override maxParams = 255;++ override calculate(...variants: BaseValueObject[]) {+ let accumulatorSum: BaseValueObject = NumberValueObject.create(0);+ let accumulatorCount: BaseValueObject = NumberValueObject.create(0);+ for (let i = 0; i < variants.length; i++) {+ let variant = variants[i];++ if (variant.isString() || variant.isBoolean()) {+ variant = variant.convertToNumberObjectValue();+ }++ if (variant.isError()) {+ return variant;+ }++ if (variant.isArray()) {+ (variant as ArrayValueObject).iterator((valueObject) => {+ if (valueObject == null || valueObject.isNull()) {+ return true; // continue+ }++ if (valueObject.isString()) {+ valueObject = valueObject.convertToNumberObjectValue();+ if (valueObject.isError()) {+ valueObject = NumberValueObject.create(0);+ }+ }++ if (valueObject.isBoolean()) {+ valueObject = valueObject.convertToNumberObjectValue();+ }++ if (valueObject.isError()) {+ accumulatorSum = valueObject;+ return false; // break+ }++ accumulatorSum = accumulatorSum.plus(valueObject);+ accumulatorCount = accumulatorCount.plus(NumberValueObject.create(1));+ });++ if (accumulatorSum.isError()) {+ return accumulatorSum;+ }+ } else if (!variant.isNull()) {+ accumulatorSum = accumulatorSum.plus(variant);+ accumulatorCount = accumulatorCount.plus(NumberValueObject.create(1));+ }+ }++ return accumulatorSum.divided(accumulatorCount);+ }+}diff --git a/packages/engine-formula/src/functions/statistical/function-map.ts b/packages/engine-formula/src/functions/statistical/function-map.tsindex 4a605cd1d8..336fb832f2 100644--- a/packages/engine-formula/src/functions/statistical/function-map.ts+++ b/packages/engine-formula/src/functions/statistical/function-map.ts@@ -29,9 +29,11 @@ import { VarS } from './var-s';import { Vara } from './vara';import { Varpa } from './varpa';import { Maxifs } from './maxifs';+import { Averagea } from './averagea';export const functionStatistical = [[Average, FUNCTION_NAMES_STATISTICAL.AVERAGE],+ [Averagea, FUNCTION_NAMES_STATISTICAL.AVERAGEA],[Count, FUNCTION_NAMES_STATISTICAL.COUNT],[Max, FUNCTION_NAMES_STATISTICAL.MAX],[Min, FUNCTION_NAMES_STATISTICAL.MIN],diff --git a/packages/engine-formula/src/functions/text/concat/__tests__/index.spec.ts b/packages/engine-formula/src/functions/text/concat/__tests__/index.spec.tsnew file mode 100644index 0000000000..66cf0a815c--- /dev/null+++ b/packages/engine-formula/src/functions/text/concat/__tests__/index.spec.ts@@ -0,0 +1,190 @@+/**+ * 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_TEXT } from '../../function-names';+import { Concat } from '../index';+import { StringValueObject } from '../../../../engine/value-object/primitive-object';+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';+import { ErrorType } from '../../../../basics/error-type';++describe('Test concat function', () => {+ const testFunction = new Concat(FUNCTION_NAMES_TEXT.CONCAT);++ describe('Concat', () => {+ it('Text is single cell', () => {+ const text1 = StringValueObject.create('Start ');+ const text2 = StringValueObject.create('End');+ const result = testFunction.calculate(text1, text2);+ expect(result.getValue()).toBe('Start End');+ });++ it('Text is single cell with quotation marks', () => {+ const text1 = StringValueObject.create('"Hello ""World"');+ const result = testFunction.calculate(text1);+ expect(result.getValue()).toBe('"Hello ""World"');+ });++ it('Text1 is single cell, text2 is array', () => {+ const text1 = StringValueObject.create('a');+ const text2 = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ [1, 2, 3],+ [2, 3, 4],+ [3, 4, 5],+ ]),+ rowCount: 3,+ columnCount: 3,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const result = testFunction.calculate(text1, text2);+ expect(result.getValue()).toBe('a123234345');+ });++ it('Text1 is array with blank cell', () => {+ const text1 = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ [null],+ [null],+ ]),+ rowCount: 2,+ columnCount: 1,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const result = testFunction.calculate(text1);+ expect(result.getValue()).toBe('');+ });++ it('Text1 is array, text2 is single cell', () => {+ const text1 = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ [1, 2, 3],+ [2, 3, 4],+ [3, 4, 5],+ ]),+ rowCount: 3,+ columnCount: 3,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const text2 = StringValueObject.create('a');+ const result = testFunction.calculate(text1, text2);+ expect(result.getValue()).toBe('123234345a');+ });++ it('Text1 is 3*1 array, text2 is 1*3 array', () => {+ const text1 = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ ['a'],+ ['b'],+ ['c'],+ ]),+ rowCount: 3,+ columnCount: 1,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const text2 = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ [1, 2, 3],+ ]),+ rowCount: 1,+ columnCount: 3,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const result = testFunction.calculate(text1, text2);+ expect(result.getValue()).toBe('abc123');+ });++ it('Text1 is 2*2 array, text2 is 3*3 array', () => {+ const text1 = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ ['a', 'd'],+ [0, null],+ ]),+ rowCount: 2,+ columnCount: 2,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const text2 = ArrayValueObject.create({+ calculateValueList: transformToValueObject([+ [1, 2, 3],+ [0, null, 4],+ [3, 4, 5],+ ]),+ rowCount: 3,+ columnCount: 3,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const result = testFunction.calculate(text1, text2);+ expect(result.getValue()).toBe('ad012304345');+ });++ it('Text1 is array with multi type cells, includes error', () => {+ const text = new ArrayValueObject({+ 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(text);+ expect(result.getValue()).toBe(ErrorType.NAME);+ });++ it('Text1 is array with multi type cells', () => {+ const text = new ArrayValueObject({+ calculateValueList: transformToValueObject([+ [1, ' ', 1.23, true, false, null],+ [0, '100', '2.34', 'test', -3, null],+ ]),+ rowCount: 2,+ columnCount: 6,+ unitId: '',+ sheetId: '',+ row: 0,+ column: 0,+ });+ const result = testFunction.calculate(text);+ expect(result.getValue()).toBe('1 1.23TRUEFALSE01002.34test-3');+ });+ });+});diff --git a/packages/engine-formula/src/functions/text/concat/index.ts b/packages/engine-formula/src/functions/text/concat/index.tsnew file mode 100644index 0000000000..6693499251--- /dev/null+++ b/packages/engine-formula/src/functions/text/concat/index.ts@@ -0,0 +1,60 @@+/**+ * 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 { ArrayValueObject } from '../../../engine/value-object/array-value-object';+import type { BaseValueObject } from '../../../engine/value-object/base-value-object';+import { StringValueObject } from '../../../engine/value-object/primitive-object';+import { BaseFunction } from '../../base-function';++export class Concat extends BaseFunction {+ override minParams = 1;+ override maxParams = 255;++ override calculate(...textValues: BaseValueObject[]) {+ let concatenatedString = '';+ let isError: BaseValueObject | null = null;++ for (const textValue of textValues) {+ if (textValue.isArray()) {+ (textValue as ArrayValueObject).iterator((valueObject) => {+ if (valueObject == null || valueObject.isNull()) {+ return true; // continue+ }++ if (valueObject.isError()) {+ isError = valueObject;+ return false; // break+ }++ if (valueObject.isBoolean()) {+ concatenatedString += `${valueObject.getValue()}`.toLocaleUpperCase();+ } else if (valueObject.isString() || valueObject.isNumber()) {+ concatenatedString += valueObject.getValue();+ }+ });++ if (isError) {+ return isError;+ }+ } else if (!textValue.isError() && !textValue.isNull()) {+ // Direct concatenation if it's a single value+ concatenatedString += textValue.getValue();+ }+ }++ return StringValueObject.create(concatenatedString);+ }+}diff --git a/packages/engine-formula/src/functions/text/concatenate/__tests__/index.spec.ts b/packages/engine-formula/src/functions/text/concatenate/__tests__/index.spec.tsindex 2575447cf1..7f2b00c029 100644--- a/packages/engine-formula/src/functions/text/concatenate/__tests__/index.spec.ts+++ b/packages/engine-formula/src/functions/text/concatenate/__tests__/index.spec.ts@@ -20,6 +20,7 @@ import { FUNCTION_NAMES_TEXT } from '../../function-names';import { Concatenate } from '../index';import { StringValueObject } from '../../../../engine/value-object/primitive-object';import { ArrayValueObject, transformToValue, transformToValueObject } from '../../../../engine/value-object/array-value-object';+import { ErrorType } from '../../../../basics/error-type';describe('Test concatenate function', () => {const testFunction = new Concatenate(FUNCTION_NAMES_TEXT.CONCATENATE);@@ -35,7 +36,7 @@ describe('Test concatenate function', () => {it('Text is single cell with quotation marks', () => {const text1 = StringValueObject.create('"Hello ""World"');const result = testFunction.calculate(text1);- expect(transformToValue(result.getArrayValue())).toStrictEqual([['Hello "World']]);+ expect(transformToValue(result.getArrayValue())).toStrictEqual([['"Hello ""World"']]);});it('Text1 is single cell, text2 is array', () => {@@ -134,5 +135,23 @@ describe('Test concatenate function', () => {const result = testFunction.calculate(text1, text2);expect(transformToValue(result.getArrayValue())).toStrictEqual([['a1', 'd2', '#N/A'], ['00', '', '#N/A'], ['#N/A', '#N/A', '#N/A']]);});++ it('Text1 is array with multi type cells, includes error', () => {+ const text = new ArrayValueObject({+ 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 text2 = StringValueObject.create('test');+ const result = testFunction.calculate(text, text2);+ expect(transformToValue(result.getArrayValue())).toStrictEqual([['1test', ' test', '1.23test', 'TRUEtest', 'FALSEtest', 'test'], ['0test', '100test', '2.34test', 'testtest', '-3test', '#NAME?']]);+ });});});diff --git a/packages/engine-formula/src/functions/text/concatenate/index.ts b/packages/engine-formula/src/functions/text/concatenate/index.tsindex c53d52a87c..2c99a2e037 100644--- a/packages/engine-formula/src/functions/text/concatenate/index.ts+++ b/packages/engine-formula/src/functions/text/concatenate/index.ts@@ -19,7 +19,7 @@ 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 { createStringValueObjectByRawValue } from '../../../engine/value-object/primitive-object';+import { StringValueObject } from '../../../engine/value-object/primitive-object';import { BaseFunction } from '../../base-function';export class Concatenate extends BaseFunction {@@ -57,10 +57,21 @@ export class Concatenate extends BaseFunction {return textValueObject;}- const resultValueObjectString = resultValueObject?.isNull() ? '' : resultValueObject?.getValue() ?? '';- const textValueObjectString = textValueObject?.isNull() ? '' : textValueObject?.getValue() ?? '';+ let resultValue = resultValueObject?.getValue();+ let textValue = textValueObject?.getValue();- return createStringValueObjectByRawValue(`${resultValueObjectString}${textValueObjectString}`);+ if (resultValueObject?.isBoolean()) {+ resultValue = `${resultValue}`.toLocaleUpperCase();+ }++ if (textValueObject?.isBoolean()) {+ textValue = `${textValue}`.toLocaleUpperCase();+ }++ const resultValueObjectString = resultValueObject?.isNull() ? '' : resultValue ?? '';+ const textValueObjectString = textValueObject?.isNull() ? '' : textValue ?? '';++ return StringValueObject.create(`${resultValueObjectString}${textValueObjectString}`);});}diff --git a/packages/engine-formula/src/functions/text/function-map.ts b/packages/engine-formula/src/functions/text/function-map.tsindex 63c8d4b09a..3cb8699c8c 100644--- a/packages/engine-formula/src/functions/text/function-map.ts+++ b/packages/engine-formula/src/functions/text/function-map.ts@@ -20,8 +20,10 @@ import { Len } from './len';import { Lenb } from './lenb';import { Text } from './text';import { Lower } from './lower';+import { Concat } from './concat';export const functionText = [+ [Concat, FUNCTION_NAMES_TEXT.CONCAT],[Concatenate, FUNCTION_NAMES_TEXT.CONCATENATE],[Len, FUNCTION_NAMES_TEXT.LEN],[Lenb, FUNCTION_NAMES_TEXT.LENB],diff --git a/packages/sheets-formula/src/locale/function-list/statistical/en-US.ts b/packages/sheets-formula/src/locale/function-list/statistical/en-US.tsindex 729dc913e1..7543ff480b 100644--- a/packages/sheets-formula/src/locale/function-list/statistical/en-US.ts+++ b/packages/sheets-formula/src/locale/function-list/statistical/en-US.ts@@ -50,7 +50,7 @@ export default {},},AVERAGEA: {- description: 'Returns the average of its arguments, including numbers, text, and logical values',+ description: 'Returns the average of its arguments, including numbers, text, and logical values.',abstract: 'Returns the average of its arguments, including numbers, text, and logical values',links: [{@@ -59,8 +59,14 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ value1: {+ name: 'value1',+ detail: 'The first number, cell reference, or range for which you want the average.',+ },+ value2: {+ name: 'value2',+ detail: 'Additional numbers, cell references or ranges for which you want the average, up to a maximum of 255.',+ },},},AVERAGEIF: {diff --git a/packages/sheets-formula/src/locale/function-list/statistical/ja-JP.ts b/packages/sheets-formula/src/locale/function-list/statistical/ja-JP.tsindex 4f13638391..7a06e5a989 100644--- a/packages/sheets-formula/src/locale/function-list/statistical/ja-JP.ts+++ b/packages/sheets-formula/src/locale/function-list/statistical/ja-JP.ts@@ -45,7 +45,7 @@ export default {},AVERAGEA: {description: '数値、文字列、および論理値を含む引数の平均値を返します。',- abstract: '数値、文字列、および論理値を含む引数の平均値を返します。',+ abstract: '数値、文字列、および論理値を含む引数の平均値を返します',links: [{title: '指導',@@ -53,8 +53,8 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ value1: { name: '値 1', detail: '平均を求める 1 つ目の数値、セル参照、またはセル範囲を指定します。' },+ value2: { name: '値 2', detail: '平均を求める追加の数値、セル参照、または範囲 (最大 255)。' },},},AVERAGEIF: {diff --git a/packages/sheets-formula/src/locale/function-list/statistical/zh-CN.ts b/packages/sheets-formula/src/locale/function-list/statistical/zh-CN.tsindex f23a91c211..568bc830ba 100644--- a/packages/sheets-formula/src/locale/function-list/statistical/zh-CN.ts+++ b/packages/sheets-formula/src/locale/function-list/statistical/zh-CN.ts@@ -50,7 +50,7 @@ export default {},},AVERAGEA: {- description: '返回其参数的平均值,包括数字、文本和逻辑值',+ description: '返回其参数的平均值,包括数字、文本和逻辑值。',abstract: '返回其参数的平均值,包括数字、文本和逻辑值',links: [{@@ -59,8 +59,14 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ value1: {+ name: '值 1',+ detail: '要计算平均值的第一个数字、单元格引用或单元格区域。',+ },+ value2: {+ name: '值 2',+ detail: '要计算平均值的其他数字、单元格引用或单元格区域,最多可包含 255 个。',+ },},},AVERAGEIF: {diff --git a/packages/sheets-formula/src/locale/function-list/text/en-US.ts b/packages/sheets-formula/src/locale/function-list/text/en-US.tsindex 9ca7184d0c..986d1ba5c7 100644--- a/packages/sheets-formula/src/locale/function-list/text/en-US.ts+++ b/packages/sheets-formula/src/locale/function-list/text/en-US.ts@@ -101,7 +101,7 @@ export default {},CONCAT: {description: 'Combines the text from multiple ranges and/or strings, but it doesn\'t provide the delimiter or IgnoreEmpty arguments.',- abstract: 'Combines the text from multiple ranges and/or strings, but it doesn\'t provide the delimiter or IgnoreEmpty arguments.',+ abstract: 'Combines the text from multiple ranges and/or strings, but it doesn\'t provide the delimiter or IgnoreEmpty arguments',links: [{title: 'Instruction',@@ -109,8 +109,8 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ text1: { name: 'text1', detail: 'Text item to be joined. A string, or array of strings, such as a range of cells.' },+ text2: { name: 'text2', detail: 'Additional text items to be joined. There can be a maximum of 253 text arguments for the text items. Each can be a string, or array of strings, such as a range of cells.' },},},CONCATENATE: {diff --git a/packages/sheets-formula/src/locale/function-list/text/ja-JP.ts b/packages/sheets-formula/src/locale/function-list/text/ja-JP.tsindex 161b9637d0..90620f07e1 100644--- a/packages/sheets-formula/src/locale/function-list/text/ja-JP.ts+++ b/packages/sheets-formula/src/locale/function-list/text/ja-JP.ts@@ -101,7 +101,7 @@ export default {},CONCAT: {description: '複数の範囲や文字列からのテキストを結合しますが、区切り記号または IgnoreEmpty 引数は提供しません。',- abstract: '複数の範囲や文字列からのテキストを結合しますが、区切り記号または IgnoreEmpty 引数は提供しません。',+ abstract: '複数の範囲や文字列からのテキストを結合しますが、区切り記号または IgnoreEmpty 引数は提供しません',links: [{title: '指導',@@ -109,8 +109,8 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ text1: { name: 'テキスト1', detail: '結合するテキスト項目。 文字列またはセルの範囲などの文字列の配列。' },+ text2: { name: 'テキスト2', detail: '結合する追加のテキスト項目。 テキスト項目には最大 253 のテキスト引数がを設定可能です。 各引数には、文字列、またはセルの範囲などの文字列の配列を指定できます。' },},},CONCATENATE: {diff --git a/packages/sheets-formula/src/locale/function-list/text/ru-RU.ts b/packages/sheets-formula/src/locale/function-list/text/ru-RU.tsindex 16925fecc9..c36b6da06b 100644--- a/packages/sheets-formula/src/locale/function-list/text/ru-RU.ts+++ b/packages/sheets-formula/src/locale/function-list/text/ru-RU.ts@@ -109,8 +109,8 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'первый' },- number2: { name: 'number2', detail: 'второй' },+ text1: { name: 'текст1', detail: 'Элемент текста, который нужно присоединить. Строка или массив строк, например диапазон ячеек.' },+ text2: { name: 'текст2', detail: 'Дополнительные текстовые элементы для объединения. Для текстовых элементов можно указать до 253 аргументов. Каждый из них может быть строкой или массивом строк, например диапазоном ячеек.' },},},CONCATENATE: {diff --git a/packages/sheets-formula/src/locale/function-list/text/zh-CN.ts b/packages/sheets-formula/src/locale/function-list/text/zh-CN.tsindex 37131e0f68..e7f4da31c4 100644--- a/packages/sheets-formula/src/locale/function-list/text/zh-CN.ts+++ b/packages/sheets-formula/src/locale/function-list/text/zh-CN.ts@@ -101,7 +101,7 @@ export default {},CONCAT: {description: '将多个区域和/或字符串的文本组合起来,但不提供分隔符或 IgnoreEmpty 参数。',- abstract: '将多个区域和/或字符串的文本组合起来,但不提供分隔符或 IgnoreEmpty 参数。',+ abstract: '将多个区域和/或字符串的文本组合起来,但不提供分隔符或 IgnoreEmpty 参数',links: [{title: '教学',@@ -109,8 +109,8 @@ export default {},],functionParameter: {- number1: { name: 'number1', detail: 'first' },- number2: { name: 'number2', detail: 'second' },+ text1: { name: '文本 1', detail: '要联接的文本项。 字符串或字符串数组,如单元格区域。' },+ text2: { name: '文本 2', detail: '要联接的其他文本项。 文本项最多可以有 253 个文本参数。 每个参数可以是一个字符串或字符串数组,如单元格区域。' },},},CONCATENATE: {diff --git a/packages/sheets-formula/src/services/function-list/statistical.ts b/packages/sheets-formula/src/services/function-list/statistical.tsindex 9ac74b6970..24d62ec56d 100644--- a/packages/sheets-formula/src/services/function-list/statistical.ts+++ b/packages/sheets-formula/src/services/function-list/statistical.ts@@ -57,7 +57,7 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [{name: 'formula.functionList.AVERAGE.functionParameter.number2.name',detail: 'formula.functionList.AVERAGE.functionParameter.number2.detail',- example: 'B2:B10',+ example: 'B1:B20',require: 0,repeat: 1,},@@ -70,18 +70,18 @@ export const FUNCTION_LIST_STATISTICAL: IFunctionInfo[] = [abstract: 'formula.functionList.AVERAGEA.abstract',functionParameter: [{- name: 'formula.functionList.AVERAGEA.functionParameter.number1.name',- detail: 'formula.functionList.AVERAGEA.functionParameter.number1.detail',+ name: 'formula.functionList.AVERAGEA.functionParameter.value1.name',+ detail: 'formula.functionList.AVERAGEA.functionParameter.value1.detail',example: 'A1:A20',require: 1,repeat: 0,},{- name: 'formula.functionList.AVERAGEA.functionParameter.number2.name',- detail: 'formula.functionList.AVERAGEA.functionParameter.number2.detail',- example: 'A1:A20',- require: 1,- repeat: 0,+ name: 'formula.functionList.AVERAGEA.functionParameter.value2.name',+ detail: 'formula.functionList.AVERAGEA.functionParameter.value2.detail',+ example: 'B1:B20',+ require: 0,+ repeat: 1,},],},diff --git a/packages/sheets-formula/src/services/function-list/text.ts b/packages/sheets-formula/src/services/function-list/text.tsindex 7cd5d634e6..a7f3756851 100644--- a/packages/sheets-formula/src/services/function-list/text.ts+++ b/packages/sheets-formula/src/services/function-list/text.ts@@ -156,18 +156,18 @@ export const FUNCTION_LIST_TEXT: IFunctionInfo[] = [abstract: 'formula.functionList.CONCAT.abstract',functionParameter: [{- name: 'formula.functionList.CONCAT.functionParameter.number1.name',- detail: 'formula.functionList.CONCAT.functionParameter.number1.detail',- example: 'A1:A20',+ name: 'formula.functionList.CONCAT.functionParameter.text1.name',+ detail: 'formula.functionList.CONCAT.functionParameter.text1.detail',+ example: '"Hello"',require: 1,repeat: 0,},{- name: 'formula.functionList.CONCAT.functionParameter.number2.name',- detail: 'formula.functionList.CONCAT.functionParameter.number2.detail',- example: 'A1:A20',- require: 1,- repeat: 0,+ name: 'formula.functionList.CONCAT.functionParameter.text2.name',+ detail: 'formula.functionList.CONCAT.functionParameter.text2.detail',+ example: '"Univer"',+ require: 0,+ repeat: 1,},],},