CSV and TSV are core-only. fromCsv projects input fields onto declared visible columns. Hidden declared columns initialize to null; extra fields are ignored and missing fields become null. It fully materializes the returned table.
Output and injection safety
toCsv follows the current view row order after sorting, filtering, hidden rows and collapsed groups. toTsv instead uses canonical data-space coordinates: reversed corners are normalized, and active views do not remap the range. TSV uses CRLF with no BOM and also injection-hardens values. Both synchronous writers fetch at most maxWriterWindowRows rows per packed store read, but still return one in-memory string.
CSV output is UTF-8 with a BOM and CRLF endings. For string values, a leading =, +, -, @, tab or CR is prefixed with a single quote. The value cannot reopen as an executable formula. For example, the string =1+1 exports as '=1+1, while a real formula cell exports its resolved scalar.
For the full setup, the CSV string is \uFEFFCustomer,Total\r\nAda,120\r\nLin,75 (BOM and line endings shown as escapes).
Clipboard formulas and references retain rich behavior only when copied/cut and pasted through the same live Sheetwrite grid controller. Payloads from another controller or application, including spreadsheet HTML, paste as injection-neutralized text. pasteValues uses resolved literals.
Options and edge cases
Delimited functions accept DelimitedTextOptions for bounded resources. See the API contract and the hostile-input lab. These plain-text formats do not carry workbook styles, formula source, names or multiple worksheets.
Built-in toolbar/context-menu download failures show an alert and emit export-error with { format: "csv", error }. See export error handling.
function fromCsv(text: string, columns: readonly Column[], options?: DelimitedTextOptions): ColumnarDatafunctionfromCsv(text:string,columns:readonlyColumn[],options?:DelimitedTextOptions,):ColumnarDatafunctionfromCsv(text:string,columns:readonlyColumn[],options?:DelimitedTextOptions,):ColumnarDataParse CSV into ColumnarData. The first record is consumed as a positional header. Input fields project onto declared visible columns; hidden declared columns are initialized to null, matching the visible-column CSV export. Extra fields are ignored and missing fields become null. The returned columnar table is fully materialized in memory.API reference →const data: ColumnarDataconstdata:ColumnarDataconstdata:ColumnarDataEager column-major values loaded into workbook.activeSheet; use instead of datasource.API reference →Column.key: stringinterfaceColumn {key:string;}interfaceColumn {key:string;}Non-empty key, unique within the sheet, used to map input and datasource values.API reference →Column.header: stringinterfaceColumn {header:string;}interfaceColumn {header:string;}Schema label used by table exports and data-grid presentation headers.API reference →Column.width: numberinterfaceColumn {width:number;}interfaceColumn {width:number;}Unzoomed column width in CSS pixels.API reference →Column.type: CellFormatinterfaceColumn {type:CellFormat;}interfaceColumn {type:CellFormat;}Controls cell input parsing and default value formatting for this column.API reference →var console: Consolevar console:Consolevar console:ConsoleConsole.log(...data: any[]): void (+1 overload)Console.log(...data: any[]): void (+1 overload)Console.log(...data: any[]): void (+1 overload)The console.log() static method outputs a message to the console. MDN ReferenceColumnarData.rowCount: numberinterfaceColumnarData {rowCount:number;}interfaceColumnarData {rowCount:number;}Row count for both in-memory and datasource-backed sheets.API reference →function downloadBytes(bytes: Uint8Array | string, filename: string, mime: string): voidfunctiondownloadBytes(bytes:Uint8Array|string,filename:string,mime:string,):voidfunctiondownloadBytes(bytes:Uint8Array|string,filename:string,mime:string,):voidTrigger a browser download from in-memory bytes. The temporary anchor is removed and its object URL is scheduled for revocation even when DOM append or click throws.API reference →function initSheetwrite(source?: BufferSource | URL | string | Request | WebAssembly.Module, engine?: SheetwriteEngine): Promise<void>functioninitSheetwrite(source?:BufferSource|URL|string|Request|WebAssembly.Module,engine?:SheetwriteEngine,):Promise<void>functioninitSheetwrite(source?:|BufferSource|URL|string|Request|WebAssembly.Module,engine?:SheetwriteEngine,):Promise<void>Load one WASM engine before createGrid. The default is @sheetwrite/wasm. Pass the @sheetwrite/formulas module as the second argument to select the full engine.Exampleimport { initSheetwrite } from"@sheetwrite/core";import*as formulas from"@sheetwrite/formulas";awaitinitSheetwrite(undefined, formulas);See also/docs/start/choose-an-engine/See alsocreateGridAPI reference →class SheetwriteStoreclassSheetwriteStoreclassSheetwriteStoreStable public facade and the sole transaction, epoch, policy, and event barrier.Exampleimport { initSheetwrite, SheetwriteStore, type Workbook } from"@sheetwrite/core";asyncfunctiontotal(workbook:Workbook) {awaitinitSheetwrite();conststore=newSheetwriteStore(workbook);try {return store.aggregate(workbook.activeSheet, 0, "sum");} finally {store.dispose();}}See alsoStore.aggregate *See alsocreateGridAPI reference →function toCsv(sheet: Sheet, store: Store, options?: DelimitedTextOptions): stringfunctiontoCsv(sheet:Sheet,store:Store,options?:DelimitedTextOptions,):stringfunctiontoCsv(sheet:Sheet,store:Store,options?:DelimitedTextOptions,):stringExport the current visible CSV view (UTF-8 BOM, CRLF): visible columns and view-ordered rows surviving sort, filter, hidden-row, and group state. String values beginning with = + - @ \t \r are prefixed with '. The synchronous API returns one in-memory string, but fetches at most maxWriterWindowRows view rows from the store per read.@throws {@link IncompleteDataError} before serialization when a paged sheet is incomplete.@throws {@link DelimitedTextResourceError} when a configured resource ceiling is exceeded.API reference →function toTsv(range: Range, store: Store, options?: DelimitedTextOptions): stringfunctiontoTsv(range:Range,store:Store,options?:DelimitedTextOptions,):stringfunctiontoTsv(range:Range,store:Store,options?:DelimitedTextOptions,):stringExport a canonical data-space range as clipboard-compatible TSV (CRLF, no BOM). Reversed corners are normalized; active sort and filter views do not remap the supplied row coordinates. Values are injection-hardened. The synchronous API returns one in-memory string and fetches at most maxWriterWindowRows canonical rows per packed store read.@throws {@link IncompleteDataError} before serialization when a paged sheet is incomplete.@throws {@link DelimitedTextResourceError} when a configured resource ceiling is exceeded.API reference →interface WorkbookinterfaceWorkbookinterfaceWorkbookLive workbook schema containing ordered sheets and the active sheet ID.API reference →const workbook: Workbookconstworkbook:Workbookconstworkbook:WorkbookLive workbook schema adopted by the store and updated by document operations.API reference →Workbook.activeSheet: stringinterfaceWorkbook {activeSheet:string;}interfaceWorkbook {activeSheet:string;}Active sheet ID and initial tab presented when the grid is created.API reference →Workbook.sheets: Sheet[]interfaceWorkbook {sheets:Sheet[];}interfaceWorkbook {sheets:Sheet[];}Sheets in display/tab order.API reference →Sheet.id: stringinterfaceSheet {id:string;}interfaceSheet {id:string;}Stable identifier, unique within the workbook and used by every cell address.API reference →Sheet.name: stringinterfaceSheet {name:string;}interfaceSheet {name:string;}User-facing sheet name shown in tabs and workbook exports.API reference →Sheet.rowCount: numberinterfaceSheet {rowCount:number;}interfaceSheet {rowCount:number;}Row count for both in-memory and datasource-backed sheets.API reference →Sheet.columns: Column[]interfaceSheet {columns:Column[];}interfaceSheet {columns:Column[];}Ordered schema; array positions are the zero-based column coordinates.API reference →const store: SheetwriteStoreconststore:SheetwriteStoreconststore:SheetwriteStoreAPI reference →new SheetwriteStore(workbook: Workbook, data?: ColumnarData, options?: SheetwriteStoreOptions): SheetwriteStorenewSheetwriteStore(workbook: Workbook, data?: ColumnarData, options?: SheetwriteStoreOptions): SheetwriteStorenewSheetwriteStore(workbook: Workbook, data?: ColumnarData, options?: SheetwriteStoreOptions): SheetwriteStoreStable public facade and the sole transaction, epoch, policy, and event barrier.Exampleimport { initSheetwrite, SheetwriteStore, type Workbook } from"@sheetwrite/core";asyncfunctiontotal(workbook:Workbook) {awaitinitSheetwrite();conststore=newSheetwriteStore(workbook);try {return store.aggregate(workbook.activeSheet, 0, "sum");} finally {store.dispose();}}See alsoStore.aggregate *See alsocreateGridAPI reference →ColumnarData.columns: Record<string, ArrayLike<CellScalar | CellValue>>interfaceColumnarData {columns:Record<string, ArrayLike<CellScalar|CellValue>>;}interfaceColumnarData {columns:Record<string,ArrayLike<CellScalar|CellValue>>;}Exact column runs represented by every returned row.API reference →customer: string[]let customer:string[]let customer:string[]total: Float64Array<ArrayBuffer>let total:Float64Array<ArrayBuffer>let total:Float64Array<ArrayBuffer>var Float64Array: Float64ArrayConstructor
new (elements: Iterable<number>) => Float64Array<ArrayBuffer> (+6 overloads)var Float64Array:Float64ArrayConstructornew (elements:Iterable<number>) =>Float64Array<ArrayBuffer> (+6 overloads)var Float64Array:Float64ArrayConstructornew (elements:Iterable<number>) =>Float64Array<ArrayBuffer> (+6 overloads)const sheet: Sheetconstsheet:Sheetconstsheet:SheetSheet identity used by the simple data-first adapter. Defaults to sheet1.API reference →var Error: ErrorConstructor
new (message?: string, options?: ErrorOptions) => Error (+2 overloads)var Error:ErrorConstructornew (message?:string, options?:ErrorOptions) =>Error (+2 overloads)var Error:ErrorConstructornew (message?:string, options?:ErrorOptions) =>Error (+2 overloads)const csv: stringconstcsv:stringconstcsv:stringconst tsv: stringconsttsv:stringconsttsv:stringRange.sheet: stringinterfaceRange {sheet:string;}interfaceRange {sheet:string;}Sheet identity used by the simple data-first adapter. Defaults to sheet1.API reference →Range.start: {
row: number;
col: number;
}interfaceRange {start: {row:number;col:number;};}interfaceRange {start: {row:number;col:number;};}Zero-based workbook column index of the first key.API reference →row: numberlet row:numberlet row:number0-based row of the cell that holds the top-left corner.API reference →col: numberlet col:numberlet col:number0-based column of the cell that holds the top-left corner.API reference →Range.end: {
row: number;
col: number;
}interfaceRange {end: {row:number;col:number;};}interfaceRange {end: {row:number;col:number;};}Exclusive workbook column index after the last key.API reference →