Excel and ODS

Import and Export from XLSX and ODS files

Use the @rowsncolumns/toolkit package to read, write and download Excel files from SheetData object

Supported formats

Format
Export
Import

ODS

Yes

Yes

XLSM

No

Yes

XLSX

Yes

Yes

CSV

Yes

Yes

TSV

No

Yes

Importing excel files

You can use importExcelFile to import excel file using a web worker.

import { useSpreadsheetState } from "@rowsncolumns/spreadsheet-state";
import { useLoadingIndicator } from "@rowsncolumns/spreadsheet"
 
const App = () => {
    const { importExcelFile } = useSpreadsheetState({ ... });
    const [showLoader, hideLoader] = useLoadingIndicator();
    return (
        <input
            type="file"
            onChange={async (e) => {
              const file = e.target.files?.[0];
              if (file) {
                showLoader("Parsing excel file");
                
                await importExcelFile(file)

                hideLoader();
              }
            }}
          />
    )
}

Read Excel in Node.js

The browser worker (libs/toolkit/excel-parser/worker.ts) demonstrates the low-level primitives that parse .xlsx files. You can reuse the same helpers on the server to read workbooks, stream rows, and fetch metadata such as conditional formatting, named ranges, fonts, drawings, charts, and data validations.

Key steps:

  • read the file with Node APIs (e.g. fs.readFile, S3 SDK) to obtain a Buffer

  • convert the Buffer into an ArrayBuffer before calling readExcelFile

  • reuse the worker helpers (WorkBook, getSheets, getConditionalFormatting, getDrawings, getCharts, getDataValidations, processSheetData) to assemble everything you need server-side

Streaming rows with processSheetData

Signature:

  • workbook: the shared WorkBook instance with load() already called.

  • chunkSize: how many logical rows you want in each yielded chunk (mirrors the worker's paging behavior).

  • enableCellXfsRegistry: set to true if you need the cellXfs map populated so you can reuse deduped cell formats outside the worker.

Result type (from libs/toolkit/excel-parser/helpers.ts):

cellXfs is the same memoized format registry the worker uses (a map keyed by the serialized cell format) so you can reconcile styles outside the worker.

Example: accumulate totals per sheet while keeping the formatting registry alive for later use.

Export to Excel

Toolkit provides createExcelFile and exportToExcel functions to either create a excel ArrayBuffer or create a downloadable excel file.

Export to ODS

Toolkit provides exportToODS to download an ODS file.

Last updated

Was this helpful?