Created
July 23, 2016 16:32
-
-
Save theredstapler/5ce6a43b066dbe0cac3fa5587835be91 to your computer and use it in GitHub Desktop.
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
<!doctype html> | |
<html> | |
<head> | |
<title>Excel to JSON Demo</title> | |
<script src="xlsx.full.min.js"></script> | |
</head> | |
<body> | |
<script> | |
/* set up XMLHttpRequest */ | |
var url = "test.xlsx"; | |
var oReq = new XMLHttpRequest(); | |
oReq.open("GET", url, true); | |
oReq.responseType = "arraybuffer"; | |
oReq.onload = function(e) { | |
var arraybuffer = oReq.response; | |
/* convert data to binary string */ | |
var data = new Uint8Array(arraybuffer); | |
var arr = new Array(); | |
for(var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]); | |
var bstr = arr.join(""); | |
/* Call XLSX */ | |
var workbook = XLSX.read(bstr, {type:"binary"}); | |
/* DO SOMETHING WITH workbook HERE */ | |
var first_sheet_name = workbook.SheetNames[0]; | |
/* Get worksheet */ | |
var worksheet = workbook.Sheets[first_sheet_name]; | |
console.log(XLSX.utils.sheet_to_json(worksheet,{raw:true})); | |
} | |
oReq.send(); | |
</script> | |
</body> | |
</html> |
How can we implement the same in Vue 2.0???
Yes, you only need to add <script src="xlsx.full.min.js"></script>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can we implement the same in Vue 2.0???