diff --git a/packages/engine-formula/src/engine/ast-node/function-node.ts b/packages/engine-formula/src/engine/ast-node/function-node.ts index 281782e003a..56239d97094 100644 --- a/packages/engine-formula/src/engine/ast-node/function-node.ts +++ b/packages/engine-formula/src/engine/ast-node/function-node.ts @@ -60,6 +60,10 @@ export class FunctionNode extends BaseAstNode { if (this._functionExecutor.needsLocale) { this._setLocale(); } + + if (this._functionExecutor.needsSheetsInfo) { + this._setSheetsInfo(); + } } override get nodeType() { @@ -275,6 +279,10 @@ export class FunctionNode extends BaseAstNode { private _setLocale() { this._functionExecutor.setLocale(this._currentConfigService.getLocale()); } + + private _setSheetsInfo() { + this._functionExecutor.setSheetsInfo(this._currentConfigService.getSheetsInfo()); + } } export class ErrorFunctionNode extends BaseAstNode { diff --git a/packages/engine-formula/src/functions/base-function.ts b/packages/engine-formula/src/functions/base-function.ts index 7435122af23..1c4e9126913 100644 --- a/packages/engine-formula/src/functions/base-function.ts +++ b/packages/engine-formula/src/functions/base-function.ts @@ -43,6 +43,8 @@ export class BaseFunction { private _column: number = -1; private _definedNames: Nullable; private _locale: LocaleType; + private _sheetOrder: string[]; + private _sheetNameMap: { [sheetId: string]: string }; /** * Whether the function needs to expand the parameters @@ -59,6 +61,11 @@ export class BaseFunction { */ needsLocale: boolean = false; + /** + * Whether the function needs sheets info + */ + needsSheetsInfo: boolean = false; + /** * Minimum number of parameters */ @@ -125,6 +132,24 @@ export class BaseFunction { this._locale = locale; } + getSheetsInfo() { + return { + sheetOrder: this._sheetOrder, + sheetNameMap: this._sheetNameMap, + }; + } + + setSheetsInfo({ + sheetOrder, + sheetNameMap, + }: { + sheetOrder: string[]; + sheetNameMap: { [sheetId: string]: string }; + }) { + this._sheetOrder = sheetOrder; + this._sheetNameMap = sheetNameMap; + } + isAsync() { return false; } diff --git a/packages/engine-formula/src/functions/information/function-map.ts b/packages/engine-formula/src/functions/information/function-map.ts index ff93d238bc7..c08e8b22f8e 100644 --- a/packages/engine-formula/src/functions/information/function-map.ts +++ b/packages/engine-formula/src/functions/information/function-map.ts @@ -14,9 +14,9 @@ * limitations under the License. */ -import { FUNCTION_NAMES_INFORMATION } from './function-names'; import { Cell } from './cell'; import { ErrorType } from './error-type'; +import { FUNCTION_NAMES_INFORMATION } from './function-names'; import { Isblank } from './isblank'; import { Iserr } from './iserr'; import { Iserror } from './iserror'; @@ -31,6 +31,8 @@ import { Isref } from './isref'; import { Istext } from './istext'; import { N } from './n'; import { Na } from './na'; +import { Sheet } from './sheet'; +import { Sheets } from './sheets'; import { Type } from './type'; export const functionInformation = [ @@ -50,5 +52,7 @@ export const functionInformation = [ [Istext, FUNCTION_NAMES_INFORMATION.ISTEXT], [N, FUNCTION_NAMES_INFORMATION.N], [Na, FUNCTION_NAMES_INFORMATION.NA], + [Sheet, FUNCTION_NAMES_INFORMATION.SHEET], + [Sheets, FUNCTION_NAMES_INFORMATION.SHEETS], [Type, FUNCTION_NAMES_INFORMATION.TYPE], ]; diff --git a/packages/engine-formula/src/functions/information/sheet/__tests__/index.spec.ts b/packages/engine-formula/src/functions/information/sheet/__tests__/index.spec.ts new file mode 100644 index 00000000000..629a8b44fde --- /dev/null +++ b/packages/engine-formula/src/functions/information/sheet/__tests__/index.spec.ts @@ -0,0 +1,168 @@ +/** + * 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 { Injector, IWorkbookData } from '@univerjs/core'; +import type { LexerNode } from '../../../../engine/analysis/lexer-node'; + +import type { BaseAstNode } from '../../../../engine/ast-node/base-ast-node'; +import { CellValueType, LocaleType } from '@univerjs/core'; +import { beforeEach, describe, expect, it } from 'vitest'; +import { ErrorType } from '../../../../basics/error-type'; +import { Lexer } from '../../../../engine/analysis/lexer'; +import { AstTreeBuilder } from '../../../../engine/analysis/parser'; +import { Interpreter } from '../../../../engine/interpreter/interpreter'; +import { generateExecuteAstNodeData } from '../../../../engine/utils/ast-node-tool'; +import { IFormulaCurrentConfigService } from '../../../../services/current-data.service'; +import { IFunctionService } from '../../../../services/function.service'; +import { IFormulaRuntimeService } from '../../../../services/runtime.service'; +import { createFunctionTestBed, getObjectValue } from '../../../__tests__/create-function-test-bed'; +import { FUNCTION_NAMES_INFORMATION } from '../../function-names'; +import { Sheet } from '../index'; + +const getTestWorkbookData = (): IWorkbookData => { + return { + id: 'test', + appVersion: '3.0.0-alpha', + sheets: { + sheet1: { + id: 'sheet1', + name: '工作表1', + cellData: { + 0: { + 0: { + v: 1, + t: CellValueType.NUMBER, + }, + }, + }, + }, + sheet2: { + id: 'sheet2', + name: '工作表2', + cellData: { + 0: { + 0: { + v: 2, + t: CellValueType.NUMBER, + }, + }, + }, + }, + }, + locale: LocaleType.ZH_CN, + name: '', + sheetOrder: [], + styles: {}, + }; +}; + +describe('Test rank function', () => { + let get: Injector['get']; + let lexer: Lexer; + let astTreeBuilder: AstTreeBuilder; + let interpreter: Interpreter; + let calculate: (formula: string) => (string | number | boolean | null)[][] | string | number | boolean; + + beforeEach(() => { + const testBed = createFunctionTestBed(getTestWorkbookData()); + + get = testBed.get; + + lexer = get(Lexer); + astTreeBuilder = get(AstTreeBuilder); + interpreter = get(Interpreter); + + const functionService = get(IFunctionService); + + const formulaCurrentConfigService = get(IFormulaCurrentConfigService); + + const formulaRuntimeService = get(IFormulaRuntimeService); + + formulaCurrentConfigService.load({ + formulaData: {}, + arrayFormulaCellData: {}, + arrayFormulaRange: {}, + forceCalculate: false, + dirtyRanges: [], + dirtyNameMap: {}, + dirtyDefinedNameMap: {}, + dirtyUnitFeatureMap: {}, + dirtyUnitOtherFormulaMap: {}, + excludedCell: {}, + allUnitData: { + [testBed.unitId]: testBed.sheetData, + }, + }); + + const sheetItem = testBed.sheetData[testBed.sheetId]; + + formulaRuntimeService.setCurrent( + 0, + 0, + sheetItem.rowCount, + sheetItem.columnCount, + testBed.sheetId, + testBed.unitId + ); + + functionService.registerExecutors( + new Sheet(FUNCTION_NAMES_INFORMATION.SHEET) + ); + + calculate = (formula: string) => { + const lexerNode = lexer.treeBuilder(formula); + + const astNode = astTreeBuilder.parse(lexerNode as LexerNode); + + const result = interpreter.execute(generateExecuteAstNodeData(astNode as BaseAstNode)); + + return getObjectValue(result); + }; + }); + + describe('Sheet', () => { + it('Value is normal', async () => { + const result = await calculate('=SHEET()'); + expect(result).toBe(1); + }); + + it('Value is error', async () => { + const result = await calculate(`=SHEET(${ErrorType.NAME})`); + expect(result).toBe(ErrorType.NAME); + }); + + it('Value is reference', async () => { + const result = await calculate('=SHEET(A1)'); + expect(result).toBe(1); + + const result2 = await calculate(`=SHEET('工作表2'!A1)`); + expect(result2).toBe(2); + }); + + it('Value is array', async () => { + const result = await calculate('=SHEET({1,2,3})'); + expect(result).toBe(ErrorType.NA); + }); + + it('Value is match sheet name', async () => { + const result = await calculate('=SHEET("工作表3")'); + expect(result).toBe(ErrorType.NA); + + const result2 = await calculate('=SHEET("工作表2")'); + expect(result2).toBe(2); + }); + }); +}); diff --git a/packages/engine-formula/src/functions/information/sheet/index.ts b/packages/engine-formula/src/functions/information/sheet/index.ts new file mode 100644 index 00000000000..e851e06caff --- /dev/null +++ b/packages/engine-formula/src/functions/information/sheet/index.ts @@ -0,0 +1,77 @@ +/** + * 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 { BaseReferenceObject, FunctionVariantType } from '../../../engine/reference-object/base-reference-object'; +import type { BaseValueObject } from '../../../engine/value-object/base-value-object'; +import { ErrorType } from '../../../basics/error-type'; +import { ErrorValueObject } from '../../../engine/value-object/base-value-object'; +import { NumberValueObject } from '../../../engine/value-object/primitive-object'; +import { BaseFunction } from '../../base-function'; + +export class Sheet extends BaseFunction { + override minParams = 0; + + override maxParams = 1; + + override needsReferenceObject = true; + + override needsSheetsInfo = true; + + override calculate(value?: FunctionVariantType): BaseValueObject { + if (value?.isError()) { + return value as ErrorValueObject; + } + + const { sheetOrder, sheetNameMap } = this.getSheetsInfo(); + + if (!value) { + const sheetIndex = sheetOrder.findIndex((sheetId) => sheetId === this.subUnitId); + + return NumberValueObject.create(sheetIndex + 1); + } + + if (value.isReferenceObject()) { + const forcedSheetId = (value as BaseReferenceObject).getForcedSheetId(); + const defaultSheetId = (value as BaseReferenceObject).getDefaultSheetId(); + + const sheetIndex = sheetOrder.findIndex((sheetId) => { + if (forcedSheetId) { + return sheetId === forcedSheetId; + } else { + return sheetId === defaultSheetId; + } + }); + + return NumberValueObject.create(sheetIndex + 1); + } + + if (value.isArray()) { + return ErrorValueObject.create(ErrorType.NA); + } + + const inputValue = `${(value as BaseValueObject).getValue()}`.toLocaleLowerCase(); + + const inputSheetId = Object.entries(sheetNameMap).find(([_, name]) => name.toLocaleLowerCase() === inputValue)?.[0]; + + if (!inputSheetId) { + return ErrorValueObject.create(ErrorType.NA); + } + + const sheetIndex = sheetOrder.findIndex((sheetId) => sheetId === inputSheetId); + + return NumberValueObject.create(sheetIndex + 1); + } +} diff --git a/packages/engine-formula/src/functions/information/sheets/__tests__/index.spec.ts b/packages/engine-formula/src/functions/information/sheets/__tests__/index.spec.ts new file mode 100644 index 00000000000..77acabbfcf6 --- /dev/null +++ b/packages/engine-formula/src/functions/information/sheets/__tests__/index.spec.ts @@ -0,0 +1,134 @@ +/** + * 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 { Injector, IWorkbookData } from '@univerjs/core'; +import type { LexerNode } from '../../../../engine/analysis/lexer-node'; + +import type { BaseAstNode } from '../../../../engine/ast-node/base-ast-node'; +import { CellValueType, LocaleType } from '@univerjs/core'; +import { beforeEach, describe, expect, it } from 'vitest'; +import { ErrorType } from '../../../../basics/error-type'; +import { Lexer } from '../../../../engine/analysis/lexer'; +import { AstTreeBuilder } from '../../../../engine/analysis/parser'; +import { Interpreter } from '../../../../engine/interpreter/interpreter'; +import { generateExecuteAstNodeData } from '../../../../engine/utils/ast-node-tool'; +import { IFormulaCurrentConfigService } from '../../../../services/current-data.service'; +import { IFunctionService } from '../../../../services/function.service'; +import { IFormulaRuntimeService } from '../../../../services/runtime.service'; +import { createFunctionTestBed, getObjectValue } from '../../../__tests__/create-function-test-bed'; +import { FUNCTION_NAMES_INFORMATION } from '../../function-names'; +import { Sheets } from '../index'; + +const getTestWorkbookData = (): IWorkbookData => { + return { + id: 'test', + appVersion: '3.0.0-alpha', + sheets: { + sheet1: { + id: 'sheet1', + cellData: { + 0: { + 0: { + v: 1, + t: CellValueType.NUMBER, + }, + }, + }, + }, + }, + locale: LocaleType.ZH_CN, + name: '', + sheetOrder: [], + styles: {}, + }; +}; + +describe('Test rank function', () => { + let get: Injector['get']; + let lexer: Lexer; + let astTreeBuilder: AstTreeBuilder; + let interpreter: Interpreter; + let calculate: (formula: string) => (string | number | boolean | null)[][] | string | number | boolean; + + beforeEach(() => { + const testBed = createFunctionTestBed(getTestWorkbookData()); + + get = testBed.get; + + lexer = get(Lexer); + astTreeBuilder = get(AstTreeBuilder); + interpreter = get(Interpreter); + + const functionService = get(IFunctionService); + + const formulaCurrentConfigService = get(IFormulaCurrentConfigService); + + const formulaRuntimeService = get(IFormulaRuntimeService); + + formulaCurrentConfigService.load({ + formulaData: {}, + arrayFormulaCellData: {}, + arrayFormulaRange: {}, + forceCalculate: false, + dirtyRanges: [], + dirtyNameMap: {}, + dirtyDefinedNameMap: {}, + dirtyUnitFeatureMap: {}, + dirtyUnitOtherFormulaMap: {}, + excludedCell: {}, + allUnitData: { + [testBed.unitId]: testBed.sheetData, + }, + }); + + const sheetItem = testBed.sheetData[testBed.sheetId]; + + formulaRuntimeService.setCurrent( + 0, + 0, + sheetItem.rowCount, + sheetItem.columnCount, + testBed.sheetId, + testBed.unitId + ); + + functionService.registerExecutors( + new Sheets(FUNCTION_NAMES_INFORMATION.SHEETS) + ); + + calculate = (formula: string) => { + const lexerNode = lexer.treeBuilder(formula); + + const astNode = astTreeBuilder.parse(lexerNode as LexerNode); + + const result = interpreter.execute(generateExecuteAstNodeData(astNode as BaseAstNode)); + + return getObjectValue(result); + }; + }); + + describe('Sheets', () => { + it('Function is normal', async () => { + const result = await calculate('=SHEETS()'); + expect(result).toBe(1); + }); + + it('Function params count exceed', async () => { + const result = await calculate('=SHEETS(1)'); + expect(result).toBe(ErrorType.NA); + }); + }); +}); diff --git a/packages/engine-formula/src/functions/information/sheets/index.ts b/packages/engine-formula/src/functions/information/sheets/index.ts new file mode 100644 index 00000000000..ac90a5b1f71 --- /dev/null +++ b/packages/engine-formula/src/functions/information/sheets/index.ts @@ -0,0 +1,33 @@ +/** + * 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 { NumberValueObject } from '../../../engine/value-object/primitive-object'; +import { BaseFunction } from '../../base-function'; + +export class Sheets extends BaseFunction { + override minParams = 0; + + override maxParams = 0; + + override needsSheetsInfo = true; + + override calculate(): BaseValueObject { + const { sheetOrder } = this.getSheetsInfo(); + + return NumberValueObject.create(sheetOrder.length); + } +} diff --git a/packages/engine-formula/src/services/current-data.service.ts b/packages/engine-formula/src/services/current-data.service.ts index f8a7a03a2bb..120f55c9fba 100644 --- a/packages/engine-formula/src/services/current-data.service.ts +++ b/packages/engine-formula/src/services/current-data.service.ts @@ -14,10 +14,7 @@ * limitations under the License. */ -import { createIdentifier, Disposable, Inject, IUniverInstanceService, LocaleService, ObjectMatrix, UniverInstanceType } from '@univerjs/core'; import type { IUnitRange, LocaleType, Nullable, Workbook } from '@univerjs/core'; - -import { convertUnitDataToRuntime } from '../basics/runtime'; import type { IArrayFormulaRangeType, IDirtyUnitFeatureMap, @@ -35,6 +32,9 @@ import type { IUnitStylesData, } from '../basics/common'; +import { createIdentifier, Disposable, Inject, IUniverInstanceService, LocaleService, ObjectMatrix, UniverInstanceType } from '@univerjs/core'; +import { convertUnitDataToRuntime } from '../basics/runtime'; + export interface IFormulaDirtyData { forceCalculation: boolean; dirtyRanges: IUnitRange[]; @@ -98,6 +98,11 @@ export interface IFormulaCurrentConfigService { getClearDependencyTreeCache(): IDirtyUnitSheetNameMap; getLocale(): LocaleType; + + getSheetsInfo(): { + sheetOrder: string[]; + sheetNameMap: { [sheetId: string]: string }; + }; } export class FormulaCurrentConfigService extends Disposable implements IFormulaCurrentConfigService { @@ -241,6 +246,16 @@ export class FormulaCurrentConfigService extends Disposable implements IFormulaC return this._localeService.getCurrentLocale(); } + getSheetsInfo() { + const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET)!; + const { id, sheetOrder } = workbook.getSnapshot(); + + return { + sheetOrder, + sheetNameMap: this._sheetIdToNameMap[id] as { [sheetId: string]: string }, + }; + } + load(config: IFormulaDatasetConfig) { if (config.allUnitData && config.unitSheetNameMap && config.unitStylesData) { this._unitData = config.allUnitData; diff --git a/packages/sheets-formula-ui/src/locale/function-list/information/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/information/en-US.ts index 29354ea149a..87873366ea4 100644 --- a/packages/sheets-formula-ui/src/locale/function-list/information/en-US.ts +++ b/packages/sheets-formula-ui/src/locale/function-list/information/en-US.ts @@ -261,13 +261,12 @@ export default { }, ], functionParameter: { - number1: { name: 'number1', detail: 'first' }, - number2: { name: 'number2', detail: 'second' }, + value: { name: 'value', detail: 'Value is the name of a sheet or a reference for which you want the sheet number. If value is omitted, SHEET returns the number of the sheet that contains the function.' }, }, }, SHEETS: { - description: 'Returns the number of sheets in a reference', - abstract: 'Returns the number of sheets in a reference', + description: 'Returns the number of sheets in a workbook', + abstract: 'Returns the number of sheets in a workbook', links: [ { title: 'Instruction', @@ -275,8 +274,6 @@ export default { }, ], functionParameter: { - number1: { name: 'number1', detail: 'first' }, - number2: { name: 'number2', detail: 'second' }, }, }, TYPE: { diff --git a/packages/sheets-formula-ui/src/locale/function-list/information/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/information/ja-JP.ts index fb2ea855748..aeda77dcde3 100644 --- a/packages/sheets-formula-ui/src/locale/function-list/information/ja-JP.ts +++ b/packages/sheets-formula-ui/src/locale/function-list/information/ja-JP.ts @@ -261,13 +261,12 @@ export default { }, ], functionParameter: { - number1: { name: 'number1', detail: 'first' }, - number2: { name: 'number2', detail: 'second' }, + value: { name: '値', detail: 'シート番号を求めるシートまたは参照の名前を指定します。 値を省略すると、この関数を含むシートの番号が返されます。' }, }, }, SHEETS: { - description: '参照内のシート数を返します。', - abstract: '参照内のシート数を返します。', + description: 'ワークブック内のシート数を返します', + abstract: 'ワークブック内のシート数を返します', links: [ { title: '指導', @@ -275,8 +274,6 @@ export default { }, ], functionParameter: { - number1: { name: 'number1', detail: 'first' }, - number2: { name: 'number2', detail: 'second' }, }, }, TYPE: { diff --git a/packages/sheets-formula-ui/src/locale/function-list/information/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/information/vi-VN.ts index 1a338b7efc9..974d9a5813d 100644 --- a/packages/sheets-formula-ui/src/locale/function-list/information/vi-VN.ts +++ b/packages/sheets-formula-ui/src/locale/function-list/information/vi-VN.ts @@ -223,6 +223,31 @@ export default { functionParameter: { }, }, + SHEET: { + description: 'Trả về số trang của trang tham chiếu.', + abstract: 'Trả về số trang của trang tham chiếu.', + links: [ + { + title: 'Hướng dẫn', + url: 'https://support.microsoft.com/vi-vn/office/sheet-%E5%87%BD%E6%95%B0-44718b6f-8b87-47a1-a9d6-b701c06cff24', + }, + ], + functionParameter: { + value: { name: 'giá trị', detail: 'là tên của một trang hoặc một tham chiếu mà bạn muốn tìm số trang của nó. Nếu đối số value được bỏ qua, hàm SHEET trả về số trang của trang có chứa hàm.' }, + }, + }, + SHEETS: { + description: 'Trả về số trang tính trong một bảng tính', + abstract: 'Trả về số trang tính trong một bảng tính', + links: [ + { + title: 'Hướng dẫn', + url: 'https://support.microsoft.com/vi-vn/office/sheets-%E5%87%BD%E6%95%B0-770515eb-e1e8-45ce-8066-b557e5e4b80b', + }, + ], + functionParameter: { + }, + }, TYPE: { description: 'Trả về một số đại diện cho kiểu dữ liệu của giá trị', abstract: 'Trả về một số đại diện cho kiểu dữ liệu của giá trị', diff --git a/packages/sheets-formula-ui/src/locale/function-list/information/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/information/zh-CN.ts index 3a43a260bcb..d7cc98dd633 100644 --- a/packages/sheets-formula-ui/src/locale/function-list/information/zh-CN.ts +++ b/packages/sheets-formula-ui/src/locale/function-list/information/zh-CN.ts @@ -261,13 +261,12 @@ export default { }, ], functionParameter: { - number1: { name: 'number1', detail: 'first' }, - number2: { name: 'number2', detail: 'second' }, + value: { name: '值', detail: '需要其工作表编号的工作表或引用的名称。 如果省略值,SHEET 返回包含 函数的工作表编号。' }, }, }, SHEETS: { - description: '返回引用中的工作表数', - abstract: '返回引用中的工作表数', + description: '返回工作簿中的工作表数', + abstract: '返回工作簿中的工作表数', links: [ { title: '教学', @@ -275,8 +274,6 @@ export default { }, ], functionParameter: { - number1: { name: 'number1', detail: 'first' }, - number2: { name: 'number2', detail: 'second' }, }, }, TYPE: { diff --git a/packages/sheets-formula-ui/src/locale/function-list/information/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/information/zh-TW.ts index 1fa44f4a00c..6ed3ad335db 100644 --- a/packages/sheets-formula-ui/src/locale/function-list/information/zh-TW.ts +++ b/packages/sheets-formula-ui/src/locale/function-list/information/zh-TW.ts @@ -260,13 +260,12 @@ export default { }, ], functionParameter: { - number1: { name: 'number1', detail: 'first' }, - number2: { name: 'number2', detail: 'second' }, + value: { name: '值', detail: '要輸入工作表編號的工作表名稱或參照。 如果省略,SHEET 會傳回包含該函數的工作表編號。' }, }, }, SHEETS: { - description: '傳回引用中的工作表數', - abstract: '傳回引用中的工作表數', + description: '傳回工作簿中的工作表數', + abstract: '傳回工作簿中的工作表數', links: [ { title: '教導', @@ -274,8 +273,6 @@ export default { }, ], functionParameter: { - number1: { name: 'number1', detail: 'first' }, - number2: { name: 'number2', detail: 'second' }, }, }, TYPE: { diff --git a/packages/sheets-formula/src/services/function-list/information.ts b/packages/sheets-formula/src/services/function-list/information.ts index 4a407790c46..d465fa4511c 100644 --- a/packages/sheets-formula/src/services/function-list/information.ts +++ b/packages/sheets-formula/src/services/function-list/information.ts @@ -308,16 +308,9 @@ export const FUNCTION_LIST_INFORMATION: IFunctionInfo[] = [ abstract: 'formula.functionList.SHEET.abstract', functionParameter: [ { - name: 'formula.functionList.SHEET.functionParameter.number1.name', - detail: 'formula.functionList.SHEET.functionParameter.number1.detail', - example: 'A1:A20', - require: 1, - repeat: 0, - }, - { - name: 'formula.functionList.SHEET.functionParameter.number2.name', - detail: 'formula.functionList.SHEET.functionParameter.number2.detail', - example: 'A1:A20', + name: 'formula.functionList.SHEET.functionParameter.value.name', + detail: 'formula.functionList.SHEET.functionParameter.value.detail', + example: 'A1', require: 1, repeat: 0, }, @@ -329,20 +322,6 @@ export const FUNCTION_LIST_INFORMATION: IFunctionInfo[] = [ description: 'formula.functionList.SHEETS.description', abstract: 'formula.functionList.SHEETS.abstract', functionParameter: [ - { - name: 'formula.functionList.SHEETS.functionParameter.number1.name', - detail: 'formula.functionList.SHEETS.functionParameter.number1.detail', - example: 'A1:A20', - require: 1, - repeat: 0, - }, - { - name: 'formula.functionList.SHEETS.functionParameter.number2.name', - detail: 'formula.functionList.SHEETS.functionParameter.number2.detail', - example: 'A1:A20', - require: 1, - repeat: 0, - }, ], }, {