React component that will export an array of objects into XLSX
npm install --save @gabrielduumont/react-export-excel
or
yarn add @gabrielduumont/react-export-excel
import React from 'react';
import { ExcelExporter } from './components';
function App() {
const data = [
{
'Column Title 1': 'Value 1',
'Column Title 2': 1,
},
{
'Column Title 1': 'Value 2',
'Column Title 2': 2,
},
{
'Column Title 1': 'Value 3',
'Column Title 2': 3,
'Column Title 3': '25-12-2015',
},
];
return (
<ExcelExporter
data={data}
fileName="Excel Report Name"
sheetName='Results'
/>
);
}
export default App;
No props are required, but if you don't provide at least the 'data' props, nothing will happen.
Prop | Required | Type | Default |
---|---|---|---|
data | no | array of objects | [] |
children | no | React Component | null |
fileName | no | string | 'Download' |
sheetName | no | string | 'Sheet 1' |
disabled | no | bool | false |
label | no | string | 'Export' (if there is data to export) / 'No data to export.' (otherwise) |
className | no | string | '' |
minCellWidth | no | number | 20 |