Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ jobs:
- name: Resolved versions
run: node scripts/print-versions.mjs

- name: Typecheck (library + playground)
- name: Typecheck (library + playground + docs examples)
if: matrix.react == 19
run: npm run typecheck

- name: Code in the README and docs matches examples/
if: matrix.react == 19
run: npm run docs:check

- name: Typecheck (library)
if: matrix.react != 19
run: npm run typecheck -w react-data-export
Expand Down
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Export data from React to `.xlsx` and `.csv`.

## Status: 1.0 is a from-scratch rewrite, in progress

- **1.0 is a clean break.** It is being rebuilt on [javascript-excel](https://github.com/securedeveloper/javascript-excel) 2.0 and will not ship the 0.x `<ExcelFile>` / `<ExcelSheet>` / `<ExcelColumn>` API. A migration guide will come with the first beta.
- **1.0 is a clean break.** It is being rebuilt on [javascript-excel](https://github.com/securedeveloper/javascript-excel) 2.0 and will not ship the 0.x `<ExcelFile>` / `<ExcelSheet>` / `<ExcelColumn>` API. See [Migrating from 0.x](#migrating-from-0x).
- **Dataset and table export are on `main`, not yet on npm:** `exportDataset`, `exportWorkbook`, `useExcelExport` and `<ExcelExport>`, plus `exportTable`, `useTableExport` and `<ExportTableButton>` for an HTML `<table>`, as specified in [docs/api.md](docs/api.md). They are built on javascript-excel 2.0's `fromDataset`, `fromTable`, writer and download. The first 1.0 prerelease will be announced in this README.

```tsx
Expand All @@ -22,6 +22,52 @@ Export data from React to `.xlsx` and `.csv`.
- **0.6.x stays on npm unchanged.** `npm install react-data-export@0.6` keeps working; nothing is unpublished or deprecated.
- **Legacy code and docs** (0.x README, examples, Babel/Jest setup) live at the [`v0.6.0` tag](https://github.com/securedeveloper/react-data-export/tree/v0.6.0).

## Migrating from 0.x

The [migration guide](docs/migration.md) shows every 0.x pattern next to its 1.0 code: `ExcelFile` + `ExcelSheet` + `ExcelColumn`, `dataSet` with `xSteps`/`ySteps`, `hideElement`, `element`, `fileExtension`, and the xlsx-style cell styles (with a converter). It also lists every intentional behaviour difference. The most common change:

```jsx
// 0.x
<ExcelFile filename="employees" element={<button>Download</button>}>
<ExcelSheet data={employees} name="Employees">
<ExcelColumn label="Name" value="name"/>
<ExcelColumn label="Marital Status" value={(col) => col.is_married ? "Married" : "Single"}/>
</ExcelSheet>
</ExcelFile>
```

<!-- example: examples/migration/readme.tsx -->
```tsx
// 1.0
import { ExcelExport } from 'react-data-export';

const employees = [{ name: 'Monika', is_married: false }];

export const Download = () => (
<ExcelExport
filename="employees"
dataset={{
name: 'Employees',
columns: [
{ title: 'Name', key: 'name' },
{ title: 'Marital Status', value: (row: (typeof employees)[number]) => (row.is_married ? 'Married' : 'Single') },
],
data: employees,
}}
>
Download
</ExcelExport>
);
```

Things to know before you switch:
- `<ExcelColumn>` headers are now bold, and 0.x's 80 px default column width is gone.
- Dates are written in local time; 0.x converted them as UTC.
- `fileExtension` is replaced by `format: 'xlsx' | 'csv'`. 0.6 saved an xlsx package even for `csv`, `txt`, `xls` and `html`.
- Styles use javascript-excel's keys (`font.size`, `fill: 'FF0000'`, …), and invalid values throw `INVALID_STYLE`.

0.6.x stays on npm unchanged (`npm install react-data-export@0.6`) if you're not ready to move.

## TypeScript support

Types ship with the package (`.d.ts` for `import`, `.d.cts` for `require`). CI type-checks a consumer project against the packed tarball, in strict mode with `skipLibCheck: false`.
Expand Down
Loading
Loading