forked from sheetjs/sheetjs
Worker HTML update [ci skip]
This commit is contained in:
parent
33fbc389c5
commit
509f7bf9c7
17
index.html
17
index.html
@ -1,5 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<!-- xlsx.js (C) 2013-2014 SheetJS http://sheetjs.com -->
|
<!-- xlsx.js (C) 2013-2014 SheetJS http://sheetjs.com -->
|
||||||
|
<!-- vim: set ts=2: -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
@ -34,6 +35,14 @@
|
|||||||
<script src="xlsx.js"></script>
|
<script src="xlsx.js"></script>
|
||||||
<script>
|
<script>
|
||||||
var rABS = typeof FileReader !== "undefined" && typeof FileReader.prototype !== "undefined" && typeof FileReader.prototype.readAsBinaryString !== "undefined";
|
var rABS = typeof FileReader !== "undefined" && typeof FileReader.prototype !== "undefined" && typeof FileReader.prototype.readAsBinaryString !== "undefined";
|
||||||
|
function fixdata(data) {
|
||||||
|
var o = "", l = 0, w = 10240;
|
||||||
|
for(; l<data.byteLength/w; ++l)
|
||||||
|
o+=String.fromCharCode.apply(null,new Uint8Array(data.slice(l*w,l*w+w)));
|
||||||
|
o+=String.fromCharCode.apply(null, new Uint8Array(data.slice(o.length)));
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
function xlsxworker(data, cb) {
|
function xlsxworker(data, cb) {
|
||||||
var worker = new Worker('./xlsxworker.js');
|
var worker = new Worker('./xlsxworker.js');
|
||||||
worker.onmessage = function(e) {
|
worker.onmessage = function(e) {
|
||||||
@ -43,7 +52,7 @@ function xlsxworker(data, cb) {
|
|||||||
case 'xlsx': cb(JSON.parse(e.data.d)); break;
|
case 'xlsx': cb(JSON.parse(e.data.d)); break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var arr = rABS ? data : btoa(String.fromCharCode.apply(null, new Uint8Array(data)));
|
var arr = rABS ? data : btoa(fixdata(data));
|
||||||
worker.postMessage({d:arr,b:rABS});
|
worker.postMessage({d:arr,b:rABS});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,11 +112,11 @@ function process_wb(wb) {
|
|||||||
var output = "";
|
var output = "";
|
||||||
switch(get_radio_value("format")) {
|
switch(get_radio_value("format")) {
|
||||||
case "json":
|
case "json":
|
||||||
output = JSON.stringify(to_json(wb), 2, 2);
|
output = JSON.stringify(to_json(wb), 2, 2);
|
||||||
break;
|
break;
|
||||||
case "form":
|
case "form":
|
||||||
output = to_formulae(wb);
|
output = to_formulae(wb);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
output = to_csv(wb);
|
output = to_csv(wb);
|
||||||
}
|
}
|
||||||
@ -133,7 +142,7 @@ function handleDrop(e) {
|
|||||||
if(rABS) {
|
if(rABS) {
|
||||||
wb = XLSX.read(data, {type: 'binary'});
|
wb = XLSX.read(data, {type: 'binary'});
|
||||||
} else {
|
} else {
|
||||||
var arr = String.fromCharCode.apply(null, new Uint8Array(data));
|
var arr = fixdata(data);
|
||||||
wb = XLSX.read(btoa(arr), {type: 'base64'});
|
wb = XLSX.read(btoa(arr), {type: 'base64'});
|
||||||
}
|
}
|
||||||
process_wb(wb);
|
process_wb(wb);
|
||||||
|
Loading…
Reference in New Issue
Block a user