API reference
Coordinates & ranges
A1 ↔ row/col conversion, range parsing, EMU and date helpers.
Coordinate
src/utils/coordinate.ts# boundariesToRangeString function
src/utils/coordinate.ts:294Inverse of rangeBoundaries for the rectangular case.
function boundariesToRangeString(b: CellRangeBoundaries): stringParameters
| Name | Type | Description |
|---|---|---|
b | CellRangeBoundaries |
Returns
string
# columnIndexFromLetter function
src/utils/coordinate.ts:45Column letter → 1-based column index. Case-insensitive but at most 3 letters (the spec ceiling). Throws on empty / non-A-Z / over-range.
function columnIndexFromLetter(letter: string): numberParameters
| Name | Type | Description |
|---|---|---|
letter | string |
Returns
number
# columnLetterFromIndex function
src/utils/coordinate.ts:241-based column index → spreadsheet column letter ("A", "Z", "AA", "XFD"). Throws OpenXmlSchemaError when out of range.
function columnLetterFromIndex(n: number): stringParameters
| Name | Type | Description |
|---|---|---|
n | number |
Returns
string
# coordinateFromString function
src/utils/coordinate.ts:103Parse a single-cell coordinate string ("A1", "$XFD$1048576") into its column letter (always uppercased) and 1-based row.
function coordinateFromString(coord: string): CellCoordinateParameters
| Name | Type | Description |
|---|---|---|
coord | string |
Returns
CellCoordinate
# coordinateToTuple function
src/utils/coordinate.ts:122Same as coordinateFromString but returning the column as its 1-based numeric index. Thin convenience for the worksheet read path.
function coordinateToTuple(coord: string): CellCoordinateNumericParameters
| Name | Type | Description |
|---|---|---|
coord | string |
Returns
CellCoordinateNumeric
# formatSheetQualifiedRef function
src/utils/coordinate.ts:333Inverse of parseSheetRange: format a sheet title + range (or single-cell ref) as `Sheet1!A1` or `'Quarter 1'!A1` per Excel's sheet-qualified syntax. Single quotes inside the title are escaped by doubling (`'Bob''s Sheet'`). Quoting rule: sheet titles consisting only of `[A-Za-z_][A-Za-z0-9_]*` are emitted bare; everything else (spaces, digits-leading, hyphens, apostrophes, punctuation…) gets wrapped in single quotes.
function formatSheetQualifiedRef(sheet: string, ref: string): stringParameters
| Name | Type | Description |
|---|---|---|
sheet | string | |
ref | string |
Returns
string
# isValidCellRef function
src/utils/coordinate.ts:142Predicate: true iff `s` is a valid single-cell A1 coordinate (`"A1"`, `"XFD1048576"`). Strings with `$` absolute markers, surrounding whitespace, ranges (`A1:B2`), or out-of-bound row / column return false. Useful for sanitising user input before passing to coordinateToTuple or `setCellByCoord`.
function isValidCellRef(s: unknown): s is stringParameters
| Name | Type | Description |
|---|---|---|
s | unknown |
Returns
s is string
# isValidColumnLetter function
src/utils/coordinate.ts:211Predicate: true iff `s` is a valid 1..3-char column letter (`"A"` through `"XFD"`, case-insensitive). Empty / over-long / out-of-bound / non-string fails.
function isValidColumnLetter(s: unknown): s is stringParameters
| Name | Type | Description |
|---|---|---|
s | unknown |
Returns
s is string
# isValidColumnNumber function
src/utils/coordinate.ts:230Predicate: true iff `n` is a valid 1-based column index in `[1, 16384]`. Non-finite / non-integer / out-of-bound fails.
function isValidColumnNumber(n: unknown): n is numberParameters
| Name | Type | Description |
|---|---|---|
n | unknown |
Returns
n is number
# isValidRangeRef function
src/utils/coordinate.ts:162Predicate: true iff `s` is a valid A1-style range expression — single cell, two-corner range, whole column (`A:A`), or whole row (`1:1`). `$` markers, whitespace, and out-of-bound bounds fail. Sanity-check before rangeBoundaries / `parseRange`.
function isValidRangeRef(s: unknown): s is stringParameters
| Name | Type | Description |
|---|---|---|
s | unknown |
Returns
s is string
# isValidRowNumber function
src/utils/coordinate.ts:222Predicate: true iff `n` is a valid 1-based row index in `[1, 1048576]`. Non-finite / non-integer / out-of-bound fails.
function isValidRowNumber(n: unknown): n is numberParameters
| Name | Type | Description |
|---|---|---|
n | unknown |
Returns
n is number
# parseSheetRange function
src/utils/coordinate.ts:306Parse a sheet-qualified range ("Sheet1!A1:B5" / "'Quarter 1'!A1"). Sheet names with single quotes inside use SQL-style doubling ("'Bob''s Sheet'!A1") — we unescape on the way out.
function parseSheetRange(input: string): { bounds: CellRangeBoundaries; range: string; sheet: string }Parameters
| Name | Type | Description |
|---|---|---|
input | string |
Returns
{ bounds: CellRangeBoundaries; range: string; sheet: string }
# rangeBoundaries function
src/utils/coordinate.ts:239Parse "A1:B5" / "A:A" / "1:1" / single-cell into 1-based (minCol, minRow, maxCol, maxRow). Whole-column ranges fill rows to [1, MAX_ROW]; whole-row ranges fill cols to [1, MAX_COL].
function rangeBoundaries(range: string): CellRangeBoundariesParameters
| Name | Type | Description |
|---|---|---|
range | string |
Returns
CellRangeBoundaries
# tupleToCoordinate function
src/utils/coordinate.ts:128Compose `"A1"` from a 1-based (col, row).
function tupleToCoordinate(col: number, row: number): stringParameters
| Name | Type | Description |
|---|---|---|
col | number | |
row | number |
Returns
string
# MAX_COL const
src/utils/coordinate.ts:11Maximum column index Excel accepts (XFD).
const MAX_COL: 16384# MAX_ROW const
src/utils/coordinate.ts:13Maximum row index Excel accepts.
const MAX_ROW: 1048576Units
src/utils/units.ts# cmFromEmu function
src/utils/units.ts:30function cmFromEmu(emu: number): numberParameters
| Name | Type | Description |
|---|---|---|
emu | number |
Returns
number
# emuFromCm function
src/utils/units.ts:27function emuFromCm(cm: number): numberParameters
| Name | Type | Description |
|---|---|---|
cm | number |
Returns
number
# emuFromInch function
src/utils/units.ts:36function emuFromInch(inch: number): numberParameters
| Name | Type | Description |
|---|---|---|
inch | number |
Returns
number
# emuFromPoint function
src/utils/units.ts:45function emuFromPoint(pt: number): numberParameters
| Name | Type | Description |
|---|---|---|
pt | number |
Returns
number
# emuFromPx function
src/utils/units.ts:18function emuFromPx(px: number): numberParameters
| Name | Type | Description |
|---|---|---|
px | number |
Returns
number
# inchFromEmu function
src/utils/units.ts:39function inchFromEmu(emu: number): numberParameters
| Name | Type | Description |
|---|---|---|
emu | number |
Returns
number
# pixelToPoint function
src/utils/units.ts:57function pixelToPoint(px: number, dpi?: number): numberParameters
| Name | Type | Description |
|---|---|---|
px | number | |
dpi? = DEFAULT_PIXEL_DPI | number |
Returns
number
# pointFromEmu function
src/utils/units.ts:48function pointFromEmu(emu: number): numberParameters
| Name | Type | Description |
|---|---|---|
emu | number |
Returns
number
# pointToPixel function
src/utils/units.ts:54function pointToPixel(pt: number, dpi?: number): numberParameters
| Name | Type | Description |
|---|---|---|
pt | number | |
dpi? = DEFAULT_PIXEL_DPI | number |
Returns
number
# pxFromEmu function
src/utils/units.ts:21function pxFromEmu(emu: number): numberParameters
| Name | Type | Description |
|---|---|---|
emu | number |
Returns
number
# EMU_PER_CM const
src/utils/units.ts:9const EMU_PER_CM: 360000# EMU_PER_INCH const
src/utils/units.ts:8const EMU_PER_INCH: 914400# EMU_PER_PIXEL const
src/utils/units.ts:10const EMU_PER_PIXEL: 9525# EMU_PER_POINT const
src/utils/units.ts:11const EMU_PER_POINT: 12700Cell range
src/worksheet/cell-range.ts# expandRangeStr function
src/worksheet/cell-range.ts:176Expand (or shrink) an A1 range by adding `deltaRows` to its bottom edge and `deltaCols` to its right edge. The top-left corner is preserved. Negative deltas shrink the range; the result must still have at least 1 row and 1 column (otherwise throws). Useful for "this is the data range — also reserve room for a totals row" or "include one more column to the right" patterns.
function expandRangeStr(range: string, deltaRows: number, deltaCols: number): stringParameters
| Name | Type | Description |
|---|---|---|
range | string | |
deltaRows | number | |
deltaCols | number |
Returns
string
# intersectionRange function
src/worksheet/cell-range.ts:217Returns the rectangular intersection of two ranges, or `null` when disjoint.
function intersectionRange(a: CellRangeBoundaries, b: CellRangeBoundaries): CellRangeBoundaries | nullParameters
| Name | Type | Description |
|---|---|---|
a | CellRangeBoundaries | |
b | CellRangeBoundaries |
Returns
CellRangeBoundaries | null
# isCellInRange function
src/worksheet/cell-range.ts:95A1-string convenience for rangeContainsCell. Parses `cellRef` (e.g. `"B3"`) and `rangeRef` (e.g. `"A1:C5"`) and returns `true` iff the cell sits inside the range (boundary-inclusive). Throws when either input is malformed.
function isCellInRange(cellRef: string, rangeRef: string): booleanParameters
| Name | Type | Description |
|---|---|---|
cellRef | string | |
rangeRef | string |
Returns
boolean
# isRangeInRange function
src/worksheet/cell-range.ts:106A1-string convenience for rangeContainsRange. Returns `true` iff the `inner` range is wholly contained by `outer` (boundary-inclusive). Single-cell refs are accepted on either side via parseRange. Throws on malformed input.
function isRangeInRange(inner: string, outer: string): booleanParameters
| Name | Type | Description |
|---|---|---|
inner | string | |
outer | string |
Returns
boolean
# rangeArea function
src/worksheet/cell-range.ts:232Inclusive cell count covered by a range.
function rangeArea(r: CellRangeBoundaries): numberParameters
| Name | Type | Description |
|---|---|---|
r | CellRangeBoundaries |
Returns
number
# rangeContainsCell function
src/worksheet/cell-range.ts:86Inclusive containment of a single (row, col) within a range.
function rangeContainsCell(r: CellRangeBoundaries, row: number, col: number): booleanParameters
| Name | Type | Description |
|---|---|---|
r | CellRangeBoundaries | |
row | number | |
col | number |
Returns
boolean
# rangeContainsRange function
src/worksheet/cell-range.ts:185Inclusive containment of `inner` within `outer`.
function rangeContainsRange(outer: CellRangeBoundaries, inner: CellRangeBoundaries): booleanParameters
| Name | Type | Description |
|---|---|---|
outer | CellRangeBoundaries | |
inner | CellRangeBoundaries |
Returns
boolean
# rangesOverlap function
src/worksheet/cell-range.ts:227True iff two ranges share at least one cell.
function rangesOverlap(a: CellRangeBoundaries, b: CellRangeBoundaries): booleanParameters
| Name | Type | Description |
|---|---|---|
a | CellRangeBoundaries | |
b | CellRangeBoundaries |
Returns
boolean
# shiftRange function
src/worksheet/cell-range.ts:199Shift a range by (dr, dc) integer offsets. The returned range is clamped to the OOXML grid; callers that want hard bounds should pass values that keep the result inside the spec.
function shiftRange(r: CellRangeBoundaries, dr: number, dc: number): CellRangeBoundariesParameters
| Name | Type | Description |
|---|---|---|
r | CellRangeBoundaries | |
dr | number | |
dc | number |
Returns
CellRangeBoundaries
# unionRange function
src/worksheet/cell-range.ts:207Bounding-box union of two ranges. Always non-null.
function unionRange(a: CellRangeBoundaries, b: CellRangeBoundaries): CellRangeBoundariesParameters
| Name | Type | Description |
|---|---|---|
a | CellRangeBoundaries | |
b | CellRangeBoundaries |
Returns
CellRangeBoundaries
Datetime
src/utils/datetime.ts# dateToExcel function
src/utils/datetime.ts:58Convert a JS `Date` into an Excel serial. The Date is read in UTC. On Windows 1900, dates ≤ 1900-02-28 get a -1 day correction to account for Excel's phantom leap day.
function dateToExcel(date: Date, opts?: { epoch?: ExcelEpoch }): numberParameters
| Name | Type | Description |
|---|---|---|
date | Date | |
opts? | { epoch?: ExcelEpoch } |
Returns
number
# durationToExcel function
src/utils/datetime.ts:81Milliseconds → Excel duration serial (fraction of a day).
function durationToExcel(ms: number): numberParameters
| Name | Type | Description |
|---|---|---|
ms | number |
Returns
number
# excelToDate function
src/utils/datetime.ts:38Convert an Excel serial date into a JS `Date` (UTC). The fractional part is treated as a fraction of a day. For Windows 1900 the leap-bug compensation kicks in for serials in [0, 60).
function excelToDate(serial: number, opts?: { epoch?: ExcelEpoch }): DateParameters
| Name | Type | Description |
|---|---|---|
serial | number | |
opts? | { epoch?: ExcelEpoch } |
Returns
Date
# excelToDuration function
src/utils/datetime.ts:73Excel duration serial (fraction of a day) → milliseconds.
function excelToDuration(serial: number): numberParameters
| Name | Type | Description |
|---|---|---|
serial | number |
Returns
number
# fromIso8601 function
src/utils/datetime.ts:95Parse an ISO-8601 / W3CDTF datetime string into a `Date`. Same grammar as `new Date(string)`; the wrapper just adds typed error reporting and a stricter "must be a recognised ISO" guard.
function fromIso8601(s: string): DateParameters
| Name | Type | Description |
|---|---|---|
s | string |
Returns
Date
# toIso8601 function
src/utils/datetime.ts:111Format a `Date` as ISO-8601 with second precision in UTC. Trims the millisecond fragment that `Date.toISOString()` always produces, so the output matches Excel / openpyxl's W3CDTF style.
function toIso8601(d: Date): stringParameters
| Name | Type | Description |
|---|---|---|
d | Date |
Returns
string
# MAC_EPOCH_MS const
src/utils/datetime.ts:251904-01-01 (UTC) — the Mac / 1904-system epoch in ms.
const MAC_EPOCH_MS: number# WINDOWS_EPOCH_MS const
src/utils/datetime.ts:231899-12-30 (UTC) — the Windows / 1900-system epoch in ms.
const WINDOWS_EPOCH_MS: number