@@ -68,6 +68,18 @@ describe('Parser - OFFSET to reference translation', () => {
6868 expect ( ast . end ) . toEqual ( CellAddress . relative ( 8 , 13 ) )
6969 } )
7070
71+ it ( 'OFFSET parsing into cell range in different sheet' , ( ) => {
72+ const sheetMapping = new SheetMapping ( buildTranslationPackage ( enUS ) )
73+ sheetMapping . addSheet ( 'Sheet1' )
74+ sheetMapping . addSheet ( 'Sheet2' )
75+ const parser = buildEmptyParserWithCaching ( new Config ( ) , sheetMapping )
76+
77+ const ast = parser . parse ( '=OFFSET(Sheet2!F16, 0, 2, 1, 3)' , adr ( 'B3' , 0 ) ) . ast as CellRangeAst
78+ expect ( ast . type ) . toBe ( AstNodeType . CELL_RANGE )
79+ expect ( ast . start ) . toEqual ( CellAddress . relative ( 6 , 13 , 1 ) )
80+ expect ( ast . end ) . toEqual ( CellAddress . relative ( 8 , 13 , 1 ) )
81+ } )
82+
7183 it ( 'OFFSET first argument need to be reference' , ( ) => {
7284 const parser = buildEmptyParserWithCaching ( new Config ( ) )
7385
@@ -186,9 +198,9 @@ describe('Parser - OFFSET to reference translation', () => {
186198 sheetMapping . addSheet ( 'Sheet2' )
187199 const parser = buildEmptyParserWithCaching ( new Config ( ) , sheetMapping )
188200
189- const ast = parser . parse ( '=OFFSET(Sheet1 !A1, 0, 0)' , adr ( 'A1' , 1 ) ) . ast as CellReferenceAst
201+ const ast = parser . parse ( '=OFFSET(Sheet2 !A1, 0, 0)' , adr ( 'A1' , 0 ) ) . ast as CellReferenceAst
190202 expect ( ast . type ) . toBe ( AstNodeType . CELL_REFERENCE )
191- expect ( ast . reference ) . toEqual ( CellAddress . relative ( 0 , 0 , 0 ) )
203+ expect ( ast . reference ) . toEqual ( CellAddress . relative ( 0 , 0 , 1 ) )
192204 } )
193205
194206 it ( 'function OFFSET can reference a different sheet' , ( ) => {
0 commit comments