Repository navigation
1.0 is a from-scratch rewrite on javascript-excel 2.0, with no runtime dependency other than javascript-excel. It exports datasets (exportDataset, exportWorkbook, useExcelExport, <ExcelExport>) and HTML tables (exportTable, useTableExport, <ExportTableButton>) to real .xlsx and .csv, in React 17, 18 and 19.
Migrating from 0.x
0.6.x stays on npm. Existing ^0.6.0 ranges keep installing it; latest now points to 1.0.0. The migration guide shows every 0.x pattern next to its 1.0 code. In short:
- New main API. The main entry has named exports only and no
<ExcelFile>/<ExcelSheet>/<ExcelColumn>. For a quick switch,react-data-export/legacyruns that 0.6 JSX on 1.0 with one import change; it is deprecated, supported for all of 1.x and removed in 2.0. - No peer libraries or bundler setup. Uninstall
file-saverandtempa-xlsxif you added them for 0.x, and drop the webpack settings they needed (node: { fs: 'empty' }, the./cptableand./jszipexternals). - Real CSV. 0.x wrote an
.xlsxpackage under anyfileExtension; 1.0 writes real CSV for'csv'and throws aTypeErrorfor other formats. - Output differences (header bold, column widths, dates in the local time zone instead of UTC, file name default
export, async exports withonError/onExported, validated sheet names and styles) are listed in the guide's behaviour differences, each with the option that restores the 0.6 output. - Runtimes: Node.js 22 or later for tooling and SSR imports; React 17–19.
The prereleases 1.0.0-alpha.1 to 1.0.0-beta.0 stay on the next dist-tag; their entries are folded into this section.
Minor Changes
-
05a07db: Add the 1.0 dataset module, built on javascript-excel 2.0:
exportDataset(dataset, options)andexportWorkbook({ sheets, activeSheet }, options)build sheets with javascript-excel'sfromDataset/fromDatasets, write.xlsx(toBlob) or.csv(toCsvBlob) and download throughjavascript-excel/dom. They resolve with{ blob, filename, format, warnings }. Falsy sheets are skipped,download: falseonly builds the file, andsignal/onProgressare supported.useExcelExport(defaults)addsstatus,progress,errorandresult, stable functions,abort(), and aborts running exports on unmount (StrictMode-safe).<ExcelExport dataset | workbook>renders a default button or a render prop with arun()that never rejects, and reports throughonExported/onError.- The entry is marked
"use client". The dataset, column, style and option types are javascript-excel's own, re-exported (Dataset,ColumnDef,LeafColumn,GroupColumn,DatasetBlock,DatasetOptions,Style,CellInput,WriteOptions,CsvWriteOptions,Progress,ExcelWarning,DocProperties), along withisExcelErrorandsanitizeSheetName.
The scaffold placeholder
useVersionis removed. -
986d0d7: Add
react-data-export/legacy, a deprecated quick path for 0.x code:<ExcelFile>,<ExcelSheet>,<ExcelColumn>, the 0.x default export (import ReactExport from 'react-data-export/legacy'), thedataSetshape withxSteps/ySteps, and xlsx-style cell styles, built on 1.0's export code and javascript-excel. The files it writes match 0.6.0's (checked against the real 0.6.0):- plain
<ExcelColumn>headers and bolddataSetheaders - 80 px default widths
- UTC dates
- the
Downloaddefault name with the extension always appended - the
<span>trigger wrapper
0.6's bugs stay fixed:
- one download under StrictMode
fileExtension: 'csv'writes real CSVxls/txt/htmlwrite.xlsxwith a warning- string
dataSetcolumns keep their header text - falsy children are skipped
convertLegacyStyleconverts 0.x styles to the 1.0 style model. The entry is supported for all of 1.x and removed in 2.0, and it logs one deprecation warning in development. It's a separate entry, so the main entry's bundle doesn't include it. - plain
-
e4e9492: Add table export, built on javascript-excel 2.0's
fromTable:exportTable(tableOrRef, options)reads an HTML<table>(an element, or a ref read when called).colspan/rowspanbecome merges,<thead>rows become headers, hidden and[data-export-ignore]rows are skipped, anddata-*hints are honoured. It exports.xlsxor.csvwith the same options and the same{ blob, filename, format, warnings }result asexportDataset.fromTableoptions pass through unchanged.useTableExport(ref, defaults)and<ExportTableButton tableRef>share the state, abort, unmount and trigger behaviour ofuseExcelExportand<ExcelExport>.- An empty ref rejects with a
TypeErrorbefore anything is built.FromTableOptions,TableElementandTableCellElementare re-exported.
Patch Changes
- e9f731c: Require javascript-excel
^2.0.0, the stable release (was a 2.0.0 prerelease range). - README: drop the prerelease notice; install from
latest. - f48b7b6: README: the 1.0 feature set is complete; until 1.0.0, changes are limited to fixes found in testing. A Web Worker option comes in a 1.x release.
- 12d2cbf: Thanks to the community pull requests whose ideas shaped 1.0:
- #143 by @samuelhulla: correct the
ExcelCelltyping (#141). - #161 by @atefBB: document the real
alignment.horizontalvalues. - #165 by @mehmetyilmaz001: nested object access in columns (
user.name, #164). - #167 by @apperside: a callback after the file is generated.
- #171 by @xaviergeorge: fix the
ExcelCellvalue type (#141). - #174 by @tobwithu: make the types work with React + TypeScript.
- #176 by @saeedkhal: skip falsy (conditional) columns.
- #180 by @imsuvesh: ship the type declarations where npm resolves them (#179, #146, #64).
- #143 by @samuelhulla: correct the
- de3f774: CSV exports started on mount under React 18/19 StrictMode no longer download twice.
toCsvBlobis synchronous, so a CSV export (build, write, download) used to finish inside the first effect run, before StrictMode's simulated unmount could abort it. Every export (exportDataset,exportWorkbook,exportTable, and the hooks and components built on them) now yields once and re-checks its signal before building. xlsx exports were not affected. - 180ee54: Depend on javascript-excel
^2.0.0-alpha.3. - f48b7b6: Depend on javascript-excel
^2.0.0-beta.0, its first 2.0.0 beta. Since 2.0.0-alpha.7 its writer returns to the event loop about every 16 ms, so a large.xlsxexport on the main thread no longer freezes the page, andsignal/abort()take effect while it runs. - 1a36b62:
react-data-export/legacy: two<ExcelSheet>elements with the same name (compared case-insensitively) no longer fail the export; the later ones are written asname (2),name (3)... with a development warning. 0.x wrote such files as given, and Excel offered to repair them (#94). - 3ce8219: README: the 0.6 API is described as shipping only in the deprecated
react-data-export/legacyentry (removed in 2.0), and the playground is linked.