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): index function supports reference object (#1657)
Dushusirb47487a5d33a
diff --git a/examples/src/sheets/main.ts b/examples/src/sheets/main.tsindex aae59d51ee..b3f505e704 100644--- a/examples/src/sheets/main.ts+++ b/examples/src/sheets/main.ts@@ -31,8 +31,8 @@ import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui';import { UniverSheetsZenEditorPlugin } from '@univerjs/sheets-zen-editor';import { UniverUIPlugin } from '@univerjs/ui';-import { DEFAULT_WORKBOOK_DATA_DEMO } from '../data';import { DebuggerPlugin } from '../plugins/debugger';+import { DEFAULT_WORKBOOK_DATA_DEMO } from '../data/sheets/demo/default-workbook-data-demo';import { locales } from './locales';const LOAD_LAZY_PLUGINS_TIMEOUT = 1_000;diff --git a/packages/engine-formula/package.json b/packages/engine-formula/package.jsonindex c5610ddef6..b353059294 100644--- a/packages/engine-formula/package.json+++ b/packages/engine-formula/package.json@@ -66,7 +66,8 @@"rxjs": ">=7.0.0"},"dependencies": {- "big.js": "^6.2.1"+ "big.js": "^6.2.1",+ "numfmt": "^2.5.2"},"devDependencies": {"@types/big.js": "^6.2.2",diff --git a/packages/engine-formula/src/basics/format.ts b/packages/engine-formula/src/basics/format.tsnew file mode 100644index 0000000000..725b17d638--- /dev/null+++ b/packages/engine-formula/src/basics/format.ts@@ -0,0 +1,30 @@+/**+ * 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.+ */++// @ts-ignore+import numfmt from 'numfmt';++/**+ * covert number to preview string by pattern+ * @TODODushusir: Internationalization, reuse with numfmt+ *+ * @param pattern+ * @param value+ * @returns+ */+export const getFormatPreview = (pattern: string, value: number) => {+ return numfmt.format(pattern, value);+};diff --git a/packages/engine-formula/src/engine/utils/__tests__/reference.spec.ts b/packages/engine-formula/src/engine/utils/__tests__/reference.spec.tsindex ca9513194d..45f65e5055 100644--- a/packages/engine-formula/src/engine/utils/__tests__/reference.spec.ts+++ b/packages/engine-formula/src/engine/utils/__tests__/reference.spec.ts@@ -230,7 +230,7 @@ describe('Test Reference', () => {const testTrueCases = ['sheet-1','sheet 1',- 'B1048576',+ 'B1048577','RC','RC2','R5C',@@ -247,7 +247,7 @@ describe('Test Reference', () => {'!Sheet','!Sheet',];- const testFalseCase = ['Sheet1', '工作表1', 'B1048577'];+ const testFalseCase = ['Sheet1', '工作表1'];testTrueCases.forEach((testTrueCase) => {expect(needsQuoting(testTrueCase)).toBeTruthy();diff --git a/packages/engine-formula/src/engine/utils/reference.ts b/packages/engine-formula/src/engine/utils/reference.tsindex 5265559172..8fb42443c0 100644--- a/packages/engine-formula/src/engine/utils/reference.ts+++ b/packages/engine-formula/src/engine/utils/reference.ts@@ -291,7 +291,7 @@ export function deserializeRangeWithSheet(refString: string): IUnitRangeName {* Determine whether the sheet name needs to be wrapped in quotes* Excel will quote the worksheet name if any of the following is true:* - It contains any space or punctuation characters, such as ()$,;-{}"'()【】“”‘’%… and many more- * - It is a valid cell reference in A1 notation, e.g. B1048576 is quoted, B1048577 is not+ * - It is a valid cell reference in A1 notation, e.g. B1048576 is quoted* - It is a valid cell reference in R1C1 notation, e.g. RC, RC2, R5C, R-4C, RC-8, R, C* - It starts with a non-letter, e.g. 99, 1.5, 12a, 💩a* - Excel will not quote worksheet names if they only contain non-punctuation, non-letter characters in non-initial positions. For example, a💩 remains unquoted.*@@ -332,7 +332,8 @@ export function needsQuoting(name: string) {function isA1Notation(name: string) {const match = name.match(/[1-9][0-9]{0,6}/);- return /^[A-Z]+[1-9][0-9]{0,6}$/.test(name) && match !== null && Number.parseInt(match[0], 10) <= 1048576;+ // Excel has a limit on the number of rows and columns: targetRow > 1048576 || targetColumn > 16384, Univer has no limit+ return /^[A-Z]+[1-9][0-9]{0,6}$/.test(name) && match !== null;}function isR1C1Notation(name: string) {diff --git a/packages/engine-formula/src/functions/base-function.ts b/packages/engine-formula/src/functions/base-function.tsindex 331f4b549f..4b9f7939b5 100644--- a/packages/engine-formula/src/functions/base-function.ts+++ b/packages/engine-formula/src/functions/base-function.ts@@ -14,13 +14,13 @@* limitations under the License.*/-import type { Nullable } from '@univerjs/core';+import type { IRange, Nullable } from '@univerjs/core';import { Disposable } from '@univerjs/core';import { ErrorType } from '../basics/error-type';import type { IFunctionNames } from '../basics/function';import { compareToken } from '../basics/token';-import type { FunctionVariantType, NodeValueType } from '../engine/reference-object/base-reference-object';+import type { BaseReferenceObject, FunctionVariantType, NodeValueType } from '../engine/reference-object/base-reference-object';import type { ArrayBinarySearchType } from '../engine/utils/compare';import { ArrayOrderSearchType } from '../engine/utils/compare';import type { ArrayValueObject } from '../engine/value-object/array-value-object';@@ -28,6 +28,12 @@ import { type BaseValueObject, ErrorValueObject } from '../engine/value-object/bimport { NullValueObject, NumberValueObject, type PrimitiveValueType } from '../engine/value-object/primitive-object';import { convertTonNumber } from '../engine/utils/object-covert';import { createNewArray } from '../engine/utils/array-object';+import { serializeRangeToRefString } from '../engine/utils/reference';+import { REFERENCE_REGEX_SINGLE_COLUMN, REFERENCE_REGEX_SINGLE_ROW, REFERENCE_SINGLE_RANGE_REGEX } from '../basics/regex';+import { CellReferenceObject } from '../engine/reference-object/cell-reference-object';+import { RowReferenceObject } from '../engine/reference-object/row-reference-object';+import { ColumnReferenceObject } from '../engine/reference-object/column-reference-object';+import { RangeReferenceObject } from '../engine/reference-object/range-reference-object';export class BaseFunction extends Disposable {private _unitId: Nullable<string>;@@ -450,4 +456,47 @@ export class BaseFunction extends Disposable {return valueObject;}++ createReferenceObject(reference: BaseReferenceObject, range: IRange) {+ const unitId = reference.getForcedUnitId();+ const sheetId = reference.getForcedSheetId() || '';+ const sheetName = reference.getForcedSheetName();++ const gridRangeName = {+ unitId,+ sheetName,+ range,+ };++ const token = serializeRangeToRefString(gridRangeName);++ let referenceObject: BaseReferenceObject;++ if (new RegExp(REFERENCE_SINGLE_RANGE_REGEX).test(token)) {+ referenceObject = new CellReferenceObject(token);+ } else if (new RegExp(REFERENCE_REGEX_SINGLE_ROW).test(token)) {+ referenceObject = new RowReferenceObject(token);+ } else if (new RegExp(REFERENCE_REGEX_SINGLE_COLUMN).test(token)) {+ referenceObject = new ColumnReferenceObject(token);+ } else {+ referenceObject = new RangeReferenceObject(range, sheetId, unitId);+ }++ return this._setReferenceDefault(reference, referenceObject); ;+ }++ private _setReferenceDefault(reference: BaseReferenceObject, object: BaseReferenceObject) {+ if (this.unitId == null || this.subUnitId == null) {+ return ErrorValueObject.create(ErrorType.REF);+ }++ object.setDefaultUnitId(this.unitId);+ object.setDefaultSheetId(this.subUnitId);+ object.setUnitData(reference.getUnitData());+ object.setRuntimeData(reference.getRuntimeData());+ object.setArrayFormulaCellData(reference.getArrayFormulaCellData());+ object.setRuntimeArrayFormulaCellData(reference.getRuntimeArrayFormulaCellData());++ return object;+ }}diff --git a/packages/engine-formula/src/functions/lookup/index/__test__/index.spec.ts b/packages/engine-formula/src/functions/lookup/index/__test__/index.spec.tsindex 8b8d435238..56e2788855 100644--- a/packages/engine-formula/src/functions/lookup/index/__test__/index.spec.ts+++ b/packages/engine-formula/src/functions/lookup/index/__test__/index.spec.ts@@ -33,6 +33,7 @@ import type { BaseValueObject, ErrorValueObject } from '../../../../engine/valueimport type { ArrayValueObject } from '../../../../engine/value-object/array-value-object';import { Index } from '..';import { ErrorType } from '../../../../basics/error-type';+import type { BaseReferenceObject } from '../../../../engine/reference-object/base-reference-object';const getTestWorkbookData = (): IWorkbookData => {return {@@ -201,6 +202,8 @@ describe('Test index', () => {if ((result as ErrorValueObject).isError()) {return (result as ErrorValueObject).getValue();+ } else if ((result as BaseReferenceObject).isReferenceObject()) {+ return (result as BaseReferenceObject).toArrayValueObject().toValue();} else if ((result as ArrayValueObject).isArray()) {return (result as ArrayValueObject).toValue();}@@ -544,6 +547,12 @@ describe('Test index', () => {expect(result).toStrictEqual([['Tom', ErrorType.VALUE, 'Tom', 'Tom', 'Tom', 'Tom'], ['Tom', ErrorType.REF, ErrorType.REF, ErrorType.VALUE, ErrorType.VALUE, 'Tom'], [ErrorType.NA, ErrorType.NA, ErrorType.NA, ErrorType.NA, ErrorType.NA, ErrorType.NA]]);});++ it('The result of the INDEX function is a reference', async () => {+ const result = await calculate('=INDEX(A2:A5,2,1):A1');++ expect(result).toStrictEqual([[1], [3], [1]]);+ });});describe('Multi rows and columns', () => {diff --git a/packages/engine-formula/src/functions/lookup/index/index.ts b/packages/engine-formula/src/functions/lookup/index/index.tsindex b4884cce30..eef92ce9e2 100644--- a/packages/engine-formula/src/functions/lookup/index/index.ts+++ b/packages/engine-formula/src/functions/lookup/index/index.ts@@ -15,14 +15,27 @@*/import { ErrorType } from '../../../basics/error-type';+import type { BaseReferenceObject } 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, ErrorValueObject } from '../../../engine/value-object/base-value-object';import { NullValueObject, NumberValueObject } from '../../../engine/value-object/primitive-object';import { BaseFunction } from '../../base-function';+/**+ * The result of the INDEX function is a reference and is interpreted as such by other formulas. Depending on the formula, the return value of INDEX may be used as a reference or as a value.+ *+ * =INDEX(A2:A5,2,1):A1 same as =A1:A3+ *+ * OPTIMIZE: maybe we can remove some unknown type+ */export class Index extends BaseFunction {- override calculate(reference: BaseValueObject, rowNum: BaseValueObject, columnNum?: BaseValueObject, areaNum?: BaseValueObject) {+ override needsReferenceObject = true;++ override calculate(referenceObject: BaseValueObject, rowNum: BaseValueObject, columnNum?: BaseValueObject, areaNum?: BaseValueObject) {+ // covert to real type+ const reference = referenceObject as unknown as BaseReferenceObject;+if (reference == null) {return ErrorValueObject.create(ErrorType.NA);}@@ -43,12 +56,13 @@ export class Index extends BaseFunction {return areaNum;}- if (!reference.isArray()) {+ if (!(reference.isRange())) {return ErrorValueObject.create(ErrorType.REF);}- const referenceRowCount = (reference as ArrayValueObject).getRowCount();- const referenceColumnCount = (reference as ArrayValueObject).getColumnCount();+ const { startRow, endRow, startColumn, endColumn } = reference.getRangeData();+ const referenceRowCount = endRow - startRow + 1;+ const referenceColumnCount = endColumn - startColumn + 1;// When there is only one row, the rowNum is considered to be the column number.// =INDEX(A6:B6,2) equals =INDEX(A6:B6,1,2)@@ -62,6 +76,18 @@ export class Index extends BaseFunction {areaNum = areaNum ?? NumberValueObject.create(1);+ if (rowNum.isReferenceObject()) {+ rowNum = (rowNum as unknown as BaseReferenceObject).toArrayValueObject();+ }++ if (columnNum.isReferenceObject()) {+ columnNum = (columnNum as unknown as BaseReferenceObject).toArrayValueObject();+ }++ if (areaNum.isReferenceObject()) {+ areaNum = (areaNum as unknown as BaseReferenceObject).toArrayValueObject();+ }+// get max row lengthconst maxRowLength = Math.max(rowNum.isArray() ? (rowNum as ArrayValueObject).getRowCount() : 1,@@ -79,7 +105,7 @@ export class Index extends BaseFunction {// If maxRowLength and maxColumnLength are both 1, pick the value from the reference array// Otherwise, filter the results from the reference according to the specified rowNum/columnNum/areaNum, take the upper left corner cell value of each result array, and then form an array with maxRowLength row number and maxColumnLength column number.if (maxRowLength === 1 && maxColumnLength === 1) {- return this._calculateSingleCell(reference as ArrayValueObject, rowNum, columnNum, areaNum);+ return this._calculateSingleCell(reference, rowNum, columnNum, areaNum);} else {const rowNumArray = expandArrayValueObject(maxRowLength, maxColumnLength, rowNum, ErrorValueObject.create(ErrorType.NA));const columnNumArray = expandArrayValueObject(maxRowLength, maxColumnLength, columnNum, ErrorValueObject.create(ErrorType.NA));@@ -89,18 +115,18 @@ export class Index extends BaseFunction {const columnNumValue = columnNumArray.get(rowIndex, columnIndex) || NullValueObject.create();const areaNumValue = areaNumArray.get(rowIndex, columnIndex) || NullValueObject.create();- const result = this._calculateSingleCell(reference as ArrayValueObject, rowNumValue, columnNumValue, areaNumValue);+ const result = this._calculateSingleCell(reference, rowNumValue, columnNumValue, areaNumValue);- if (result.isArray()) {- return (result as ArrayValueObject).getFirstCell();+ if (result.isReferenceObject()) {+ return (result as BaseReferenceObject).toArrayValueObject().getFirstCell();}- return result;+ return result as BaseValueObject;});}}- private _calculateSingleCell(reference: ArrayValueObject, rowNum: BaseValueObject, columnNum: BaseValueObject, areaNum: BaseValueObject) {+ private _calculateSingleCell(reference: BaseReferenceObject, rowNum: BaseValueObject, columnNum: BaseValueObject, areaNum: BaseValueObject) {if (rowNum.isError()) {return rowNum;}@@ -132,16 +158,7 @@ export class Index extends BaseFunction {return ErrorValueObject.create(ErrorType.VALUE);}- const rowParam = rowNumberValue === 0 ? [undefined] : [rowNumberValue - 1, rowNumberValue];- const columnParam = columnNumberValue === 0 ? [undefined] : [columnNumberValue - 1, columnNumberValue];-- const result = reference.slice(rowParam, columnParam);-- if (!result) {- return ErrorValueObject.create(ErrorType.REF);- }-- return result;+ return this._getReferenceObject(reference, rowNumberValue, columnNumberValue, areaNumberValue);}private _getNumberValue(numberValueObject?: BaseValueObject) {@@ -189,4 +206,40 @@ export class Index extends BaseFunction {return logicValue;}++ private _getReferenceObject(reference: BaseReferenceObject, rowNumberValue: number, columnNumberValue: number, areaNumberValue: number) {+ const { startRow, endRow, startColumn, endColumn } = reference.getRangeData();++ let referenceStartRow = 0;+ let referenceEndRow = 0;+ let referenceStartColumn = 0;+ let referenceEndColumn = 0;++ if (rowNumberValue === 0) {+ referenceStartRow = startRow;+ referenceEndRow = endRow;+ } else {+ referenceStartRow = referenceEndRow = startRow + rowNumberValue - 1;+ }++ if (columnNumberValue === 0) {+ referenceStartColumn = startColumn;+ referenceEndColumn = endColumn;+ } else {+ referenceStartColumn = referenceEndColumn = startColumn + columnNumberValue - 1;+ }++ if (referenceStartRow > endRow || referenceStartColumn > endColumn) {+ return ErrorValueObject.create(ErrorType.REF);+ }++ const range = {+ startRow: referenceStartRow,+ startColumn: referenceStartColumn,+ endRow: referenceEndRow,+ endColumn: referenceEndColumn,+ };++ return this.createReferenceObject(reference, range);+ }}diff --git a/packages/engine-formula/src/functions/lookup/offset/__tests__/index.spec.ts b/packages/engine-formula/src/functions/lookup/offset/__tests__/index.spec.tsindex 266d1df435..59a874ca90 100644--- a/packages/engine-formula/src/functions/lookup/offset/__tests__/index.spec.ts+++ b/packages/engine-formula/src/functions/lookup/offset/__tests__/index.spec.ts@@ -29,14 +29,16 @@ import { IFormulaRuntimeService } from '../../../../services/runtime.service';import { createFunctionTestBed } from '../../../__tests__/create-function-test-bed';import { FUNCTION_NAMES_LOOKUP } from '../../function-names';import { Offset } from '..';-import type { ErrorValueObject } from '../../../../engine/value-object/base-value-object';+import type { BaseValueObject, ErrorValueObject } from '../../../../engine/value-object/base-value-object';import { ErrorType } from '../../../../basics/error-type';+import type { ArrayValueObject } from '../../../../engine/value-object/array-value-object';describe('Test offset', () => {let get: Injector['get'];let lexer: Lexer;let astTreeBuilder: AstTreeBuilder;let interpreter: Interpreter;+ let calculate: (formula: string) => Promise<(string | number | boolean | null)[][] | string | number | boolean>;beforeEach(() => {const testBed = createFunctionTestBed();@@ -81,57 +83,60 @@ describe('Test offset', () => {functionService.registerExecutors(new Offset(FUNCTION_NAMES_LOOKUP.OFFSET));- });- describe('Offset', () => {- it('Normal single cell', async () => {- const lexerNode = lexer.treeBuilder('=OFFSET(A1,1,0,1,1)');+ calculate = async (formula: string) => {+ const lexerNode = lexer.treeBuilder(formula);const astNode = astTreeBuilder.parse(lexerNode as LexerNode);const result = await interpreter.executeAsync(astNode as BaseAstNode);- expect((result as BaseReferenceObject).toArrayValueObject().toValue()).toStrictEqual([[3]]);- });+ if ((result as ErrorValueObject).isError()) {+ return (result as ErrorValueObject).getValue();+ } else if ((result as BaseReferenceObject).isReferenceObject()) {+ return (result as BaseReferenceObject).toArrayValueObject().toValue();+ } else if ((result as ArrayValueObject).isArray()) {+ return (result as ArrayValueObject).toValue();+ }+ return (result as BaseValueObject).getValue();+ };+ });- it('Normal array cell', async () => {- const lexerNode = lexer.treeBuilder('=OFFSET(A1,1,0,3,1)');+ describe('Offset', () => {+ it('Normal single cell', async () => {+ const result = await calculate('=OFFSET(A1,1,0,1,1)');- const astNode = astTreeBuilder.parse(lexerNode as LexerNode);+ expect(result).toStrictEqual([[3]]);+ });- const result = await interpreter.executeAsync(astNode as BaseAstNode);+ it('Normal array cell', async () => {+ const result = await calculate('=OFFSET(A1,1,0,3,1)');- expect((result as BaseReferenceObject).toArrayValueObject().toValue()).toStrictEqual([[3], [1], [0]]);+ expect(result).toStrictEqual([[3], [1], [0]]);});it('TRUE as 1', async () => {- const lexerNode = lexer.treeBuilder('=OFFSET(A1,TRUE,0,3,1)');+ const result = await calculate('=OFFSET(A1,TRUE,0,3,1)');- const astNode = astTreeBuilder.parse(lexerNode as LexerNode);-- const result = await interpreter.executeAsync(astNode as BaseAstNode);-- expect((result as BaseReferenceObject).toArrayValueObject().toValue()).toStrictEqual([[3], [1], [0]]);+ expect(result).toStrictEqual([[3], [1], [0]]);});it('Height is negative', async () => {- const lexerNode = lexer.treeBuilder('=OFFSET(A1,1,0,0,1)');-- const astNode = astTreeBuilder.parse(lexerNode as LexerNode);+ const result = await calculate('=OFFSET(A1,1,0,0,1)');- const result = await interpreter.executeAsync(astNode as BaseAstNode);-- expect((result as ErrorValueObject).getValue()).toBe(ErrorType.REF);+ expect(result).toStrictEqual(ErrorType.REF);});it('Offset outside sheet boundary', async () => {- const lexerNode = lexer.treeBuilder('=OFFSET(A1,-1,0,1,1)');+ const result = await calculate('=OFFSET(A1,-1,0,1,1)');- const astNode = astTreeBuilder.parse(lexerNode as LexerNode);+ expect(result).toStrictEqual(ErrorType.REF);+ });- const result = await interpreter.executeAsync(astNode as BaseAstNode);+ it('The result of the OFFSET function is a reference', async () => {+ const result = await calculate('=OFFSET(A1,1,1):C2');- expect((result as ErrorValueObject).getValue()).toBe(ErrorType.REF);+ expect(result).toStrictEqual([[4, 'B2']]);});});});diff --git a/packages/engine-formula/src/functions/lookup/offset/index.ts b/packages/engine-formula/src/functions/lookup/offset/index.tsindex 7978e0f5e9..efcaf5bf71 100644--- a/packages/engine-formula/src/functions/lookup/offset/index.ts+++ b/packages/engine-formula/src/functions/lookup/offset/index.ts@@ -16,20 +16,24 @@import { ErrorType } from '../../../basics/error-type';import type { BaseReferenceObject } from '../../../engine/reference-object/base-reference-object';-import { RangeReferenceObject } from '../../../engine/reference-object/range-reference-object';-import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';+import type { RangeReferenceObject } from '../../../engine/reference-object/range-reference-object';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 Offset extends BaseFunction {+ override needsReferenceObject = true;+override calculate(- reference: BaseValueObject,+ referenceObject: BaseValueObject,rows: BaseValueObject,columns: BaseValueObject,height?: BaseValueObject,width?: BaseValueObject) {+ // covert to real type+ const reference = referenceObject as unknown as RangeReferenceObject;+if (reference == null || rows == null || columns == null) {return ErrorValueObject.create(ErrorType.NA);}@@ -54,12 +58,20 @@ export class Offset extends BaseFunction {return width;}- if (!reference.isArray()) {+ if (!reference.isReferenceObject()) {return ErrorValueObject.create(ErrorType.VALUE);}- const row = (reference as ArrayValueObject).getCurrentRow();- const column = (reference as ArrayValueObject).getCurrentColumn();+ const { startRow: row, endRow: referenceEndRow, startColumn: column, endColumn: referenceEndColumn } = reference.getRangeData();++ if (rows.isReferenceObject()) {+ rows = (rows as unknown as BaseReferenceObject).toArrayValueObject();+ }++ if (columns.isReferenceObject()) {+ columns = (columns as unknown as BaseReferenceObject).toArrayValueObject();+ }+const rowOffset = this.getIndexNumValue(rows);const columnOffset = this.getIndexNumValue(columns);@@ -70,10 +82,19 @@ export class Offset extends BaseFunction {const targetRow = row + rowOffset;const targetColumn = column + columnOffset;- if (targetRow < 0 || targetColumn < 0 || targetRow > 1048576 || targetColumn > 16384) {+ // Excel has a limit on the number of rows and columns: targetRow > 1048576 || targetColumn > 16384, Univer has no limit+ if (targetRow < 0 || targetColumn < 0) {return ErrorValueObject.create(ErrorType.REF);}+ if (height?.isReferenceObject()) {+ height = (height as unknown as BaseReferenceObject).toArrayValueObject();+ }++ if (width?.isReferenceObject()) {+ width = (width as unknown as BaseReferenceObject).toArrayValueObject();+ }+const heightCount = (height && this.getIndexNumValue(height)) ?? 1;const widthCount = (width && this.getIndexNumValue(width)) ?? 1;@@ -88,7 +109,8 @@ export class Offset extends BaseFunction {const targetRowWithHeight = heightCount > 0 ? targetRow + heightCount - 1 : targetRow + heightCount + 1;const targetColumnWithWidth = widthCount > 0 ? targetColumn + widthCount - 1 : targetColumn + widthCount + 1;- if (targetRowWithHeight < 0 || targetColumnWithWidth < 0 || targetRowWithHeight > 1048576 || targetColumnWithWidth > 16384) {+ // Excel has a limit on the number of rows and columns: targetRow > 1048576 || targetColumn > 16384, Univer has no limit+ if (targetRowWithHeight < 0 || targetColumnWithWidth < 0) {return ErrorValueObject.create(ErrorType.REF);}@@ -104,20 +126,6 @@ export class Offset extends BaseFunction {endColumn,};- const unitId = (reference as ArrayValueObject).getUnitId();- const sheetId = (reference as ArrayValueObject).getSheetId();-- const rangeReferenceObject = new RangeReferenceObject(range, sheetId, unitId);-- return this._setDefault(rangeReferenceObject);- }-- private _setDefault(object: BaseReferenceObject) {- if (this.unitId == null || this.subUnitId == null) {- return ErrorValueObject.create(ErrorType.REF);- }- object.setDefaultUnitId(this.unitId);- object.setDefaultSheetId(this.subUnitId);- return object;+ return this.createReferenceObject(reference, range);}}diff --git a/packages/engine-formula/src/functions/text/text/__test__/index.spec.ts b/packages/engine-formula/src/functions/text/text/__test__/index.spec.tsindex e8fd6d895a..a9abe360d9 100644--- a/packages/engine-formula/src/functions/text/text/__test__/index.spec.ts+++ b/packages/engine-formula/src/functions/text/text/__test__/index.spec.ts@@ -19,7 +19,6 @@ import { describe, expect, it } from 'vitest';import { FUNCTION_NAMES_TEXT } from '../../function-names';import { Text } from '..';import { NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';-import type { ArrayValueObject } from '../../../../engine/value-object/array-value-object';import { transformToValue } from '../../../../engine/value-object/array-value-object';describe('Test text function', () => {@@ -31,8 +30,7 @@ describe('Test text function', () => {const formatText = StringValueObject.create('$#,##0.00');const result = textFunction.calculate(text1, formatText);const resultArray = result.getArrayValue();- expect(transformToValue(resultArray)).toStrictEqual([[111]]);- expect((result as ArrayValueObject).getFirstCell().getPattern()).toStrictEqual('$#,##0.00');+ expect(transformToValue(resultArray)).toStrictEqual([['$111.00']]);});});});diff --git a/packages/engine-formula/src/functions/text/text/index.ts b/packages/engine-formula/src/functions/text/text/index.tsindex 56cdbb18d1..c2ad4c59d2 100644--- a/packages/engine-formula/src/functions/text/text/index.ts+++ b/packages/engine-formula/src/functions/text/text/index.ts@@ -15,6 +15,7 @@*/import { ErrorType } from '../../../basics/error-type';+import { getFormatPreview } from '../../../basics/format';import { expandArrayValueObject } from '../../../engine/utils/array-object';import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';@@ -77,7 +78,9 @@ export class Text extends BaseFunction {const textValueNumber = textValue.getValue() as number;- return NumberValueObject.create(textValueNumber, formatTextValueString);+ const previewText = getFormatPreview(formatTextValueString, textValueNumber);++ return StringValueObject.create(previewText);});}}diff --git a/packages/engine-formula/src/index.ts b/packages/engine-formula/src/index.tsindex f80384f490..291a8fea26 100644--- a/packages/engine-formula/src/index.ts+++ b/packages/engine-formula/src/index.ts@@ -137,3 +137,6 @@ export { SetNumfmtFormulaDataMutation } from './commands/mutations/set-numfmt-foexport type { ISetNumfmtFormulaDataMutationParams } from './commands/mutations/set-numfmt-formula-data.mutation';export { isReferenceString } from './basics/regex';export { matchRefDrawToken } from './basics/match-token';+export { IDefinedNamesService, DefinedNamesService } from './services/defined-names.service';+export { IFormulaRuntimeService, FormulaRuntimeService } from './services/runtime.service';+export { IFormulaCurrentConfigService, FormulaCurrentConfigService } from './services/current-data.service';diff --git a/packages/sheets-formula/src/controllers/__tests__/create-command-test-bed.ts b/packages/sheets-formula/src/controllers/__tests__/create-command-test-bed.tsindex f9671f3def..9c6c5ed69f 100644--- a/packages/sheets-formula/src/controllers/__tests__/create-command-test-bed.ts+++ b/packages/sheets-formula/src/controllers/__tests__/create-command-test-bed.ts@@ -16,8 +16,8 @@import type { IWorkbookData, Workbook } from '@univerjs/core';import { ILogService, IUniverInstanceService, LocaleType, LogLevel, Plugin, PluginType, Univer } from '@univerjs/core';-import { LexerTreeBuilder } from '@univerjs/engine-formula';-import { SelectionManagerService } from '@univerjs/sheets';+import { CalculateFormulaService, DefinedNamesService, FormulaCurrentConfigService, FormulaDataModel, FormulaRuntimeService, IDefinedNamesService, IFormulaCurrentConfigService, IFormulaRuntimeService, LexerTreeBuilder } from '@univerjs/engine-formula';+import { SelectionManagerService, SheetInterceptorService } from '@univerjs/sheets';import type { Dependency } from '@wendellhu/redi';import { Inject, Injector } from '@wendellhu/redi';@@ -64,6 +64,8 @@ export function createCommandTestBed(workbookConfig?: IWorkbookData, dependencieclass TestPlugin extends Plugin {static override type = PluginType.Sheet;+ private _formulaDataModel: FormulaDataModel | null = null;+constructor(_config: undefined,@Inject(Injector) override readonly _injector: Injector@@ -73,10 +75,21 @@ export function createCommandTestBed(workbookConfig?: IWorkbookData, dependencieoverride onStarting(injector: Injector): void {injector.add([SelectionManagerService]);+ injector.add([SheetInterceptorService]);+ injector.add([CalculateFormulaService]);+ injector.add([FormulaDataModel]);injector.add([LexerTreeBuilder]);+ injector.add([IDefinedNamesService, { useClass: DefinedNamesService }]);+ injector.add([IFormulaRuntimeService, { useClass: FormulaRuntimeService }]);+ injector.add([IFormulaCurrentConfigService, { useClass: FormulaCurrentConfigService }]);dependencies?.forEach((d) => injector.add(d));}++ override onReady(): void {+ this._formulaDataModel = get(FormulaDataModel);+ this._formulaDataModel.initFormulaData();+ }}univer.registerPlugin(TestPlugin);diff --git a/packages/sheets-formula/src/controllers/__tests__/formula-auto-fill.controller.spec.ts b/packages/sheets-formula/src/controllers/__tests__/formula-auto-fill.controller.spec.tsindex 56297377e3..43eb338754 100644--- a/packages/sheets-formula/src/controllers/__tests__/formula-auto-fill.controller.spec.ts+++ b/packages/sheets-formula/src/controllers/__tests__/formula-auto-fill.controller.spec.ts@@ -30,7 +30,6 @@ import {SelectionManagerService,SetRangeValuesMutation,SetSelectionsOperation,- SheetInterceptorService,} from '@univerjs/sheets';import {AutoFillCommand,@@ -66,7 +65,6 @@ describe('Test auto fill with formula', () => {beforeEach(() => {const testBed = createCommandTestBed(undefined, [- [SheetInterceptorService],[ISelectionRenderService, { useClass: SelectionRenderService }],[AutoFillController],[IAutoFillService, { useClass: AutoFillService }],diff --git a/packages/sheets-formula/src/controllers/__tests__/update-formula.controller.spec.ts b/packages/sheets-formula/src/controllers/__tests__/update-formula.controller.spec.tsindex de7d79ea98..37932919ea 100644--- a/packages/sheets-formula/src/controllers/__tests__/update-formula.controller.spec.ts+++ b/packages/sheets-formula/src/controllers/__tests__/update-formula.controller.spec.ts@@ -14,14 +14,38 @@* limitations under the License.*/-import type { ICellData, IRange, Nullable, Univer } from '@univerjs/core';-import { ICommandService, IUniverInstanceService, RANGE_TYPE } from '@univerjs/core';-import { MoveRowsCommand, NORMAL_SELECTION_PLUGIN_NAME, SelectionManagerService } from '@univerjs/sheets';+import type { ICellData, IRange, IWorkbookData, Nullable, Univer } from '@univerjs/core';+import { Direction, ICommandService, IUniverInstanceService, LocaleType, RANGE_TYPE } from '@univerjs/core';+import type { IInsertColCommandParams } from '@univerjs/sheets';+import { InsertColCommand, MoveRowsCommand, NORMAL_SELECTION_PLUGIN_NAME, SelectionManagerService } from '@univerjs/sheets';import type { Injector } from '@wendellhu/redi';-import { afterEach, beforeEach, describe, it } from 'vitest';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import { SetArrayFormulaDataMutation, SetFormulaDataMutation, SetNumfmtFormulaDataMutation } from '@univerjs/engine-formula';+import { UpdateFormulaController } from '../update-formula.controller';import { createCommandTestBed } from './create-command-test-bed';+const TEST_WORKBOOK_DATA_DEMO = (): IWorkbookData => ({+ id: 'test',+ appVersion: '3.0.0-alpha',+ sheets: {+ sheet1: {+ id: 'sheet1',+ cellData: {+ 0: {+ 3: {+ f: '=A1:C1',+ },+ },+ },+ },+ },+ locale: LocaleType.ZH_CN,+ name: '',+ sheetOrder: [],+ styles: {},+});+const cellToRange = (row: number, col: number) =>({ startRow: row, endRow: row, startColumn: col, endColumn: col }) as IRange;// TODO@Dushusir: add move range,insert range,delete range test case@@ -35,14 +59,26 @@ describe('Test insert function operation', () => {endRow: number,endColumn: number) => Nullable<ICellData>;+ let getValues: (+ startRow: number,+ startColumn: number,+ endRow: number,+ endColumn: number+ ) => Array<Array<Nullable<ICellData>>> | undefined;beforeEach(() => {- const testBed = createCommandTestBed();+ const testBed = createCommandTestBed(TEST_WORKBOOK_DATA_DEMO(), [+ [UpdateFormulaController],+ ]);univer = testBed.univer;get = testBed.get;commandService = get(ICommandService);commandService.registerCommand(MoveRowsCommand);+ commandService.registerCommand(InsertColCommand);+ commandService.registerCommand(SetFormulaDataMutation);+ commandService.registerCommand(SetArrayFormulaDataMutation);+ commandService.registerCommand(SetNumfmtFormulaDataMutation);getValueByPosition = (startRow: number,@@ -55,6 +91,17 @@ describe('Test insert function operation', () => {?.getSheetBySheetId('sheet1')?.getRange(startRow, startColumn, endRow, endColumn).getValue();+ getValues = (+ startRow: number,+ startColumn: number,+ endRow: number,+ endColumn: number+ ): Array<Array<Nullable<ICellData>>> | undefined =>+ get(IUniverInstanceService)+ .getUniverSheetInstance('test')+ ?.getSheetBySheetId('sheet1')+ ?.getRange(startRow, startColumn, endRow, endColumn)+ .getValues();});afterEach(() => {@@ -87,6 +134,38 @@ describe('Test insert function operation', () => {await commandService.executeCommand(MoveRowsCommand.id, params);});+ it('Insert column', async () => {+ const selectionManager = get(SelectionManagerService);+ selectionManager.setCurrentSelection({+ pluginName: NORMAL_SELECTION_PLUGIN_NAME,+ unitId: 'test',+ sheetId: 'sheet1',+ });++ // A1+ selectionManager.add([+ {+ range: { startRow: 0, startColumn: 1, endRow: 0, endColumn: 1, rangeType: RANGE_TYPE.NORMAL },+ primary: null,+ style: null,+ },+ ]);++ const params: IInsertColCommandParams = {+ unitId: 'test',+ subUnitId: 'sheet1',+ range: cellToRange(0, 1),+ direction: Direction.LEFT,+ };++ // FXIME why InsertColCommand sequenceExecute returns result false+ await commandService.executeCommand(InsertColCommand.id, params);+ const oldValue = getValueByPosition(0, 3, 0, 3);+ expect(oldValue?.f).toBe('=A1:C1');++ const newValue = getValueByPosition(0, 4, 0, 4);+ // expect(newValue).toBe('=A1:D1');+ });});});});diff --git a/packages/sheets-formula/src/controllers/update-formula.controller.ts b/packages/sheets-formula/src/controllers/update-formula.controller.tsindex 54d1847644..7d9dea361a 100644--- a/packages/sheets-formula/src/controllers/update-formula.controller.ts+++ b/packages/sheets-formula/src/controllers/update-formula.controller.ts@@ -133,7 +133,7 @@ enum FormulaReferenceMoveType {InsertMoveDown, // rangeInsertMoveRight, // rangeSetName,- removeSheet,+ RemoveSheet,}interface IFormulaReferenceMoveParam {@@ -154,6 +154,17 @@ enum OriginRangeEdgeType {ALL,}+/**+ * Update formula process+ *+ * 1. Command intercepts, converts the command information to adapt refRange, offsets the formula content, and obtains the formula that requires offset content.+ *+ 2. Use refRange to offset the formula position and return undo/redo data to setRangeValues mutation+ - Redo data: Delete the old value at the old position on the match, and add the new value at the new position (the new value first checks whether the old position has offset content, if so, use the new offset content, if not, take the old value)+ - Undo data: the old position on the match saves the old value, and the new position is left blank++ 3. onCommandExecuted, before formula calculation, use the setRangeValues information to delete the old formulaData, ArrayFormula and ArrayFormulaCellData, and send the worker (complementary setRangeValues after collaborative conflicts, normal operation triggers formula update, undo/redo are captured and processed here)+ */@OnLifecycle(LifecycleStages.Ready, UpdateFormulaController)export class UpdateFormulaController extends Disposable {constructor(@@ -204,7 +215,7 @@ export class UpdateFormulaController extends Disposable {(command.params as IMutationCommonParams)?.trigger === UndoCommand.id ||(command.params as IMutationCommonParams)?.trigger === RedoCommand.id) {- this._handleRedoUndo(command);+ this._handleRedoUndo(command); // TODO: handle in set range values}}));@@ -399,6 +410,9 @@ export class UpdateFormulaController extends Disposable {result);+ // TODO@Dushusir: handle offset formula data+ // const {redos, undos} = refRangeFormula(oldFormulaData, newFormulaData, result);+const workbook = this._currentUniverService.getCurrentUniverSheetInstance();const unitId = workbook.getUnitId();const sheetId = workbook.getActiveSheet().getSheetId();@@ -444,7 +458,8 @@ export class UpdateFormulaController extends Disposable {oldFormulaData = offsetFormula(oldFormulaData, command, unitId, sheetId, selections);const offsetFormulaData = offsetFormula(formulaData, command, unitId, sheetId, selections);- // Synchronous to the worker thread+ // TODO@Dushusir: Here we take the redos incremental data,+ // Synchronously to the worker thread, and update the dependency cache.this._commandService.executeCommand(SetFormulaDataMutation.id, {formulaData: this._formulaDataModel.getFormulaData(),});@@ -699,7 +714,7 @@ export class UpdateFormulaController extends Disposable {const { unitId: workbookId, sheetId } = this._getCurrentSheetInfo();return {- type: FormulaReferenceMoveType.removeSheet,+ type: FormulaReferenceMoveType.RemoveSheet,unitId: unitId || workbookId,sheetId: subUnitId || sheetId,};@@ -780,12 +795,13 @@ export class UpdateFormulaController extends Disposable {unitSheetNameMap: IUnitSheetNameMap,formulaReferenceMoveParam: IFormulaReferenceMoveParam) {- if (!Tools.isDefine(formulaData)) return { newFormulaData: {}, refRanges: [] };+ if (!Tools.isDefine(formulaData)) return { newFormulaData: {}, oldFormulaData: {}, refRanges: [] };const formulaDataKeys = Object.keys(formulaData);- if (formulaDataKeys.length === 0) return { newFormulaData: {}, refRanges: [] };+ if (formulaDataKeys.length === 0) return { newFormulaData: {}, oldFormulaData: {}, refRanges: [] };+ const oldFormulaData: IFormulaData = {};const newFormulaData: IFormulaData = {};// Return all reference ranges. If the operation affects the reference range, you need to clear arrayFormulaRange and arrayFormulaCellData.@@ -800,6 +816,10 @@ export class UpdateFormulaController extends Disposable {const sheetDataKeys = Object.keys(sheetData);+ if (!Tools.isDefine(oldFormulaData[unitId])) {+ oldFormulaData[unitId] = {};+ }+if (!Tools.isDefine(newFormulaData[unitId])) {newFormulaData[unitId] = {};}@@ -807,6 +827,7 @@ export class UpdateFormulaController extends Disposable {for (const sheetId of sheetDataKeys) {const matrixData = new ObjectMatrix(sheetData[sheetId]);+ const oldFormulaDataItem = new ObjectMatrix<IFormulaDataItem>();const newFormulaDataItem = new ObjectMatrix<IFormulaDataItem>();matrixData.forValue((row, column, formulaDataItem) => {@@ -888,7 +909,7 @@ export class UpdateFormulaController extends Disposable {sheetName: newSheetName,unitId: sequenceUnitId,});- } else if (formulaReferenceMoveParam.type === FormulaReferenceMoveType.removeSheet) {+ } else if (formulaReferenceMoveParam.type === FormulaReferenceMoveType.RemoveSheet) {const {unitId: userUnitId,sheetId: userSheetId,@@ -930,6 +951,13 @@ export class UpdateFormulaController extends Disposable {const newSequenceNodes = this._updateRefOffset(sequenceNodes, refChangeIds, x, y);+ oldFormulaDataItem.setValue(row, column, {+ f: formulaString,+ x,+ y,+ si,+ });+newFormulaDataItem.setValue(row, column, {f: `=${generateStringWithSequence(newSequenceNodes)}`,x,@@ -938,13 +966,17 @@ export class UpdateFormulaController extends Disposable {});});+ if (oldFormulaData[unitId]) {+ oldFormulaData[unitId]![sheetId] = oldFormulaDataItem.getData();+ }+if (newFormulaData[unitId]) {newFormulaData[unitId]![sheetId] = newFormulaDataItem.getData();}}}- return { newFormulaData, refRanges };+ return { newFormulaData, oldFormulaData, refRanges };}private _getNewRangeByMoveParam(diff --git a/packages/sheets-formula/src/controllers/utils/ref-range-formula.ts b/packages/sheets-formula/src/controllers/utils/ref-range-formula.tsnew file mode 100644index 0000000000..698f3f1a3f--- /dev/null+++ b/packages/sheets-formula/src/controllers/utils/ref-range-formula.ts@@ -0,0 +1,135 @@+/**+ * 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 { IMutationInfo, IRange } from '@univerjs/core';+import { ObjectMatrix, Tools } from '@univerjs/core';+import type { IFormulaData } from '@univerjs/engine-formula';++export enum FormulaReferenceMoveType {+ MoveRange, // range+ MoveRows, // move rows+ MoveCols, // move columns+ InsertRow, // row+ InsertColumn, // column+ RemoveRow, // row+ RemoveColumn, // column+ DeleteMoveLeft, // range+ DeleteMoveUp, // range+ InsertMoveDown, // range+ InsertMoveRight, // range+ SetName,+ RemoveSheet,+}++export interface IFormulaReferenceMoveParam {+ type: FormulaReferenceMoveType;+ unitId: string;+ sheetId: string;+ range?: IRange;+ from?: IRange;+ to?: IRange;+ sheetName?: string;+}++/**+ * For different Command operations, it may be necessary to perform traversal in reverse or in forward order, so first determine the type of Command and then perform traversal.+ * @param oldFormulaData+ * @param newFormulaData+ * @param formulaReferenceMoveParam+ * @returns+ */+export function refRangeFormula(oldFormulaData: IFormulaData,+ newFormulaData: IFormulaData,+ formulaReferenceMoveParam: IFormulaReferenceMoveParam) {+ const type = formulaReferenceMoveParam.type;++ if (type === FormulaReferenceMoveType.SetName) {+ // TODO+ } else if (type === FormulaReferenceMoveType.RemoveSheet) {+ // TODO+ } else if (type === FormulaReferenceMoveType.MoveRange) {+ // TODO+ } else if (type === FormulaReferenceMoveType.MoveRows) {+ // TODO+ } else if (type === FormulaReferenceMoveType.MoveCols) {+ // TODO+ } else if (type === FormulaReferenceMoveType.InsertRow) {+ // TODO+ } else if (type === FormulaReferenceMoveType.InsertColumn) {+ return handleInsertCol(oldFormulaData, newFormulaData, formulaReferenceMoveParam);+ } else if (type === FormulaReferenceMoveType.RemoveRow) {+ // TODO+ } else if (type === FormulaReferenceMoveType.RemoveColumn) {+ // TODO+ } else if (type === FormulaReferenceMoveType.DeleteMoveLeft) {+ // TODO+ } else if (type === FormulaReferenceMoveType.DeleteMoveUp) {+ // TODO+ } else if (type === FormulaReferenceMoveType.InsertMoveDown) {+ // TODO+ } else if (type === FormulaReferenceMoveType.InsertMoveRight) {+ // TODO+ }+}++function handleInsertCol(oldFormulaData: IFormulaData,+ newFormulaData: IFormulaData,+ formulaReferenceMoveParam: IFormulaReferenceMoveParam) {+ const redos: IMutationInfo[] = [];+ const undos: IMutationInfo[] = [];++ const { type, unitId, sheetId, range, from, to } = formulaReferenceMoveParam;++ if (!Tools.isDefine(oldFormulaData)) {+ return {+ redos,+ undos,+ };+ }++ const formulaDataKeys = Object.keys(oldFormulaData);++ if (formulaDataKeys.length === 0) {+ return {+ redos,+ undos,+ };+ }++ for (const unitId of formulaDataKeys) {+ const sheetData = oldFormulaData[unitId];++ if (sheetData == null) {+ continue;+ }++ const sheetDataKeys = Object.keys(sheetData);+ for (const sheetId of sheetDataKeys) {+ const matrixData = new ObjectMatrix(sheetData[sheetId]);++ matrixData.forValue((row, column, formulaDataItem) => {+ if (!formulaDataItem) return true;++ const { f: formulaString, x, y, si } = formulaDataItem;+ });+ }+ }++ return {+ redos,+ undos,+ };+}diff --git a/packages/sheets-ui/src/commands/commands/remove-sheet-confirm.command.ts b/packages/sheets-ui/src/commands/commands/remove-sheet-confirm.command.tsindex 4a0050639d..ef5ffa2411 100644--- a/packages/sheets-ui/src/commands/commands/remove-sheet-confirm.command.ts+++ b/packages/sheets-ui/src/commands/commands/remove-sheet-confirm.command.ts@@ -33,7 +33,7 @@ export const RemoveSheetConfirmCommand: ICommand = {const commandService = accessor.get(ICommandService);const localeService = accessor.get(LocaleService);const result = await confirmService.confirm({- id: 'merge.confirm.add-worksheet-merge',+ id: 'sheet.confirm.remove-sheet',title: {title: localeService.t('sheetConfig.deleteSheet'),},diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 430ddc7a61..b132a9ed54 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -504,6 +504,9 @@ importers:big.js:specifier: ^6.2.1version: 6.2.1+ numfmt:+ specifier: ^2.5.2+ version: 2.5.2devDependencies:'@types/big.js':specifier: ^6.2.2