diff --git a/.gitignore b/.gitignore index 0c19414..f8d01c1 100644 --- a/.gitignore +++ b/.gitignore @@ -13,8 +13,8 @@ tmp *.[pP][rR][nN] *.[sS][lL][kK] *.socialcalc -*.[xX][lL][sSwWcC] -*.[xX][lL][sS][xXmMbB] +*.[xX][lL][sSwWcCaAtT] +*.[xX][lL][sSaAtT][xXmMbB] *.[oO][dD][sS] *.[fF][oO][dD][sS] *.[xX][mM][lL] diff --git a/tests/core.js b/tests/core.js index 3845f9c..bde5fed 100644 --- a/tests/core.js +++ b/tests/core.js @@ -1673,6 +1673,15 @@ describe('json output', function() { assert.equal(json1[2][1], 5); assert.equal(json1[2][3], 3); }); + it('should preserve values when column header is missing', function() { + /*jshint elision:true */ + var _data = [[,"a","b",,"c"], [1,2,3,,5],[,3,4,5,6]]; + /*jshint elision:false */ + var _ws = X.utils.aoa_to_sheet(_data); + var json1 = X.utils.sheet_to_json(_ws, { raw: true }); + assert.equal(json1[0].__EMPTY, 1); + assert.equal(json1[1].__EMPTY_1, 5); + }); }); @@ -1891,6 +1900,11 @@ describe('HTML', function() { it('should interpret values by default', function() { plaintext_test(X.read(html_bstr, {type:"binary"}), false, false); }); it('should generate strings if raw option is passed', function() { plaintext_test(X.read(html_bstr, {type:"binary", raw:true}), true, false); }); it('should handle "string" type', function() { plaintext_test(X.read(html_str, {type:"string"}), false, false); }); + it('should handle newlines correctly', function() { + var table = "
foo bar | baz |
0){if(e.strm.data_type===o){e.strm.data_type=fe(e)}ne(e,e.l_desc);ne(e,e.d_desc);l=oe(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);le(e,e.l_desc.max_code+1,e.d_desc.max_code+1,l+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[V(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.14";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 o(e){var r=[];for(var t=0;t 0){if(e.strm.data_type===o){e.strm.data_type=fe(e)}ne(e,e.l_desc);ne(e,e.d_desc);l=oe(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);le(e,e.l_desc.max_code+1,e.d_desc.max_code+1,l+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[V(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.15";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 o(e){var r=[];for(var t=0;t0&&u!==R)_[u].name="!MiniFAT";_[v[0]].name="!FAT";_.fat_addrs=v;_.ssz=a;var B={},T=[],x=[],I=[];k(s,_,C,T,n,B,x,u);c(x,I,T);T.shift();var A={FileIndex:x,FullPaths:I};if(r&&r.raw)A.raw={header:m,sectors:C};return A}function o(e){e.chk(D,"Header Signature: ");e.chk(F,"CLSID: ");var r=e._R(2,"u");return[e._R(2,"u"),r]}function l(e,r){var t=9;e.l+=2;switch(t=e._R(2)){case 9:if(r!=3)throw new Error("Sector Shift: Expected 9 saw "+t);break;case 12:if(r!=4)throw new Error("Sector Shift: Expected 12 saw "+t);break;default:throw new Error("Sector Shift: Expected 9 or 12 saw "+t);}e.chk("0600","Mini Sector Shift: ");e.chk("000000000000","Reserved: ")}function f(e,r){var t=Math.ceil(e.length/r)-1;var a=[];for(var n=1;na.l)a=a.slice(0,a.l);if(a.length>0)e.push(a);a=null};var i=function c(e){if(a&&ea.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),o=65001;if(!x(s))return"";a[1]=s[1];var l=t.match(r);if(x(l))o=i(l[1],a[0],a[2]);return a[0].join("")+a[1].replace(n,"
")+a[2].join("")}return function l(e){return e.replace(t,"").split(a).map(s).join("")}}();var Ds=/<(?:\w+:)?t[^>]*>([^<]*)<\/(?:\w+:)?t>/g,Os=/<(?:\w+:)?r>/;var Fs=/<(?:\w+:)?rPh.*?>([\s\S]*?)<\/(?:\w+:)?rPh>/g;function Ps(e,r){var t=r?r.cellHTML:true;var a={};if(!e)return null;var n;if(e.match(/^\s*<(?:\w+:)?t[^>]*>/)){a.t=pe(Be(e.slice(e.indexOf(">")+1).split(/<\/(?:\w+:)?t>/)[0]||""));a.r=Be(e);if(t)a.h=we(a.t)}else if(n=e.match(Os)){a.r=Be(e);a.t=pe(Be((e.replace(Fs,"").match(Ds)||[]).join("").replace(le,"")));if(t)a.h=Rs(a.r)}return a}var Ns=/<(?:\w+:)?sst([^>]*)>([\s\S]*)<\/(?:\w+:)?sst>/;var Ls=/<(?:\w+:)?(?:si|sstItem)>/g;var Ms=/<\/(?:\w+:)?(?:si|sstItem)>/;function Us(e,r){var t=[],a="";if(!e)return t;var n=e.match(Ns);if(x(n)){a=n[2].replace(Ls,"").split(Ms);for(var i=0;i!=a.length;++i){var s=Ps(a[i].trim(),r);if(s!=null)t[t.length]=s}n=ue(n[1]);t.Count=n.count;t.Unique=n.uniqueCount}return t}ha.SST="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings";var Hs=/^\s|\s$|[\t\n\r]/;function Ws(e,r){if(!r.bookSST)return"";var t=[se];t[t.length]=Ue("sst",null,{xmlns:ze.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"