Skip to content

Instantly share code, notes, and snippets.

@Praseetha-KR
Created September 21, 2015 12:53
Show Gist options
  • Save Praseetha-KR/eb81f2b28b5b55699596 to your computer and use it in GitHub Desktop.
Save Praseetha-KR/eb81f2b28b5b55699596 to your computer and use it in GitHub Desktop.
Excel to JSON, dependency https://github.com/SheetJS/js-xlsx
'use strict';
let XLSX = require('xlsx');
let workbook = XLSX.readFile(process.argv[3]);
let sheets = workbook.Workbook.Sheets.map(obj => obj.name);
let mails = sheets.reduce((acc, elem) => {
let sheet = workbook.Sheets[elem];
let mailArr = Object.keys(sheet).map(cell => sheet[cell].v).filter(val => val).filter((val, index) => index);
return acc.concat(mailArr);
}, []);
console.log(JSON.stringify(mails, null, '\t'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment