diff --git a/index.html b/index.html index b66807e..b8a9ff5 100644 --- a/index.html +++ b/index.html @@ -34,7 +34,8 @@ Output Format: JSON
FORMULAE
--> -
Drop an XLSX or XLSM or XLSB file here to see sheet data.
+
Drop an XLSX or XLSM or XLSB file here to see sheet data
+

... or click here to select a file


Advanced Demo Options:
@@ -182,7 +183,7 @@ function process_wb(wb) { var output = ""; switch(get_radio_value("format")) { case "json": - output = JSON.stringify(to_json(wb), 2, 2); + output = JSON.stringify(to_json(wb), 2, 2); break; case "form": output = to_formulae(wb); @@ -238,6 +239,39 @@ if(drop.addEventListener) { drop.addEventListener('dragover', handleDragover, false); drop.addEventListener('drop', handleDrop, false); } + + +var xlf = document.getElementById('xlf'); +function handleFile(e) { + rABS = document.getElementsByName("userabs")[0].checked; + use_worker = document.getElementsByName("useworker")[0].checked; + 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) { + if(typeof console !== 'undefined') console.log("onload", new Date(), rABS, use_worker); + var data = e.target.result; + if(use_worker) { + xlsxworker(data, process_wb); + } else { + var wb; + if(rABS) { + wb = XLSX.read(data, {type: 'binary'}); + } else { + var arr = fixdata(data); + wb = XLSX.read(btoa(arr), {type: 'base64'}); + } + process_wb(wb); + } + }; + if(rABS) reader.readAsBinaryString(f); + else reader.readAsArrayBuffer(f); + } +} + +if(xlf.addEventListener) xlf.addEventListener('change', handleFile, false);