|
| 1 | +import { HyperFormula } from '../../../src' |
1 | 2 | import {CellError, ErrorType} from '../../../src/Cell'
|
2 | 3 | import {Config} from '../../../src/Config'
|
| 4 | +import { SheetMapping } from '../../../src/DependencyGraph' |
3 | 5 | import {ErrorMessage} from '../../../src/error-message'
|
| 6 | +import { buildTranslationPackage } from '../../../src/i18n' |
| 7 | +import { enUS } from '../../../src/i18n/languages' |
4 | 8 | import {AstNodeType, CellAddress, CellRangeAst, CellReferenceAst, ErrorAst} from '../../../src/parser'
|
5 | 9 | import {adr} from '../testUtils'
|
6 | 10 | import {buildEmptyParserWithCaching} from './common'
|
@@ -175,4 +179,24 @@ describe('Parser - OFFSET to reference translation', () => {
|
175 | 179 | expect(ast.type).toBe(AstNodeType.CELL_REFERENCE)
|
176 | 180 | expect(ast.reference).toEqual(CellAddress.relative(4, 13))
|
177 | 181 | })
|
| 182 | + |
| 183 | + it('parser returns address with a sheet reference', () => { |
| 184 | + const sheetMapping = new SheetMapping(buildTranslationPackage(enUS)) |
| 185 | + sheetMapping.addSheet('Sheet1') |
| 186 | + sheetMapping.addSheet('Sheet2') |
| 187 | + const parser = buildEmptyParserWithCaching(new Config(), sheetMapping) |
| 188 | + |
| 189 | + const ast = parser.parse('=OFFSET(Sheet1!A1, 0, 0)', adr('A1', 1)).ast as CellReferenceAst |
| 190 | + expect(ast.type).toBe(AstNodeType.CELL_REFERENCE) |
| 191 | + expect(ast.reference).toEqual(CellAddress.relative(0, 0, 0)) |
| 192 | + }) |
| 193 | + |
| 194 | + it('function OFFSET can reference a different sheet', () => { |
| 195 | + const engine = HyperFormula.buildFromSheets({ |
| 196 | + Sheet1: [['sheet1']], |
| 197 | + Sheet2: [['sheet2', '=OFFSET(Sheet1!A1, 0, 0)']], |
| 198 | + }) |
| 199 | + |
| 200 | + expect(engine.getCellValue(adr('B1', engine.getSheetId('Sheet2')))).toEqual('sheet1') |
| 201 | + }) |
178 | 202 | })
|
0 commit comments