# excel-to-json-with-template

> A library to convert the excel to JSON format with a simple or complex desired template

Latest version **0.1.1** (published 2020-07-24) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install excel-to-json-with-template
pnpm add excel-to-json-with-template
yarn add excel-to-json-with-template
bun add excel-to-json-with-template
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2020-07-24 |
| First published | 2020-07-09 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 213.1 KB |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Thiyagarajan Nagaraj thyagajan@gmail.com https://thyagajan.in |
| Maintainers | thyagajan |
| Keywords | excel, json, template |

## Links

- npm: https://www.npmjs.com/package/excel-to-json-with-template
- Repository: https://github.com/thyagajan/my-angular-libraries
- Homepage: https://www.thyagajan.in
- Issues: https://github.com/thyagajan/my-angular-libraries/issues
- npm.io page: https://npm.io/package/excel-to-json-with-template

## Dependencies (2)

- [xlsx](https://npm.io/package/xlsx.md) 0.16.3
- [tslib](https://npm.io/package/tslib.md) ^1.9.0

## 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.1.1 (latest) — 2020-07-24
- 0.1.0 — 2020-07-24
- 0.0.5 — 2020-07-11
- 0.0.4 — 2020-07-09
- 0.0.3 — 2020-07-09
- 0.0.2 — 2020-07-09
- 0.0.1 — 2020-07-09

## README

# ExcelToJsonWithTemplate

An NPM library which can be used in Angular project to convert Excel file to JSON with your desired custom template.

## What it does?
This library helps to convert the excel data to JSON with your own templete.
Currently it supports
* simple key value mapping.
* multiple Key value mapping.
* Object with multiple keys.
* List of keys (only column mapping is supported, row support to be added).
* List of Objects.
* Multiple Sheets/Tabs.
* complex JSON structure.

### Installaton
npm i excel-to-json-with-template

### User Interface
An simple user interface which is developed in Angular framework available in the below link. This project can be imported and used on your hosting server.
https://github.ibm.com/tnagaraj/excel-to-json

### Usage
In your app component,
1. Import the libraray
`import {ExcelToJsonWithTemplateService,Excel2JsonInput} from 'excel-to-json-with-template';`
2. Inject to your constructor
`constructor(private excel2JsonService:ExcelToJsonWithTemplateService)`
3. Set the Input

`const jsonInput:Excel2JsonInput = {
      excelFileHandler : this.file,
      jsonTemplate : this.template?JSON.parse(this.template):undefined,
      delimiter: this.delimiter
    }`
   * excelFileHandler is the File handle object which you get it after clicking on import file button.
   * jsonTemplate is an optional template(just to give you more freedom), which you want to convert your excel file to
   * delimiter is an optional parameter that you use in your template. By default it is '$'.
4. Call the library code to convert your excel to JSON

 `this.excel2JsonService.convertToJson(jsonInput).subscribe(jsonData => {
      console.log("received data ",jsonData);
    });`
   

## Use Cases
### Mapping without a Template
![Mappingwithoutatemplate](https://www.thyagajan.in/myassets/excel-json/images/no_template.png)

### Simple Key Value Mapping
![KeyValueMapping](https://www.thyagajan.in/myassets/excel-json/images/simple_key_mapping.png)
### Multiple Key Value Mapping
![MultipleKeyValueMapping](https://www.thyagajan.in/myassets/excel-json/images/multiple_key_mappings.png)

### Multiple Keys as Object
![MultipleKeysasObject](https://www.thyagajan.in/myassets/excel-json/images/mappings_as_object.png)

### Simple List
![SimpleList](https://www.thyagajan.in/myassets/excel-json/images/simple_list.png)

### List Of Objects
![listOfObjects](https://www.thyagajan.in/myassets/excel-json/images/List_of_objects.png)

### Multiple Tab/Sheets
![MultipleTabExcel](https://www.thyagajan.in/myassets/excel-json/images/different_tab_excel.png)

![MultipleTabJSON](https://www.thyagajan.in/myassets/excel-json/images/different_tab_json.png)

### Real Life Example
![RealLifeExampleExcel](https://www.thyagajan.in/myassets/excel-json/images/imdb_excel.png)
![RealLifeExampleTemplate](https://www.thyagajan.in/myassets/excel-json/images/imdb_template.png)
![RealLifeExampleOutput](https://www.thyagajan.in/myassets/excel-json/images/imdb_output.png)

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