Created
April 13, 2016 14:07
-
-
Save Millsky/fb9e37d69c9698221ff45679db4aa8ef 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
function convertToIntArray(hex){ | |
var bytes = [], | |
str; | |
for(var i=0; i<hex.length-1;i+=2){ | |
bytes.push(parseInt(hex.substr(i, 2), 16)) | |
} | |
return bytes; | |
} | |
var hex = | |
"504b03040A0000000000c37c8c4800000000000000000000000008000000746573742e747874504b010214000a0000000000c37c8c48000000000000000000000000080024000000000000002000000000000000746573742e7478740a0020000000000001001800d068f6d4f294d101d068f6d4f294d101d068f6d4f294d101504b050600000000010001005a000000260000000000"; | |
var bytes = convertToIntArray(hex); | |
options = {}; | |
options.fileName = "asd"; | |
var ab = new ArrayBuffer(bytes.length); | |
var ia = new Uint8Array(ab); | |
for (var i = 0; i < bytes.length; i++) { | |
ia[i] = bytes[i]; | |
} | |
var b = new Blob([ia], {type: "application/octet-stream"}); | |
var url = window.URL.createObjectURL(b), | |
a = document.createElement("a"); | |
document.body.appendChild(a); | |
a.href = url; | |
a.download = options ? options.fileName + "" : "excelReport.xls"; | |
a.click(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Downloads a zip file in your browser