# react-excel-workbook

> An downloadable excel workbook react component

Latest version **0.0.4** (published 2017-06-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-excel-workbook
pnpm add react-excel-workbook
yarn add react-excel-workbook
bun add react-excel-workbook
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2017-06-15 |
| First published | 2016-12-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 109 |
| Author | David Adams |
| Maintainers | dadamssg |
| Keywords | react-component, excel, workbook |

## Links

- npm: https://www.npmjs.com/package/react-excel-workbook
- Repository: https://github.com/ClearC2/react-excel-workbook
- Issues: https://github.com/ClearC2/react-excel-workbook/issues
- npm.io page: https://npm.io/package/react-excel-workbook

## Dependencies (2)

- [xlsx](https://npm.io/package/xlsx.md) ^0.10.3
- [file-saver](https://npm.io/package/file-saver.md) ^1.3.3

## Recent versions

- 0.0.4 (latest) — 2017-06-15
- 0.0.3 — 2017-06-01
- 0.0.2 — 2017-02-10
- 0.0.1 — 2016-12-22

## README

# React Excel Workbook

React Excel Workbook is a library for defining downloadable excel workbooks with react components.

## Example

```jsx
import Workbook from 'react-excel-workbook'

const data1 = [
  {
    foo: '123',
    bar: '456',
    baz: '789'
  },
  {
    foo: 'abc',
    bar: 'dfg',
    baz: 'hij'
  },
  {
    foo: 'aaa',
    bar: 'bbb',
    baz: 'ccc'
  }
]

const data2 = [
  {
    aaa: 1,
    bbb: 2,
    ccc: 3
  },
  {
    aaa: 4,
    bbb: 5,
    ccc: 6
  }
]

const example = (
  <div className="row text-center" style={{marginTop: '100px'}}>
    <Workbook filename="example.xlsx" element={<button className="btn btn-lg btn-primary">Try me!</button>}>
      <Workbook.Sheet data={data1} name="Sheet A">
        <Workbook.Column label="Foo" value="foo"/>
        <Workbook.Column label="Bar" value="bar"/>
      </Workbook.Sheet>
      <Workbook.Sheet data={data2} name="Another sheet">
        <Workbook.Column label="Double aaa" value={row => row.aaa * 2}/>
        <Workbook.Column label="Cubed ccc " value={row => Math.pow(row.ccc, 3)}/>
      </Workbook.Sheet>
    </Workbook>
  </div>
)

render(example, document.getElementById('app'))
```

![Example](http://i.imgur.com/dfhivAs.png)
![Excel](http://i.imgur.com/OnInSNv.png)

Workbooks can have multiple sheets. Sheets can use the same or different data sets(an array of objects).
Sheets have columns. Columns define a column label and value. Values can either be a string(the property name) or a function
that takes the current object and returns a value.

## Dependencies

This package uses [file-saver](https://www.npmjs.com/package/file-saver) and [xlsx](https://www.npmjs.com/package/xlsx) packages. I am only familiar with webpack and in order for everything to work with webpack you must use the [json-loader](https://www.npmjs.com/package/json-loader) and have this defined in your webpack config.

```js
node: {fs: 'empty'},
externals: [
  {'./cptable': 'var cptable'},
  {'./jszip': 'jszip'}
]
```

See the `example` directory for a working example.

## Testing

I have no idea how to test this.

---
_Source: https://npm.io/package/react-excel-workbook · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
