UNPKG

hyperformula

Version:

HyperFormula is a JavaScript engine for efficient processing of spreadsheet-like data and formulas

50 lines (49 loc) 3.37 kB
/** * @license * Copyright (c) 2025 Handsoncode. All rights reserved. */ import { SimpleCellRange } from '../AbsoluteCellRange'; import { SimpleCellAddress } from '../Cell'; import { Maybe } from '../Maybe'; import { CellAddress } from './CellAddress'; import { ColumnAddress } from './ColumnAddress'; import { RowAddress } from './RowAddress'; export declare type SheetIndexMappingFn = (sheetIndex: number) => Maybe<string>; export declare type ResolveSheetReferenceFn = (sheetName: string) => Maybe<number>; /** * Computes R0C0 representation of cell address based on it's string representation and base address. * * @param {string} stringAddress - string representation of cell address, e.g., 'C64' * @param {SimpleCellAddress} baseAddress - base address for R0C0 conversion * @param {ResolveSheetReferenceFn} resolveSheetReference - mapping function needed to change name of a sheet to index * @returns {Maybe<CellAddress>} object representation of address or `undefined` if the sheet cannot be resolved */ export declare const cellAddressFromString: (stringAddress: string, baseAddress: SimpleCellAddress, resolveSheetReference: ResolveSheetReferenceFn) => Maybe<CellAddress>; export declare const columnAddressFromString: (stringAddress: string, baseAddress: SimpleCellAddress, resolveSheetReference: ResolveSheetReferenceFn) => Maybe<ColumnAddress>; export declare const rowAddressFromString: (stringAddress: string, baseAddress: SimpleCellAddress, resolveSheetReference: ResolveSheetReferenceFn) => Maybe<RowAddress>; /** * Computes simple (absolute) address of a cell address based on its string representation. * - If sheet name is present in the string representation but is not present in sheet mapping, returns `undefined`. * - If sheet name is not present in the string representation, returns {@param contextSheetId} as sheet number. * * @param {ResolveSheetReferenceFn} resolveSheetReference - mapping function needed to change name of a sheet to index * @param {string} stringAddress - string representation of cell address, e.g., 'C64' * @param {number} contextSheetId - sheet in context of which we should parse the address * @returns {Maybe<SimpleCellAddress>} absolute representation of address, e.g., { sheet: 0, col: 1, row: 1 } */ export declare const simpleCellAddressFromString: (resolveSheetReference: ResolveSheetReferenceFn, stringAddress: string, contextSheetId: number) => Maybe<SimpleCellAddress>; export declare const simpleCellRangeFromString: (resolveSheetReference: ResolveSheetReferenceFn, stringAddress: string, contextSheetId: number) => Maybe<SimpleCellRange>; /** * Returns string representation of absolute address * If sheet index is not present in sheet mapping, returns undefined */ export declare const simpleCellAddressToString: (sheetIndexMapping: SheetIndexMappingFn, address: SimpleCellAddress, sheetIndex: number) => Maybe<string>; export declare const simpleCellRangeToString: (sheetIndexMapping: SheetIndexMappingFn, address: SimpleCellRange, sheetIndex: number) => Maybe<string>; /** * Converts column index to label * * @param column - address to convert * @returns string representation, e.g., 'AAB' */ export declare function columnIndexToLabel(column: number): string; export declare function sheetIndexToString(sheetId: number, sheetMappingFn: SheetIndexMappingFn): Maybe<string>;