# xlsx-json-stream

> A memory friendly JSON row streamer for Excel (XLSX) files

Latest version **0.2.0** (published 2022-01-15) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install xlsx-json-stream
pnpm add xlsx-json-stream
yarn add xlsx-json-stream
bun add xlsx-json-stream
```

## 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.2.0 |
| Published | 2022-01-15 |
| First published | 2021-09-12 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 22 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Oscar Yu |
| Maintainers | orca256 |
| Keywords | excel, xlsx, stream, json, read-excel-file |

## Links

- npm: https://www.npmjs.com/package/xlsx-json-stream
- Repository: https://github.com/oscaryu/xlsx-json-stream
- Homepage: https://github.com/oscaryu/xlsx-json-stream#readme
- Issues: https://github.com/oscaryu/xlsx-json-stream/issues
- npm.io page: https://npm.io/package/xlsx-json-stream

## Dependencies (1)

- [read-excel-file](https://npm.io/package/read-excel-file.md) ^5.2.25

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.2.0 (latest) — 2022-01-15
- 0.1.9 — 2022-01-13
- 0.1.8 — 2022-01-13
- 0.1.7 — 2021-11-30
- 0.1.6 — 2021-11-20
- 0.1.5 — 2021-11-20
- 0.1.4 — 2021-11-20
- 0.1.3 — 2021-09-22
- 0.1.2 — 2021-09-22
- 0.1.1 — 2021-09-12
- 0.1.0 — 2021-09-12

## README

# xlsx-json-stream

Minimize memory usage by processing each row as soon as possible, instead of trying to convert everything into an array of JSON objects.

This does not have write functionality.

## Quick start

npm install xlsx-json-stream

````
const ExcelStreamer = require('xlsx-json-stream');


main = async () => {
    await ExcelStreamer.readToJson('Spreadsheet.xlsx', (err, data) => {
        console.log(data.row, data.rowCtr, data.dataLength, data.headerLength, data.sheetName);
        // ToDo: add your transform and load steps for each Excel row here
    });
    console.log("** Done **");
}

main()
````

## You can also override some parameters:

- MAX_EMPTY_SEQUENTIAL_ROWS = 2;
- DEFAULT_VALUE = null;
- HEADER_ROW = 0;
- DATA_START_ROW = 1;
- INCLUDE_EMPTY = false;
- SHEETS = [];
- ASYNC_BATCH_SIZE = 1;
- READ_OPTIONS = { dateFormat: 'm/d/yy;@' }; // Default date format is mm/dd/yyyy
- DATE_FIELD_LIST = ['Column Header 1', 'Arrival Date']; // force numbers to date
- IS_LOCAL_DATES = false; // remove the 'Z' at the end of the ISO string to 'treat it like a local' date


````
const ExcelStreamer = require('xlsx-json-stream');

let options = {
  MAX_EMPTY_SEQUENTIAL_ROWS : 2,
  DEFAULT_VALUE:'',
  HEADER_ROW:0,
  DATA_START_ROW:1,
  INCLUDE_EMPTY:false,
  SHEETS:['USA','MEX'],
  ASYNC_BATCH_SIZE:1,
  READ_OPTIONS : {dateFormat: 'm/d/yy;@' }; // default format is mm/dd/yyyy
}

main = async () => {
    await ExcelStreamer.readToJson(filename, options, (err, data) => {
        console.log(data.row, data.rowCtr, data.sheetName, data.dataLength, data.headerLength);
        // ToDo: add your transform and load steps for each Excel row here
    });
    console.log("** Done **");
}

main()
````

## BREAKING CHANGE
We are now returning the standard `(error, data)`, instead of returning multiple parameters: `obj, rowCtr, sheetName, headerLength, dataLength`.  And access them this way:
 - data.row
 - data.rowCtr
 - data.sheetName
 - data.headerLength 
 - data.dataLength


## Exceptions

UnhandledPromiseRejectionWarning: Error: Sheet "MEX" not found in the *.xlsx file. Available sheets: "USA" (#1), "CAN" (#2).

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