# jsonexcel

> produce an excel file out of an array of json objects

Latest version **2.0.3** (published 2017-12-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install jsonexcel
pnpm add jsonexcel
yarn add jsonexcel
bun add jsonexcel
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2017-12-09 |
| First published | 2015-07-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Scott Frees |
| Maintainers | freezer3 |
| Keywords | excel |

## Links

- npm: https://www.npmjs.com/package/jsonexcel
- Repository: https://github.com/freezer333/jsonexcel
- Homepage: https://github.com/freezer333/jsonexcel#readme
- Issues: https://github.com/freezer333/jsonexcel/issues
- npm.io page: https://npm.io/package/jsonexcel

## Dependencies (2)

- [flatjson](https://npm.io/package/flatjson.md) ^1.0.5
- [node-xlsx](https://npm.io/package/node-xlsx.md) ^0.5.1

## Recent versions

- 2.0.3 (latest) — 2017-12-09
- 2.0.2 — 2017-11-09
- 2.0.1 — 2016-09-24
- 2.0.0 — 2016-09-24
- 1.0.1 — 2015-07-10
- 1.0.0 — 2015-07-10

## README

This module lets you create an excel file out of an array of javascript objects.  The objects are flattened using [flatjson](https://github.com/freezer333/flatjson).  The resulting excel sheet has one column per key in the flattened objects.  Each row in the excel sheet corresponds to the values of each object in the input array.

The array of objects do not necessarily need to have the same set of keys - but the excel sheet will have the union of all keys as the column list.

# Example Usage

```js
toxl = require('jsonexcel');
fs = require('fs');

var test = [
    {
        parent1: {
            child1: {
                child11: 10, 
                child12: 11
            }, 
            child2: {
                child21: 20, 
                child22: 21
            }
        }, 
        parent2 : {
            child1: {
                child11: 101, 
                child21: 102
            }
        }
    }, 
    {
        parent1: {
            child2: {
                child21: 20, 
                child22: 21
            }, 
            child3: {
                child31: 30, 
                child32: 31
            }
        }, 
        parent2 : {
            child1: {
                child11: 101, 
                child21: 102
            }
        }
    }
]

var opts = {
    sheetname : "My Example",
    delimiter : "."
}

buffer = toxl(test, opts);
fs.writeFile("example.xlsx", buffer,  "binary",function(err) {
    if(err) {
        console.log(err);
    } else {
        console.log("Saved excel file to example.xlsx");
    }
});
```

The resulting excel file will look like this:
<img src="example.png"/>

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