npm.io
1.0.7 • Published 6 years ago

parseexcel

Licence
ISC
Version
1.0.7
Deps
1
Size
8 kB
Vulns
5
Weekly
0

Usage

animal weight color
dog 20 kg black
cat 5 kg white
mouse 0.15 kg gray

1. Parse excel file by path to array of javaScript objects

const { parseObj } = require('parseexcel')

const resArr = parseObj(filePath)
Result:
resArr = [
           { animal: 'dog', weight: '20 kg', color: 'black' },
           { animal: 'cat', weight: '5 kg', color: 'white' },
           { animal: 'mouse', weight: '0.15 kg', color: 'gray' }
         ]
2. Parse excel file by path to array of JSON
const { parseJson } = require('parseexcel')

const resArr = parseJson(filePath) 
Result:
resArr = [
           '{"animal":"dog","weight":"20 kg","color":"black"}',
           '{"animal":"cat","weight":"5 kg","color":"white"}',
           '{"animal":"mouse","weight":"0.15 kg","color":"gray"}'
         ]
3. Parse excel files (1 or more) from directory to array of javaScript objects

Table 1

phone price color
Xiaomi 100 $ blue
Samsung 150 $ white
Nokia 50 $ black

Table 2

TV price size weight
LG 150 $ 150 10
Horizont 50 $ 70 12
Panasonic 250 $ 120 8

Usage:

const { parseAllObj } = require('parseexcel')

const resArr = parseAllObj(directoryPath) 
Result:
resArr = [
           [
             { phone: 'Xiaomi', price: '100 
4. Parse excel files (1 or more) from directory to array of JSON
const { parseAllJson } = require('parseexcel')

const resArr = parseAllJson(directoryPath) 
5. Parse Async excel files (1 or more) from directory to array of javaScript objects
const { parseAllObjAsync } = require('parseexcel')

const resArr = await parseAllObjAsync(directoryPath) 
6. Parse Async excel files (1 or more) from directory to array of JSON
const { parseAllJsonAsync } = require('parseexcel')

const resArr = await parseAllJsonAsync(directoryPath) 
, color: 'blue' }, { phone: 'Samsung', price: '150
4. Parse excel files (1 or more) from directory to array of JSON
__CODE_BLOCK_6__
5. Parse Async excel files (1 or more) from directory to array of javaScript objects
__CODE_BLOCK_7__
6. Parse Async excel files (1 or more) from directory to array of JSON
__CODE_BLOCK_8__
, color: 'white' }, { phone: 'Nokia', price: '50
4. Parse excel files (1 or more) from directory to array of JSON
__CODE_BLOCK_6__
5. Parse Async excel files (1 or more) from directory to array of javaScript objects
__CODE_BLOCK_7__
6. Parse Async excel files (1 or more) from directory to array of JSON
__CODE_BLOCK_8__
, color: 'black' } ], [ { TV: 'LG', price: '150
4. Parse excel files (1 or more) from directory to array of JSON
__CODE_BLOCK_6__
5. Parse Async excel files (1 or more) from directory to array of javaScript objects
__CODE_BLOCK_7__
6. Parse Async excel files (1 or more) from directory to array of JSON
__CODE_BLOCK_8__
, size: 150, weight: 10 }, { TV: 'Horizont', price: '50
4. Parse excel files (1 or more) from directory to array of JSON
__CODE_BLOCK_6__
5. Parse Async excel files (1 or more) from directory to array of javaScript objects
__CODE_BLOCK_7__
6. Parse Async excel files (1 or more) from directory to array of JSON
__CODE_BLOCK_8__
, size: 70, weight: 12 }, { TV: 'Panasonic', price: '250
4. Parse excel files (1 or more) from directory to array of JSON
__CODE_BLOCK_6__
5. Parse Async excel files (1 or more) from directory to array of javaScript objects
__CODE_BLOCK_7__
6. Parse Async excel files (1 or more) from directory to array of JSON
__CODE_BLOCK_8__
, size: 120, weight: 8 } ] ]
4. Parse excel files (1 or more) from directory to array of JSON
__CODE_BLOCK_6__
5. Parse Async excel files (1 or more) from directory to array of javaScript objects
__CODE_BLOCK_7__
6. Parse Async excel files (1 or more) from directory to array of JSON
__CODE_BLOCK_8__