diff --git a/Makefile b/Makefile index f3c3c1d..e8f0e7a 100644 --- a/Makefile +++ b/Makefile @@ -14,3 +14,4 @@ update: git show master:tests/mocha.css > tests/mocha.css git show master:tests/mocha.js > tests/mocha.js git show master:tests/xhr-hack.js > tests/xhr-hack.js + git show master:demos/datagrid/index.html > datagrid.html diff --git a/datagrid.html b/datagrid.html index 235c53f..31e386e 100644 --- a/datagrid.html +++ b/datagrid.html @@ -105,6 +105,8 @@ function process_wb(wb) { var data = XLSX.utils.sheet_to_json(ws, {header:1}); if(!cDg) cDg = canvasDatagrid({ parentNode:document.getElementById('htmlout'), data:data }); else cDg.data = data; + var range = XLSX.utils.decode_range(ws['!ref']); + for(var i = range.s.c; i <= range.e.c; ++i) cDg.schema[i - range.s.c].title = XLSX.utils.encode_col(i); document.getElementById('xport').disabled = false; if(typeof console !== 'undefined') console.log("output", new Date()); } diff --git a/tests/core.js b/tests/core.js index 156af81..c4aec3e 100644 --- a/tests/core.js +++ b/tests/core.js @@ -568,14 +568,14 @@ describe('input formats', function() { X.read(fs.readFileSync(paths.cstxlsb, 'base64'), {type: 'base64'}); }); var k = browser ? 'array' : 'buffer'; - (typeof UInt8Array !== 'undefined' ? it : it.skip)('should read ' + k + 's', function() { - X.read(fs.readFileSync(paths.cstxls, 'buffer'), {type: k}); - X.read(fs.readFileSync(paths.cstxml, 'buffer'), {type: k}); - X.read(fs.readFileSync(paths.cstods, 'buffer'), {type: k}); - X.read(fs.readFileSync(paths.cstxlsx, 'buffer'), {type: k}); - X.read(fs.readFileSync(paths.cstxlsb, 'buffer'), {type: k}); + (typeof Uint8Array !== 'undefined' ? it : it.skip)('should read ' + k + 's', function() { + X.read(fs.readFileSync(paths.cstxls, browser ? 'buffer' : null), {type: k}); + X.read(fs.readFileSync(paths.cstxml, browser ? 'buffer' : null), {type: k}); + X.read(fs.readFileSync(paths.cstods, browser ? 'buffer' : null), {type: k}); + X.read(fs.readFileSync(paths.cstxlsx, browser ? 'buffer' : null), {type: k}); + X.read(fs.readFileSync(paths.cstxlsb, browser ? 'buffer' : null), {type: k}); }); - (typeof UInt8Array !== 'undefined' ? it : it.skip)('should read array', function() { + (typeof Uint8Array !== 'undefined' ? it : it.skip)('should read array', function() { X.read(fs.readFileSync(paths.cstxls, 'binary').split("").map(function(x) { return x.charCodeAt(0); }), {type:'array'}); X.read(fs.readFileSync(paths.cstxml, 'binary').split("").map(function(x) { return x.charCodeAt(0); }), {type:'array'}); X.read(fs.readFileSync(paths.cstxlsx, 'binary').split("").map(function(x) { return x.charCodeAt(0); }), {type:'array'}); @@ -1845,6 +1845,40 @@ describe('csv', function() { }); }); +describe('HTML', function() { + describe('input', function(){ + var b = "
-0.08 | 4,001 | \u00e3\u0081\u0082 1 |
$41.08 | 11% |
0){if(e.strm.data_type===f){e.strm.data_type=le(e)}ne(e,e.l_desc);ne(e,e.d_desc);o=fe(e);i=e.opt_len+3+7>>>3;s=e.static_len+3+7>>>3;if(s<=i){i=s}}else{i=s=t+5}if(t+4<=i&&r!==-1){he(e,r,t,a)}else if(e.strategy===n||s===i){G(e,(c<<1)+(a?1:0),3);ae(e,D,O)}else{G(e,(u<<1)+(a?1:0),3);oe(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1);ae(e,e.dyn_ltree,e.dyn_dtree)}J(e);if(a){q(e)}}function pe(e,r,t){e.pending_buf[e.d_buf+e.last_lit*2]=r>>>8&255;e.pending_buf[e.d_buf+e.last_lit*2+1]=r&255;e.pending_buf[e.l_buf+e.last_lit]=t&255;e.last_lit++;if(r===0){e.dyn_ltree[t*2]++}else{e.matches++;r--;e.dyn_ltree[(P[t]+p+1)*2]++;e.dyn_dtree[z(r)*2]++}return e.last_lit===e.lit_bufsize-1}t._tr_init=ue;t._tr_stored_block=he;t._tr_flush_block=ve;t._tr_tally=pe;t._tr_align=de},{"../utils/common":27}],39:[function(e,r,t){"use strict";function a(){this.input=null;this.next_in=0;this.avail_in=0;this.total_in=0;this.output=null;this.next_out=0;this.avail_out=0;this.total_out=0;this.msg="";this.state=null;this.data_type=2;this.adler=0}r.exports=a},{}]},{},[9])(9)});var XLSX={};(function e(r){r.version="0.11.1";var t=1200;if(typeof module!=="undefined"&&typeof require!=="undefined"){if(typeof cptable==="undefined")global.cptable=undefined}function a(){n(1200)}var n=function(e){t=e};function i(e){var r=[];for(var t=0,a=e.length;t>1;++t)r[t]=String.fromCharCode(e.charCodeAt(2*t)+(e.charCodeAt(2*t+1)<<8));return r.join("")}function f(e){var r=[];for(var t=0;t 0){if(e.strm.data_type===f){e.strm.data_type=le(e)}ne(e,e.l_desc);ne(e,e.d_desc);o=fe(e);i=e.opt_len+3+7>>>3;s=e.static_len+3+7>>>3;if(s<=i){i=s}}else{i=s=t+5}if(t+4<=i&&r!==-1){he(e,r,t,a)}else if(e.strategy===n||s===i){G(e,(c<<1)+(a?1:0),3);ae(e,D,O)}else{G(e,(u<<1)+(a?1:0),3);oe(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1);ae(e,e.dyn_ltree,e.dyn_dtree)}J(e);if(a){q(e)}}function pe(e,r,t){e.pending_buf[e.d_buf+e.last_lit*2]=r>>>8&255;e.pending_buf[e.d_buf+e.last_lit*2+1]=r&255;e.pending_buf[e.l_buf+e.last_lit]=t&255;e.last_lit++;if(r===0){e.dyn_ltree[t*2]++}else{e.matches++;r--;e.dyn_ltree[(P[t]+p+1)*2]++;e.dyn_dtree[z(r)*2]++}return e.last_lit===e.lit_bufsize-1}t._tr_init=ue;t._tr_stored_block=he;t._tr_flush_block=ve;t._tr_tally=pe;t._tr_align=de},{"../utils/common":27}],39:[function(e,r,t){"use strict";function a(){this.input=null;this.next_in=0;this.avail_in=0;this.total_in=0;this.output=null;this.next_out=0;this.avail_out=0;this.total_out=0;this.msg="";this.state=null;this.data_type=2;this.adler=0}r.exports=a},{}]},{},[9])(9)});var XLSX={};(function e(r){r.version="0.11.2";var t=1200;if(typeof module!=="undefined"&&typeof require!=="undefined"){if(typeof cptable==="undefined")global.cptable=undefined}function a(){n(1200)}var n=function(e){t=e};function i(e){var r=[];for(var t=0,a=e.length;t>1;++t)r[t]=String.fromCharCode(e.charCodeAt(2*t)+(e.charCodeAt(2*t+1)<<8));return r.join("")}function f(e){var r=[];for(var t=0;ta.l)a=a.slice(0,a.l);if(a.length>0)e.push(a);a=null};var i=function c(e){if(a&&e":a.strike=1;break;case"":break;case"":;case"":a.u=1;break;case"":break;case"":;case"":a.b=1;break;case"":break;case"":;case"":a.i=1;break;case"":break;case"");t.push("")}if(i=="superscript")i="sup";else if(i=="subscript")i="sub";if(i!=""){r.push("<"+i+">");t.push(""+i+">")}t.push("");return n};function s(t){var a=[[],"",[]];var s=t.match(e),f=65001;if(!x(s))return"";a[1]=s[1];var o=t.match(r);if(x(o))f=i(o[1],a[0],a[2]);return a[0].join("")+a[1].replace(n,"
")+a[2].join("")}return function o(e){return e.replace(t,"").split(a).map(s).join("")}}();var Hu=/<(?:\w+:)?t[^>]*>([^<]*)<\/(?:\w+:)?t>/g,Wu=/<(?:\w+:)?r>/;var Vu=/<(?:\w+:)?rPh.*?>([\s\S]*?)<\/(?:\w+:)?rPh>/g;function zu(e,r){var t=r?r.cellHTML:true;var a={};if(!e)return null;var n;if(e.match(/^\s*<(?:\w+:)?t[^>]*>/)){a.t=Se(ue(e.substr(e.indexOf(">")+1).split(/<\/(?:\w+:)?t>/)[0]));a.r=Se(e);if(t)a.h=me(a.t)}else if(n=e.match(Wu)){a.r=Se(e);a.t=Se(ue((e.replace(Vu,"").match(Hu)||[]).join("").replace(ne,"")));if(t)a.h=Uu(a.r)}return a}var Xu=/<(?:\w+:)?sst([^>]*)>([\s\S]*)<\/(?:\w+:)?sst>/;var Gu=/<(?:\w+:)?(?:si|sstItem)>/g;var ju=/<\/(?:\w+:)?(?:si|sstItem)>/;function Ku(e,r){var t=[],a="";if(!e)return t;var n=e.match(Xu);if(x(n)){a=n[2].replace(Gu,"").split(ju);for(var i=0;i!=a.length;++i){var s=zu(a[i].trim(),r);if(s!=null)t[t.length]=s}n=fe(n[1]);t.Count=n.count;t.Unique=n.uniqueCount}return t}sa.SST="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings";var Yu=/^\s|\s$|[\t\n\r]/;function $u(e,r){if(!r.bookSST)return"";var t=[Ne];t[t.length]=Oe("sst",null,{xmlns:Le.main[0],count:e.Count,uniqueCount:e.Unique});for(var a=0;a!=e.length;++a){if(e[a]==null)continue;var n=e[a];var i="":n.strike=1;break;case""+s+"
");a.push(cE(i,r,e,t));return a.join("")}function bE(e,r){var t=[];t.push(fE(e,r));t.push(oE(e,r));t.push(lE(e,r));for(var a=0;a]*>)/i);var l=-1,u=0,h=0,d=0;var v={s:{r:1e7,c:1e7},e:{r:0,c:0}};var p=[],b=0;for(s=0;s ";return p+i.join("")+" "}function a(e,r,t){var a=[];return a.join("")+""}var n='
"+l);return c.join("")}return{to_workbook:r,to_sheet:e,_row:t,BEGIN:n,END:i,_preamble:a,from_sheet:s}}();function ME(e,r){var t=r||{};if(c!=null)t.dense=c;var a=t.dense?[]:{};var n=e.getElementsByTagName("tr");var i={s:{r:0,c:0},e:{r:n.length-1,c:0}};var s=[],f=0;var o=0,l=0,u=0,h=0,d=0;for(;oa.l)a=a.slice(0,a.l);if(a.length>0)e.push(a);a=null};var i=function c(e){if(a&&e