UNPKG

@sheetxl/models

Version:

Models - A Headless javascript spreadsheet library.

105 lines 4.64 kB
import { FixableCellRangeCoords, FixableCellCoords, CellRangeCoords, CellCoords } from "@sheetxl/common"; import { CellCoordsAddress, CellRangeCoordsAddress } from "../cell"; import { SheetCellRangeCoords, SheetCellRangeCoordsAddress } from "./SheetCellRange"; /** * Regex for range. * regex doesn't catch trailing ':' */ export declare const REGEX_CELL_RANGE: RegExp; export declare const REGEX_LITERAL_ARRAY: RegExp; /** * A string value that represents an invalid reference */ export declare const STRING_INVALID_REF = "#REF!"; /** @hidden */ export declare const MESSAGE_ERROR_NO_COORDS = "Must specify a coords"; /** @hidden */ export declare const MESSAGE_ERROR_NO_RANGE = "Must specify a range"; /** @hidden */ export declare const MESSAGE_ERROR_INVALID_ADDRESS: (address?: CellCoordsAddress) => string; /** @hidden */ export declare const MESSAGE_ERROR_INVALID_RANGE = "Invalid range."; /** @hidden */ export declare const MESSAGE_ERROR_INVALID_RANGE_ADDRESS: (address: string) => string; /** @hidden */ export declare const MESSAGE_ERROR_INVALID_RANGE_RELATIVE: (address: string) => string; /** @hidden */ export declare const ERROR_INVALID_REF: () => never; export declare const encodeRow: (row: number, isFixed?: boolean) => string; export declare const encodeCol: (col: number, isFixed?: boolean) => string; /** * Decodes a cell address into a row and column index * @param address * @param allow1D * @returns */ export declare const decodeAddress: (address: string, allow1D?: boolean) => Partial<FixableCellCoords>; /** * * @param address Return just a single cell for the address. * @returns */ export declare const decodeCellAddress: (address: string) => FixableCellCoords; /** * Return a string for a given cell address. * @param coords. * @returns */ export declare const encodeCellAddress: (coords: FixableCellCoords) => string; /** * This doesn't fail but will return null if unable to parse * The second argument is the default range use for bounds that may be specified * for example the max row or max column in a row/column header ('A:C') * @remarks * R1C1 parsing is not yet implemented. */ export declare const decodeRangeAddress: (address: string, defaultRange?: CellRangeCoords, allowR1C1?: boolean) => FixableCellRangeCoords; export declare const decodeRangeAddresses: (addresses: CellRangeCoordsAddress | CellRangeCoordsAddress[], defaultRange: CellRangeCoords) => CellRangeCoords[]; /** * Encodes an address as a a1 style string with a from:to. * @remarks * If a defaultRange is provided then this will allow for row/column ranges * @param address * @param defaultRange * @returns */ export declare const encodeRangeAddress: (range: Partial<FixableCellRangeCoords>, defaultRange?: CellRangeCoords) => string; /** * This doesn't fail but will return null if unable to parse */ export declare const decodeSheetAddress: (address: string, defaultRange?: SheetCellRangeCoords, allowR1C1?: boolean) => SheetCellRangeCoords; /** * Encodes an address as a a1 style string with a sheetName!from:to */ export declare const encodeSheetAddress: (address: Partial<SheetCellRangeCoords>, defaultRange?: SheetCellRangeCoords) => string; /** * Support for converting an array of sheet ranges into a string. */ export declare const encodeSheetAddresses: (addresses: Partial<SheetCellRangeCoords>[], defaultRange?: SheetCellRangeCoords) => string; export declare const decodeSheetAddresses: (addresses: SheetCellRangeCoordsAddress | SheetCellRangeCoordsAddress[], defaultRange?: SheetCellRangeCoords, allowR1C1?: boolean) => SheetCellRangeCoords[]; /** * This is a very fast way to decode cells but has no error checking. * If does not support fixed cells, sheets, or partials. This is useful * for reading from save strings */ export declare const fastDecodeCell: (address: string) => CellCoords; /** * This is a very fast way to decode ranges but has no error checking. * If does not support fixed cells, sheets, or partials. This is useful * for reading from save strings */ export declare const fastDecodeCellRange: (address: string) => CellRangeCoords; /** * Return true is the string is a valid format for a cell address. * @param address * @returns boolean */ export declare const validateCellCoordsString: (address: string) => boolean; /** * Return true is the string is a valid format for a cell range. * @param address * @returns boolean */ export declare const validateCellCoordsRangeString: (address: string) => boolean; export declare const rangeArrayToStringArray: (ranges: CellRangeCoords[]) => string[] | undefined; //# sourceMappingURL=AddressUtils.d.ts.map