Coerce raw text input into a CellValue, following spreadsheet input-bar conventions: - blank (after trimming) clears the cell to a null literal; - text longer than one character beginning with = becomes a formula; -…
Coerce raw text input into a CellValue, following spreadsheet
input-bar conventions:
blank (after trimming) clears the cell to a null literal;
text longer than one character beginning with = becomes a formula;
in a number column a finite numeric string becomes a number literal;
in a date column a recognized date string (parseDateInput) becomes
its serial-number literal;
in a currency column a currency string (parseCurrencyInput) becomes
a plain number literal;
anything else is stored verbatim as a text literal (the untrimmed raw).
Shared by the grid's inline editor and any host-built formula bar, so input
parsing is identical everywhere instead of re-derived per consumer.
Package
@sheetwrite/core
Source
packages/core/src/cell-input.ts#L28
Declaration
functionparseCellInput(raw:string, type:CellFormattype CellFormat = "text" | "number" | "date" | "currency";typeCellFormat="text"|"number"|"date"|"currency";typeCellFormat=|"text"|"number"|"date"|"currency";How a column's cells are typed, parsed, and rendered: text verbatim, number via its numberFormat, date as an Excel-style serial (see date-serial.ts) rendered by a date numberFormat, and currency as a plain number rendered by a currency numberFormat (e.g. $#,##0.00).API reference →):CellValuetype CellValue =
| { kind: "literal"; value: CellScalar }
| { kind: "ref"; target: CellAddress }
| { kind: "formula"; src: string };typeCellValue=| { kind:"literal"; value:CellScalar }| { kind:"ref"; target:CellAddress }| { kind:"formula"; src:string };typeCellValue=| {kind:"literal";value:CellScalar;}| {kind:"ref";target:CellAddress;}| {kind:"formula";src:string;};A cell's persisted input: a literal, a cross-reference, or a formula. References resolve through the store's reference graph; formulas resolve in the WASM calculation engine.API reference →