react-excel-exporter
Version:
Library for exporting data to Excel made with React and ViteJS.
83 lines (69 loc) • 2.71 kB
Markdown
Library for exporting data to Excel made with React and ViteJS.
- If you are usign [yarn](https://github.com/yarnpkg/berry):
```sh
yarn add react-excel-exporter
```
- If you are usign [npm](https://www.npmjs.com/):
```sh
npm install react-excel-exporter
```
| Prop | Type | Default | Required | Description |
| :------------ | :------------------ | :--------- | :------- | :------------------------------------------------ |
| filename | `string` | `null` | `true` | Name of the excel file that will be downloaded |
| element | `ReactNode` | `null` | `true` | Element to download excel file |
| children | `Array<ExcelSheet>` | `null` | `true` | ExcelSheet Represents data |
| Prop | Type | Default | Required | Description |
| :------- | :---------------------- | :------ | :------- | :----------------- |
| name | `string` | `null` | `true` | Sheet name in file |
| data | `array<object>` | `null` | `true` | Excel Sheet data |
| children | `ExcelColumn` | `null` | `true` | ExcelColumns |
| Prop | Type | Default | Required | Description |
| :------- | :---------------------- | :------ | :------- | :------------------------------ |
| name | `string` | `null` | `true` | Column name in file |
| value | `string or function` | `null` | `true` | Property name to access value |
```ts
import { ExcelFile, ExcelColumn, ExcelSheet } from 'react-excel-exporter'
function App() {
return (
<ExcelFile
element={
<button>
download
</button>
}
filename="excel-colors"
>
<ExcelSheet
name="Colors"
data={[
{
name: 'Blue',
is_dark: false,
},
{
name: 'Yellow',
is_dark: false
},
{
name: 'Pink',
is_dark: false,
},
{
name: 'Black',
is_dark: true
},
]}
>
<ExcelColumn label="Name" value="name" />
<ExcelColumn label="Color Dark" value={(col) => col.is_dark ? "Yes" : "False"} />
</ExcelSheet>
</ExcelFile>
)
}
```