1// the simplest way to read excel is to use sheetjs
2// https://github.com/SheetJS/sheetjs
3
4// A. in nodejs
5var XLSX = require('xlsx');
6var workbook = XLSX.readFile('test.xlsx');
7/* DO SOMETHING WITH workbook HERE */
8
9// B. in browser
10// 1. first include the library
11// <script src="dist/xlsx.full.min.js"></script>
12
13// 2. handle the file upload in a script
14
15function handleFile(e) {
16 var files = e.target.files, f = files[0];
17 var reader = new FileReader();
18 reader.onload = function(e) {
19 var data = new Uint8Array(e.target.result);
20 var workbook = XLSX.read(data, {type: 'array'});
21
22 /* DO SOMETHING WITH workbook HERE */
23 };
24 reader.readAsArrayBuffer(f);
25}
26input_dom_element.addEventListener('change', handleFile, false);
27