@czkoudy/export-to-excel

0.4.3 • Public • Published

@czkoudy/export-to-excel

React component for exporting data to Excel

NPM JavaScript Style Guide

Downloads

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

Package Sidebar

Install

npm i @czkoudy/export-to-excel

Weekly Downloads

0

Version

0.4.3

License

MIT

Unpacked Size

8.79 kB

Total Files

7

Last publish

Collaborators

  • czkoudy