0.1.1 • Published 4 years ago

excel-to-json-with-template v0.1.1

Weekly downloads
19
License
Apache-2.0
Repository
github
Last release
4 years ago

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 '$'.
  1. 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

Simple Key Value Mapping

KeyValueMapping

Multiple Key Value Mapping

MultipleKeyValueMapping

Multiple Keys as Object

MultipleKeysasObject

Simple List

SimpleList

List Of Objects

listOfObjects

Multiple Tab/Sheets

MultipleTabExcel

MultipleTabJSON

Real Life Example

RealLifeExampleExcel RealLifeExampleTemplate RealLifeExampleOutput

0.1.0

4 years ago

0.1.1

4 years ago

0.0.5

4 years ago

0.0.3

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago