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
fix(formula): fix TEXTJOIN formula calculation when the ignoreEmpty parameter is true (#6096)
wpxp12345610b7cbfa098f
diff --git a/packages/engine-formula/src/functions/text/textjoin/__test__/index.spec.ts b/packages/engine-formula/src/functions/text/textjoin/__test__/index.spec.tsindex c84e6c71c7..0c523f9176 100644--- a/packages/engine-formula/src/functions/text/textjoin/__test__/index.spec.ts+++ b/packages/engine-formula/src/functions/text/textjoin/__test__/index.spec.ts@@ -128,6 +128,14 @@ describe('Test textjoin function', () => {});const result6 = testFunction.calculate(delimiter, ignoreEmpty6, text);expect(getObjectValue(result6)).toStrictEqual('Hi, Univer, test');++ const text2 = StringValueObject.create('');+ const text3 = StringValueObject.create('1');+ const text4 = StringValueObject.create('2');+ const text5 = StringValueObject.create('3');+ const ignoreEmpty7 = BooleanValueObject.create(true);+ const result7 = testFunction.calculate(delimiter, ignoreEmpty7, text2, text3, text2, text2, text4, text2, text5);+ expect(getObjectValue(result7)).toStrictEqual('1, 2, 3');});it('Text value test', () => {diff --git a/packages/engine-formula/src/functions/text/textjoin/index.ts b/packages/engine-formula/src/functions/text/textjoin/index.tsindex 33c50c3640..9b35a1bdf0 100644--- a/packages/engine-formula/src/functions/text/textjoin/index.ts+++ b/packages/engine-formula/src/functions/text/textjoin/index.ts@@ -79,7 +79,7 @@ export class Textjoin extends BaseFunction {let _textValues = textValues;if (ignoreEmptyValue) {- _textValues = textValues.filter((value) => value !== null);+ _textValues = textValues.filter((value) => value !== null && value !== '');}let result = '';