From 219a053e51f52809214d8ba4defcc04b73fa9357 Mon Sep 17 00:00:00 2001 From: Dushusir <1414556676@qq.com> Date: Fri, 28 Jun 2024 14:07:54 +0800 Subject: [PATCH] feat(formula): add choose function (#2613) * feat(formula): add choose function * fix(formula): numfmt formula sum * fix(formula): choose function ref 0 * fix(formula): choose return reference object --- .../engine/utils/__tests__/numfmt-kit.spec.ts | 3 + .../src/engine/utils/numfmt-kit.ts | 6 + .../engine/value-object/primitive-object.ts | 5 +- .../__tests__/nested-functions.spec.ts | 51 +++++-- .../lookup/choose/__tests__/index.spec.ts | 132 ++++++++++++++++++ .../src/functions/lookup/choose/index.ts | 105 ++++++++++++++ .../src/functions/lookup/function-map.ts | 2 + .../src/locale/function-list/lookup/en-US.ts | 7 +- .../src/locale/function-list/lookup/ja-JP.ts | 7 +- .../src/locale/function-list/lookup/zh-CN.ts | 7 +- .../src/services/function-list/lookup.ts | 19 ++- 11 files changed, 317 insertions(+), 27 deletions(-) create mode 100644 packages/engine-formula/src/functions/lookup/choose/__tests__/index.spec.ts create mode 100644 packages/engine-formula/src/functions/lookup/choose/index.ts diff --git a/packages/engine-formula/src/engine/utils/__tests__/numfmt-kit.spec.ts b/packages/engine-formula/src/engine/utils/__tests__/numfmt-kit.spec.ts index 35e36c10a0..2d43aea00e 100644 --- a/packages/engine-formula/src/engine/utils/__tests__/numfmt-kit.spec.ts +++ b/packages/engine-formula/src/engine/utils/__tests__/numfmt-kit.spec.ts @@ -180,5 +180,8 @@ describe('Test numfmt kit', () => { expect(comparePatternPriority(numfmtMap.date, numfmtMap.date, operatorToken.MULTIPLY)).toBe(''); // Date / Date = General expect(comparePatternPriority(numfmtMap.date, numfmtMap.date, operatorToken.DIVIDED)).toBe(''); + + expect(comparePatternPriority(numfmtMap.date, '', operatorToken.PLUS)).toBe(numfmtMap.date); + expect(comparePatternPriority('', numfmtMap.accounting, operatorToken.MINUS)).toBe(numfmtMap.accounting); }); }); diff --git a/packages/engine-formula/src/engine/utils/numfmt-kit.ts b/packages/engine-formula/src/engine/utils/numfmt-kit.ts index 216fb9a39b..f5ccc46654 100644 --- a/packages/engine-formula/src/engine/utils/numfmt-kit.ts +++ b/packages/engine-formula/src/engine/utils/numfmt-kit.ts @@ -233,6 +233,12 @@ function isAccounting(pattern: string) { * @param nextPattern */ export function comparePatternPriority(previousPattern: string, nextPattern: string, operator: operatorToken) { + if (previousPattern === '') { + return nextPattern; + } else if (nextPattern === '') { + return previousPattern; + } + const previousPatternType = getNumberFormatType(previousPattern); const nextPatternType = getNumberFormatType(nextPattern); diff --git a/packages/engine-formula/src/engine/value-object/primitive-object.ts b/packages/engine-formula/src/engine/value-object/primitive-object.ts index b6a6641968..caa5ee7004 100644 --- a/packages/engine-formula/src/engine/value-object/primitive-object.ts +++ b/packages/engine-formula/src/engine/value-object/primitive-object.ts @@ -433,6 +433,9 @@ export class NumberValueObject extends BaseValueObject { if (valueObject.isArray()) { return valueObject.plus(this); } + + const pattern = comparePatternPriority(this.getPattern(), valueObject.getPattern(), operatorToken.PLUS); + const object = this.plusBy(valueObject.getValue()); // = 1 + #NAME? gets #NAME?, = 1 + #VALUE! gets #VALUE! @@ -441,7 +444,7 @@ export class NumberValueObject extends BaseValueObject { } // Set number format - object.setPattern(comparePatternPriority(this.getPattern(), valueObject.getPattern(), operatorToken.PLUS)); + object.setPattern(pattern); return object; } diff --git a/packages/engine-formula/src/functions/__tests__/nested-functions.spec.ts b/packages/engine-formula/src/functions/__tests__/nested-functions.spec.ts index a333613a1f..4e5923df61 100644 --- a/packages/engine-formula/src/functions/__tests__/nested-functions.spec.ts +++ b/packages/engine-formula/src/functions/__tests__/nested-functions.spec.ts @@ -46,8 +46,10 @@ import { FUNCTION_NAMES_STATISTICAL } from '../statistical/function-names'; import { FUNCTION_NAMES_DATE } from '../date/function-names'; import { FUNCTION_NAMES_TEXT } from '../text/function-names'; import { IFunctionService } from '../../services/function.service'; -import type { ArrayValueObject } from '../../engine/value-object/array-value-object'; import type { LexerNode } from '../../engine/analysis/lexer-node'; +import { Choose } from '../lookup/choose'; +import { Sum } from '../math/sum'; +import { ErrorType } from '../../basics/error-type'; import { createFunctionTestBed, getObjectValue } from './create-function-test-bed'; const getFunctionsTestWorkbookData = (): IWorkbookData => { @@ -252,6 +254,7 @@ describe('Test nested functions', () => { let lexer: Lexer; let astTreeBuilder: AstTreeBuilder; let interpreter: Interpreter; + let calculate: (formula: string) => (string | number | boolean | null)[][] | string | number | boolean; beforeEach(() => { const testBed = createFunctionTestBed(getFunctionsTestWorkbookData()); @@ -307,29 +310,55 @@ describe('Test nested functions', () => { new Min(FUNCTION_NAMES_STATISTICAL.MIN), new Plus(FUNCTION_NAMES_META.PLUS), new Minus(FUNCTION_NAMES_META.MINUS), - new Concatenate(FUNCTION_NAMES_TEXT.CONCATENATE) + new Concatenate(FUNCTION_NAMES_TEXT.CONCATENATE), + new Sum(FUNCTION_NAMES_MATH.SUM), + new Choose(FUNCTION_NAMES_LOOKUP.CHOOSE) ); - }); - describe('Normal', () => { - it('Nested functions IFERROR,XLOOKUP,MAX,SUMIFS,EDATE,TODAY,DAY,PLUS,Minus,CONCATENATE', () => { - const lexerNode = lexer.treeBuilder('=IFERROR(XLOOKUP(MAX(SUMIFS(C2:C10, A2:A10, ">="&EDATE(TODAY(),-1)+1-DAY(TODAY()), A2:A10, "<"&TODAY()-DAY(TODAY())+1)), SUMIFS(C2:C10, A2:A10, ">="&EDATE(TODAY(),-1)+1-DAY(TODAY()), A2:A10, "<"&TODAY()-DAY(TODAY())+1), B2:B10, "No Data"), "No Data")'); + calculate = (formula: string) => { + const lexerNode = lexer.treeBuilder(formula); const astNode = astTreeBuilder.parse(lexerNode as LexerNode); const result = interpreter.execute(astNode as BaseAstNode); - expect((result as ArrayValueObject).toValue()).toStrictEqual([[101], [102], [103], [104], [105], [101], [102], [103], [104]]); + return getObjectValue(result); + }; + }); + + describe('Normal', () => { + it('Nested functions IFERROR,XLOOKUP,MAX,SUMIFS,EDATE,TODAY,DAY,PLUS,Minus,CONCATENATE', () => { + const result = calculate('=IFERROR(XLOOKUP(MAX(SUMIFS(C2:C10, A2:A10, ">="&EDATE(TODAY(),-1)+1-DAY(TODAY()), A2:A10, "<"&TODAY()-DAY(TODAY())+1)), SUMIFS(C2:C10, A2:A10, ">="&EDATE(TODAY(),-1)+1-DAY(TODAY()), A2:A10, "<"&TODAY()-DAY(TODAY())+1), B2:B10, "No Data"), "No Data")'); + + expect(result).toStrictEqual([[101], [102], [103], [104], [105], [101], [102], [103], [104]]); }); it('Nested functions ADDRESS,XMATCH,MIN,SUMIFS,EDATE,TODAY,DAY', () => { - const lexerNode = lexer.treeBuilder('=ADDRESS(XMATCH(MIN(SUMIFS(C2:C10, A2:A10, ">=" & EDATE(TODAY(), -1) + 1 - DAY(TODAY()), A2:A10, "<" & TODAY() - DAY(TODAY()) + 1)), SUMIFS(C2:C10, A2:A10, ">=" & EDATE(TODAY(), -1) + 1 - DAY(TODAY()), A2:A10, "<" & TODAY() - DAY(TODAY()) + 1), 0) + 1, 2)'); + const result = calculate('=ADDRESS(XMATCH(MIN(SUMIFS(C2:C10, A2:A10, ">=" & EDATE(TODAY(), -1) + 1 - DAY(TODAY()), A2:A10, "<" & TODAY() - DAY(TODAY()) + 1)), SUMIFS(C2:C10, A2:A10, ">=" & EDATE(TODAY(), -1) + 1 - DAY(TODAY()), A2:A10, "<" & TODAY() - DAY(TODAY()) + 1), 0) + 1, 2)'); - const astNode = astTreeBuilder.parse(lexerNode as LexerNode); + expect(result).toStrictEqual([['$B$2']]); + }); - const result = interpreter.execute(astNode as BaseAstNode); + it('SUM, CHOOSE', () => { + let result = calculate('=SUM(A2:CHOOSE(2,B2,C2))'); + + expect(result).toStrictEqual(45033); + + result = calculate('=SUM(CHOOSE(1,A2:B2))'); + + expect(result).toStrictEqual(45028); + + result = calculate('=SUM(CHOOSE({1,1},A2:B2))'); + + expect(result).toStrictEqual(45028); + + result = calculate('=SUM(CHOOSE({1,1,1},A2:B2))'); + + expect(result).toStrictEqual(ErrorType.NA); + + result = calculate('=SUM(CHOOSE({1,2},A2:B2))'); - expect(getObjectValue(result)).toStrictEqual([['$B$2']]); + expect(result).toStrictEqual(ErrorType.VALUE); }); }); }); diff --git a/packages/engine-formula/src/functions/lookup/choose/__tests__/index.spec.ts b/packages/engine-formula/src/functions/lookup/choose/__tests__/index.spec.ts new file mode 100644 index 0000000000..47d7b38b5b --- /dev/null +++ b/packages/engine-formula/src/functions/lookup/choose/__tests__/index.spec.ts @@ -0,0 +1,132 @@ +/** + * Copyright 2023-present DreamNum Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, expect, it } from 'vitest'; + +import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object'; +import { FUNCTION_NAMES_LOOKUP } from '../../function-names'; +import { Choose } from '../index'; +import { NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object'; +import { ErrorType } from '../../../../basics/error-type'; +import { getObjectValue } from '../../../__tests__/create-function-test-bed'; +import { ErrorValueObject } from '../../../../engine/value-object/base-value-object'; + +describe('Test choose function', () => { + const testFunction = new Choose(FUNCTION_NAMES_LOOKUP.CHOOSE); + + describe('Choose', () => { + it('Index num and value', async () => { + const indexNum = NumberValueObject.create(2); + const value1 = NumberValueObject.create(11); + const value2 = NumberValueObject.create(22); + + const resultObject = testFunction.calculate(indexNum, value1, value2); + expect(getObjectValue(resultObject)).toStrictEqual(22); + }); + + it('Index num error', async () => { + const indexNum = ErrorValueObject.create(ErrorType.NAME); + const value1 = NumberValueObject.create(11); + + const resultObject = testFunction.calculate(indexNum, value1); + expect(getObjectValue(resultObject)).toStrictEqual(ErrorType.NAME); + }); + + it('Index num and value, exceeding quantity', async () => { + const indexNum = NumberValueObject.create(3); + const value1 = NumberValueObject.create(11); + const value2 = NumberValueObject.create(22); + + const resultObject = testFunction.calculate(indexNum, value1, value2); + expect(getObjectValue(resultObject)).toStrictEqual(ErrorType.VALUE); + }); + + it('Index num array', async () => { + const indexNum = ArrayValueObject.create(/*ts*/ `{ + 1,2,3 + }`); + const value1 = NumberValueObject.create(11); + const value2 = StringValueObject.create('second'); + + const resultObject = testFunction.calculate(indexNum, value1, value2); + expect(getObjectValue(resultObject)).toStrictEqual([[11, 'second', ErrorType.VALUE]]); + }); + + it('Index num number, value1 array', async () => { + const indexNum = NumberValueObject.create(1.9); + + const value1 = ArrayValueObject.create(/*ts*/ `{ + 2; + 3; + 4 + }`); + const resultObject = testFunction.calculate(indexNum, value1); + expect(getObjectValue(resultObject)).toStrictEqual([[2], [3], [4]]); + }); + + it('Index num number negative', async () => { + const indexNum = NumberValueObject.create(-2); + + const value1 = ArrayValueObject.create(/*ts*/ `{ + 2; + 3; + 4 + }`); + const resultObject = testFunction.calculate(indexNum, value1); + expect(getObjectValue(resultObject)).toStrictEqual(ErrorType.VALUE); + }); + + it('Index num number, value1 array with blank cell', async () => { + const indexNum = NumberValueObject.create(1); + + const value1 = ArrayValueObject.create({ + calculateValueList: transformToValueObject([ + [null], + ]), + rowCount: 1, + columnCount: 1, + unitId: '', + sheetId: '', + row: 0, + column: 0, + }); + const resultObject = testFunction.calculate(indexNum, value1); + expect(getObjectValue(resultObject)).toStrictEqual([[0]]); + }); + + it('All params with array', async () => { + const indexNum = ArrayValueObject.create(/*ts*/ `{ + 1; + 2; + 3 + }`); + + const value1 = ArrayValueObject.create(/*ts*/ `{ + 11,22,33,44 + }`); + + const value2 = ArrayValueObject.create(/*ts*/ `{ + 44,77; + 55,88; + 66,99 + }`); + const value3 = NumberValueObject.create(3); + + const resultObject = testFunction.calculate(indexNum, value1, value2, value3); + expect(getObjectValue(resultObject)).toStrictEqual([[11, 22, 33, 44], [55, 88, ErrorType.NA, ErrorType.NA], [3, 3, 3, 3]]); + }); + }); +}); diff --git a/packages/engine-formula/src/functions/lookup/choose/index.ts b/packages/engine-formula/src/functions/lookup/choose/index.ts new file mode 100644 index 0000000000..b43a60cd36 --- /dev/null +++ b/packages/engine-formula/src/functions/lookup/choose/index.ts @@ -0,0 +1,105 @@ +/** + * 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 { BaseReferenceObject, FunctionVariantType } from '../../../engine/reference-object/base-reference-object'; +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 { NumberValueObject } from '../../../engine/value-object/primitive-object'; +import { BaseFunction } from '../../base-function'; + +export class Choose extends BaseFunction { + override minParams = 2; + + override maxParams = 255; + + override needsReferenceObject = true; + + override isAddress() { + return true; + } + + override calculate(indexNum: FunctionVariantType, ...variants: FunctionVariantType[]) { + if (indexNum.isError()) { + return indexNum; + } + + if (indexNum.isReferenceObject()) { + indexNum = (indexNum as BaseReferenceObject).toArrayValueObject(); + } + + indexNum = indexNum as BaseValueObject; + + if (!indexNum.isArray()) { + const index = indexNum.convertToNumberObjectValue(); + + if (index.isError()) { + return index; + } + + const variant = variants[Math.trunc(+index.getValue()) - 1] || ErrorValueObject.create(ErrorType.VALUE); + // if (variant.isNull()) { + // variant = NumberValueObject.create(0); + // } + return variant; + } + + // The size of the extended range is determined by the maximum width and height of the criteria range. + let maxRowLength = indexNum.isArray() ? (indexNum as ArrayValueObject).getRowCount() : 1; + let maxColumnLength = indexNum.isArray() ? (indexNum as ArrayValueObject).getColumnCount() : 1; + + variants.forEach((variant, i) => { + if (variant.isArray()) { + const arrayValue = variant as ArrayValueObject; + maxRowLength = Math.max(maxRowLength, arrayValue.getRowCount()); + maxColumnLength = Math.max(maxColumnLength, arrayValue.getColumnCount()); + } else { + maxRowLength = Math.max(maxRowLength, 1); + maxColumnLength = Math.max(maxColumnLength, 1); + } + }); + + const indexNumArray = expandArrayValueObject(maxRowLength, maxColumnLength, indexNum, ErrorValueObject.create(ErrorType.NA)); + const arrayValueObjectList = variants.map((variant) => { + if (variant.isReferenceObject()) { + variant = (variant as BaseReferenceObject).toArrayValueObject(); + } + return expandArrayValueObject(maxRowLength, maxColumnLength, variant as BaseValueObject, ErrorValueObject.create(ErrorType.NA)); + }); + + return indexNumArray.map((indexNumValue, row, column) => { + if (indexNumValue.isError()) { + return indexNumValue; + } + + const index = indexNumValue.convertToNumberObjectValue(); + + if (index.isError()) { + return index; + } + + const arrayValueObject = arrayValueObjectList[Math.trunc(+index.getValue()) - 1]; + + let valueObject = arrayValueObject?.get(row, column) || ErrorValueObject.create(ErrorType.VALUE); + if (valueObject?.isNull()) { + valueObject = NumberValueObject.create(0); + } + return valueObject; + }); + } +} diff --git a/packages/engine-formula/src/functions/lookup/function-map.ts b/packages/engine-formula/src/functions/lookup/function-map.ts index 090acfb602..b5107a36c7 100644 --- a/packages/engine-formula/src/functions/lookup/function-map.ts +++ b/packages/engine-formula/src/functions/lookup/function-map.ts @@ -28,10 +28,12 @@ import { Rows } from './rows'; import { Vlookup } from './vlookup'; import { Xlookup } from './xlookup'; import { Xmatch } from './xmatch'; +import { Choose } from './choose'; import { Index } from './index'; export const functionLookup = [ [Address, FUNCTION_NAMES_LOOKUP.ADDRESS], + [Choose, FUNCTION_NAMES_LOOKUP.CHOOSE], [Column, FUNCTION_NAMES_LOOKUP.COLUMN], [Columns, FUNCTION_NAMES_LOOKUP.COLUMNS], [Index, FUNCTION_NAMES_LOOKUP.INDEX], diff --git a/packages/sheets-formula/src/locale/function-list/lookup/en-US.ts b/packages/sheets-formula/src/locale/function-list/lookup/en-US.ts index 82e71bb551..302a5efa19 100644 --- a/packages/sheets-formula/src/locale/function-list/lookup/en-US.ts +++ b/packages/sheets-formula/src/locale/function-list/lookup/en-US.ts @@ -64,7 +64,7 @@ export default { }, }, CHOOSE: { - description: 'Chooses a value from a list of values', + description: 'Chooses a value from a list of values.', abstract: 'Chooses a value from a list of values', links: [ { @@ -73,8 +73,9 @@ export default { }, ], functionParameter: { - number1: { name: 'number1', detail: 'first' }, - number2: { name: 'number2', detail: 'second' }, + indexNum: { name: 'index_num', detail: 'Specifies which value argument is selected. Index_num must be a number between 1 and 254, or a formula or reference to a cell containing a number between 1 and 254.\nIf index_num is 1, CHOOSE returns value1; if it is 2, CHOOSE returns value2; and so on.\nIf index_num is less than 1 or greater than the number of the last value in the list, CHOOSE returns the #VALUE! error value.\nIf index_num is a fraction, it is truncated to the lowest integer before being used.' }, + value1: { name: 'value1', detail: 'CHOOSE selects a value or an action to perform based on index_num. The arguments can be numbers, cell references, defined names, formulas, functions, or text.' }, + value2: { name: 'value2', detail: '1 to 254 value arguments.' }, }, }, CHOOSECOLS: { diff --git a/packages/sheets-formula/src/locale/function-list/lookup/ja-JP.ts b/packages/sheets-formula/src/locale/function-list/lookup/ja-JP.ts index 510189cbd0..5ab22fb4cc 100644 --- a/packages/sheets-formula/src/locale/function-list/lookup/ja-JP.ts +++ b/packages/sheets-formula/src/locale/function-list/lookup/ja-JP.ts @@ -54,7 +54,7 @@ export default { }, CHOOSE: { description: '引数リストの値の中から特定の値を 1 つ選択します。', - abstract: '引数リストの値の中から特定の値を 1 つ選択します。', + abstract: '引数リストの値の中から特定の値を 1 つ選択します', links: [ { title: '指導', @@ -62,8 +62,9 @@ export default { }, ], functionParameter: { - number1: { name: 'number1', detail: 'first' }, - number2: { name: 'number2', detail: 'second' }, + indexNum: { name: 'インデックス', detail: 'どの値引数が選択されるかを指定します。 インデックスには 1 ~ 254 の数値、または 1 ~ 254 の数値を返す数式またはセル参照を指定します。\nインデックスが 1 の場合は、値 1 が返され、2 の場合は値 2 が返されます (以下同様)。\nインデックスが 1 未満またはリスト内の最後の値の数値よりも大きい場合は、エラー値 #VALUE! が返されます。\nインデックスに小数部がある場合は、使用される前に切り捨てられて、整数値が使用されます。' }, + value1: { name: '値 1', detail: 'CHOOSE 関数はこれらの引数から、インデックスに基づいて 1 つの値または実行する動作を選択します。 引数には、数値、セル参照、定義名、数式、関数、または文字列を指定できます。' }, + value2: { name: '値 2', detail: ' 1 ~ 254 個の値引数を指定します。' }, }, }, CHOOSECOLS: { diff --git a/packages/sheets-formula/src/locale/function-list/lookup/zh-CN.ts b/packages/sheets-formula/src/locale/function-list/lookup/zh-CN.ts index eb5bbf2d69..b2896b58cf 100644 --- a/packages/sheets-formula/src/locale/function-list/lookup/zh-CN.ts +++ b/packages/sheets-formula/src/locale/function-list/lookup/zh-CN.ts @@ -54,7 +54,7 @@ export default { }, }, CHOOSE: { - description: '从值的列表中选择值', + description: '从值的列表中选择值。', abstract: '从值的列表中选择值', links: [ { @@ -63,8 +63,9 @@ export default { }, ], functionParameter: { - number1: { name: 'number1', detail: 'first' }, - number2: { name: 'number2', detail: 'second' }, + indexNum: { name: '索引', detail: '用于指定所选定的数值参数。 index_num 必须是介于 1 到 254 之间的数字,或是包含 1 到 254 之间的数字的公式或单元格引用。\n如果 index_num 为 1,则 CHOOSE 返回 value1;如果为 2,则 CHOOSE 返回 value2,以此类推。\n如果 index_num 小于 1 或大于列表中最后一个值的索引号,则 CHOOSE 返回 #VALUE! 错误值。\n如果 index_num 为小数,则在使用前将被截尾取整。' }, + value1: { name: '值 1', detail: 'CHOOSE 将根据 index_num 从中选择一个数值或一项要执行的操作。 参数可以是数字、单元格引用、定义的名称、公式、函数或文本。' }, + value2: { name: '值 2', detail: '1 到 254 个值参数。' }, }, }, CHOOSECOLS: { diff --git a/packages/sheets-formula/src/services/function-list/lookup.ts b/packages/sheets-formula/src/services/function-list/lookup.ts index 6487e7ec12..695bb6ffc7 100644 --- a/packages/sheets-formula/src/services/function-list/lookup.ts +++ b/packages/sheets-formula/src/services/function-list/lookup.ts @@ -89,19 +89,26 @@ export const FUNCTION_LIST_LOOKUP: IFunctionInfo[] = [ abstract: 'formula.functionList.CHOOSE.abstract', functionParameter: [ { - name: 'formula.functionList.CHOOSE.functionParameter.number1.name', - detail: 'formula.functionList.CHOOSE.functionParameter.number1.detail', - example: 'A1:A20', + name: 'formula.functionList.CHOOSE.functionParameter.indexNum.name', + detail: 'formula.functionList.CHOOSE.functionParameter.indexNum.detail', + example: '1', require: 1, repeat: 0, }, { - name: 'formula.functionList.CHOOSE.functionParameter.number2.name', - detail: 'formula.functionList.CHOOSE.functionParameter.number2.detail', - example: 'A1:A20', + name: 'formula.functionList.CHOOSE.functionParameter.value1.name', + detail: 'formula.functionList.CHOOSE.functionParameter.value1.detail', + example: '"Hello"', require: 1, repeat: 0, }, + { + name: 'formula.functionList.CHOOSE.functionParameter.value2.name', + detail: 'formula.functionList.CHOOSE.functionParameter.value2.detail', + example: '"Univer"', + require: 0, + repeat: 1, + }, ], }, {