Parses a spreadsheet and returns the rows as objects.
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");
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"));
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'
}
]