xlsx2json

Convert xlsx to JSON.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
xlsx2json
1.0.07 years ago10 years agoMinified + gzip package size for xlsx2json in KB

Readme

xlsx2json Build Status Coverage Status Code Climate
NPM
Convert xlsx to JSON.

Install

$ npm install xlsx2json

Usage

Simple usage : )
var xlsx2json = require('xlsx2json');
xlsx2json('path_to_xlsx_file').then(jsonArray => {
    ...
});

xlsx2json(pathToXlsx, options, callback)

Arguments

  • pathToXlsx String

  • options Object (optional)
``sheet``
* {Number} (*zero-based sheet index)
* {String}
* {Array}

If options.sheet is not set, all sheets will be passed as Array.
``keysRow`` {Number} (one-based row position) ``mapping`` {Object} ``dataStartingRow`` {Number} (one-based row position)
  • callback Function (optional)
function(error, jsonArray) {}

Returns

  • Promise

for example : )
convert test/xlsx/withheaderinformationandkeysrow.xlsx
to jsonArray.
var xlsx2json = require('xlsx2json');
xlsx2json(
    'test/xlsx/with_header_information_and_keys_row.xlsx',
    {
        dataStartingRow: 4,
        mapping: {
            'col_1': 'A',
            'col_2': 'B',
            'col_3': 'C'
        }
    }
}).then(jsonArray => { ... });
The jsonArray is as follows : )
[
    [
        {"col_1": "value 1-A", "col_1": "value 1-B", "col_3": "value 1-C"},
        {"col_1": "value 2-A", "col_2": "value 2-B", "col_3": "value 2-C"}
    ]
]

The result is the structure of a three-dimensional array.
In short, ``jsonArray[sheets][rows][cellValues]``
Alternatively, if the option.sheet is set (as a String or a Number), only specific sheet will be passed.