@czkoudy/export-to-excel
v0.4.3
Published
React component for exporting data to Excel spreadsheets
Downloads
17
Readme
@czkoudy/export-to-excel
React component for exporting data to Excel
Install
npm install --save @czkoudy/export-to-excel
Usage
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 <ExcelExport options={workbookOptions} />;
API
ExcelExport props
| Name | Type | Required | Default | | ------- | ------ | -------- | ------- | | options | Object | Yes | - |
options props
| 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
columns: [{ header: 'First Name' }, { header: 'Age' }, { header: 'Nationality' }],
License
MIT © czkoudy