1.0.3 • Published 4 years ago
excel-to-rows v1.0.3
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
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'
}
]