diff --git a/packages/engine-formula/src/engine/analysis/__tests__/lexer-tree-builder.spec.ts b/packages/engine-formula/src/engine/analysis/__tests__/lexer-tree-builder.spec.ts index 0ac04d4f9a1..376ec05f06d 100644 --- a/packages/engine-formula/src/engine/analysis/__tests__/lexer-tree-builder.spec.ts +++ b/packages/engine-formula/src/engine/analysis/__tests__/lexer-tree-builder.spec.ts @@ -714,5 +714,13 @@ describe('lexer nodeMaker test', () => { const result = lexerTreeBuilder.moveFormulaRefOffset('=sum(A$1:B$3)', 1, 1, true); expect(result).toStrictEqual('=sum(B$2:C$4)'); }); + + it('sheet name quote', () => { + let result = lexerTreeBuilder.moveFormulaRefOffset("= 'dv-test'!F26", 0, 1, true); + expect(result).toStrictEqual("= 'dv-test'!F27"); + + result = lexerTreeBuilder.moveFormulaRefOffset("=SUM( 'dv-test'!F26)", 0, 1, true); + expect(result).toStrictEqual("=SUM( 'dv-test'!F27)"); + }); }); }); diff --git a/packages/engine-formula/src/engine/analysis/lexer-tree-builder.ts b/packages/engine-formula/src/engine/analysis/lexer-tree-builder.ts index 2e4d888191d..c9e3e4a0c2b 100644 --- a/packages/engine-formula/src/engine/analysis/lexer-tree-builder.ts +++ b/packages/engine-formula/src/engine/analysis/lexer-tree-builder.ts @@ -1446,6 +1446,13 @@ export class LexerTreeBuilder extends Disposable { } else if (currentString === matchToken.SINGLE_QUOTATION && this.isDoubleQuotationClose()) { if (this.isSingleQuotationClose()) { this._openSingleQuotation(); + + // If the current segment is blank, reset the segment. + // Process the space before the double single quotes of sheet name. + // e.g. = 'dv-test'!C27 + if (this._segmentCount() === 0) { + this._resetSegment(); + } } else { const nextCurrentString = formulaStringArray[cur + 1]; if (nextCurrentString && nextCurrentString === matchToken.SINGLE_QUOTATION) {