Skip to content
Data TableAPI Reference

Excel XLSX

comins-table@0.2.2Framework neutral

comins-table/xlsx is a separate entry for ordinary-row Excel import/export. File selection, downloads and Worker execution belong to the application; APIs accept or return bytes only.

import { inspectCominsXlsx, importCominsRowsFromXlsx, exportCominsRowsToXlsx } from 'comins-table/xlsx';
const bytes = await exportCominsRowsToXlsx({
rows: [{ id: '001', amount: 120 }],
columns: [{ id: 'id', value: row => row.id }, { id: 'amount', value: row => row.amount }],
sheetName: 'Data',
styles: { theme: 'comins', columns: { amount: { width: 16, body: { format: '#,##0', align: 'right' } } } },
});
const workbook = await inspectCominsXlsx({ bytes });
const rows = await importCominsRowsFromXlsx({
bytes, sheetName: 'Data', hasHeader: true,
mapRow: ({ cells }) => ({ id: String(cells[0]), amount: Number(cells[1]) }),
});
API Input / output
inspectCominsXlsx(options) bytes, limits? → Promise<CominsXlsxWorkbookInfo>
importCominsRowsFromXlsx<T>(options) bytes, sheetName?, hasHeader?, limits?, mapRow → Promise<T[]>
exportCominsRowsToXlsx<T>(options) rows, columns, sheetName?, maxCells?, styles? → Promise<Uint8Array>

mapRow converts validated rows to application types. Numbers, booleans, strings and null remain typed; formulas use cached results without recalculation. Select sheetName when multiple visible sheets exist. Hidden sheets, merged cells, missing formula caches, error cells and unsupported values are rejected. Rows are returned only after the entire read and mapping succeed.

The default theme is comins; plain disables default decoration. Set fonts, colors, borders, alignment, wrapping and number formats for header, body or individual columns. Column widths are in characters; row heights are in points. CSS, HTML and vendor objects are not accepted.

Input limits are maxBytes, maxUncompressedBytes and maxCells. Actual inflated bytes and CRC are checked. CominsXlsxError.code distinguishes INVALID_OPTIONS, UNSUPPORTED_FILE, INVALID_WORKBOOK, LIMIT_EXCEEDED, SHEET_SELECTION_REQUIRED, SHEET_NOT_FOUND, MERGED_CELLS, MISSING_FORMULA_RESULT, CELL_ERROR and UNSUPPORTED_VALUE.

File I/O, formula execution and dedicated Tree/Group Excel export are outside scope. Strings remain literal text. See the export guide and type catalog for limit defaults and additional contracts.