Skip to content

Instantly share code, notes, and snippets.

@espl-saket
Created January 3, 2016 07:08
Show Gist options
  • Save espl-saket/45ec3164b8ad6e066b18 to your computer and use it in GitHub Desktop.
Save espl-saket/45ec3164b8ad6e066b18 to your computer and use it in GitHub Desktop.
Implementation of the SheetJs library to parse Excel workbooks
<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