2016-12-31 08:20:45 +00:00
|
|
|
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
|
2014-06-29 18:29:45 +00:00
|
|
|
/* uncomment the next line for encoding support */
|
2017-03-09 05:24:32 +00:00
|
|
|
importScripts('dist/cpexcel.js');
|
2014-06-29 18:29:45 +00:00
|
|
|
importScripts('jszip.js');
|
|
|
|
importScripts('xlsx.js');
|
2014-10-10 02:22:38 +00:00
|
|
|
/* uncomment the next line for ODS support */
|
|
|
|
importScripts('dist/ods.js');
|
2014-06-29 18:29:45 +00:00
|
|
|
postMessage({t:"ready"});
|
|
|
|
|
|
|
|
function ab2str(data) {
|
|
|
|
var o = "", l = 0, w = 10240;
|
2017-03-05 00:56:31 +00:00
|
|
|
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(l*w)));
|
2014-06-29 18:29:45 +00:00
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
function s2ab(s) {
|
|
|
|
var b = new ArrayBuffer(s.length*2), v = new Uint16Array(b);
|
|
|
|
for (var i=0; i != s.length; ++i) v[i] = s.charCodeAt(i);
|
|
|
|
return [v, b];
|
|
|
|
}
|
|
|
|
|
|
|
|
onmessage = function (oEvent) {
|
|
|
|
var v;
|
|
|
|
try {
|
|
|
|
v = XLSX.read(ab2str(oEvent.data), {type: 'binary'});
|
|
|
|
} catch(e) { postMessage({t:"e",d:e.stack}); }
|
|
|
|
var res = {t:"xlsx", d:JSON.stringify(v)};
|
|
|
|
var r = s2ab(res.d)[1];
|
2017-02-03 20:50:45 +00:00
|
|
|
postMessage(r, [r]);
|
2014-06-29 18:29:45 +00:00
|
|
|
};
|