React component for exporting data to Excel spreadsheets
npm install @czkoudy/export-to-excelbash
npm install --save @czkoudy/export-to-excel
`
Usage
`jsx
import PaginationTable from '@czkoudy/pagination-table';
const allUsers = [
{
firstName: 'Jakub',
age: 36,
nationality: 'Czech',
},
];
const workbookOptions = {
filename: 'Export of users',
sheets: [
{
name: 'Users',
options: {
columns: [{ header: 'First Name' }, { header: 'Age' }, { header: 'Nationality' }],
},
data: allUsers,
keys: [
{
label: 'firstName',
formatValue: (val) => val.toLowerCase(),
},
{
label: 'age',
},
{
label: 'nationality',
},
],
},
],
};
return ;
`
API
ExcelExport props
| Name | Type | Required | Default |
| ------- | ------ | -------- | ------- |
| options | Object | Yes | - |
$3
| Name | Type | Required | Default | Description |
| -------- | ------ | -------- | ------- | ----------------------------------------------- |
| fileName | String | Yes | - | Name of excel file |
| sheets | Array | Yes | - | Array of objects representing sheet in workbook |
options.sheets props
| Name | Type | Required | Default | Description |
| ------- | ------ | -------- | ------- | ----------- |
| name | String | Yes | - |
| options | Object | Yes | - |
| data | Array | Yes | - |
| keys | Array | Yes | - |
options.sheets.options props
`js
columns: [{ header: 'First Name' }, { header: 'Age' }, { header: 'Nationality' }],
``