Created
January 3, 2016 07:08
-
-
Save espl-saket/45ec3164b8ad6e066b18 to your computer and use it in GitHub Desktop.
Implementation of the SheetJs library to parse Excel workbooks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>SheetJs implementation</title> | |
</head> | |
<body> | |
<input type="file" id="inputFile" /> | |
<script src="http://oss.sheetjs.com/js-xlsx/jszip.js"></script> | |
<script src="http://oss.sheetjs.com/js-xlsx/ods.js"></script> | |
<script src="http://oss.sheetjs.com/js-xlsx/xlsx.js"></script> | |
<script> | |
function handleFile(e) { | |
var files = e.target.files; | |
var i,f; | |
for (i = 0, f = files[i]; i != files.length; ++i) { | |
var reader = new FileReader(); | |
var name = f.name; | |
reader.onload = function(e) { | |
var data = e.target.result; | |
var workbook = XLSX.read(data, {type: 'binary'}); | |
console.log(workbook); | |
}; | |
reader.readAsBinaryString(f); | |
} | |
} | |
document.getElementById("inputFile").addEventListener('change', handleFile, false); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment