Extracte a columns/rows from XLSX file.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
src
.eslintrc
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
package.json

README.md

xlsx-extractor

Support Node of LTS npm version Build Status Document Standard - JavaScript Style Guide

Extract the colums/rows from XLSX file.

Installation

$ npm install xlsx-extractor

Usage

Node API

Specify index and extract as a single sheet.

const XlsxExtractor = require('xlsx-extractor');

const extractor = new XlsxExtractor('./sample.xlsx');
const tasks     = [];
for (let i = 1, max = extractor.count; i <= max; ++i) {
  tasks.push(extractor.extract(i));
}

Promise
  .all(tasks)
  .then((results) => {
    console.log(JSON.stringify(results, null, '  ') + '\n');
  })
  .catch((err) => {
    console.error(err);
  });

Extract all sheets at once.

const XlsxExtractor = require('xlsx-extractor');

const extractor = new XlsxExtractor('./sample.xlsx');

extractor
  .extractAll()
  .then((results) => {
    console.log(JSON.stringify(results, null, '  ') + '\n');
  })
  .catch((err) => {
    console.error(err);
  });

constructor

new XlsxExtractor(path)

Name Type Description
path String Path of the XLSX file.

count

XlsxExtractor.count is a number of sheets.

extract

XlsxExtractor.extract(index) is promisify.

Name Type Description
index Number Number of the extract sheet.

result (Primise then):

Name Type Description
id Number Number of the extract sheets.
name String Name of the sheet.
cells Array<String[]> Cells of the sheet. Empty cell is stored is "".

extractAll

XlsxExtractor.extractAll() is promisify.

result (Primise then):

Returns the result of XlsxExtractor.extract as an Array of sheets.

CLI

Usage: xlsx-extractor [OPTIONS]

  Extract the colums/rows from XLSX file.

  Options:
    -h, --help    Display this text.
    -v, --version Display the version number.
    -i, --input   Path of the XLSX file.
    -r, --range   Range of sheets to be output.
                  Specify the numeric value of "N" or "N-N".
                  When omitted will output all of the sheet.
    -c, --count   Outputs the number of sheet.
                  This option overrides the -r and --range.

  Examples:
    $ xlsx-extractor -i sample.xlsx
    $ xlsx-extractor -i sample.xlsx -c
    $ xlsx-extractor -i sample.xlsx -r 3
    $ xlsx-extractor -i sample.xlsx -r 1-5

  See also:
    https://github.com/akabekobeko/npm-xlsx-extractor/issues

ChangeLog

License