Zaedus / excel-to-rows

Parses a spreadsheet and returns the rows as objects.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

excel-to-rows

Parses a spreadsheet and returns the rows as objects.

Examples

Read from a file

const excelToRows = require('excel-to-rows');

// Read as .xlsx file
excelToRows.fromXlsx("/path/to/file.xlsx");

// Read as .csv file
excelToRows.fromCsv("/path/to/file.csv");

// Read as automatically determined file type
excelToRows.from("/path/to/file");

Read from a stream

const excelToRows = require('excel-to-rows');
const fs = require('fs');

// Read as .xlsx file
excelToRow.fromXlsx(fs.createReadStream("/path/to/file.xlsx"));

// Read as .csv file
excelToRow.fromXlsx(fs.createReadStream("/path/to/file.csv"));

Example

data.xlsx

ID First Name Last Name Job
0 Albert Einstein Theoretical Physicist
1 Jeff Delaney JS Developer
2 Jeff Bezos CEO of Amazon

index.js

const excelToRows = require('excel-to-rows');

(async function() {
    console.log(await excelToRows.from("./data.xlsx"));
}())

Output:

[
  {
    ID: 0,
    'First Name': 'Albert',
    'Last Name': 'Einstein',
    Job: 'Theoretical Physicist'
  },
  {
    ID: 1,
    'First Name': 'Jeff',
    'Last Name': 'Delaney',
    Job: 'JS Developer'
  },
  {
    ID: 2,
    'First Name': 'Jeff',
    'Last Name': 'Bezos',
    Job: 'CEO of Amazon'
  }
]

About

Parses a spreadsheet and returns the rows as objects.


Languages

Language:JavaScript 76.1%Language:TypeScript 23.9%