From e6f8b84ec1ca93eb0e5106498b2b53d2266c960d Mon Sep 17 00:00:00 2001 From: Travis Clarke Date: Wed, 7 Dec 2016 00:53:54 -0800 Subject: [PATCH] v4.0.0-alpha.3 - fix 'rowspan' logic --- README.md | 2 +- bower.json | 2 +- dist/css/tableexport.css | 2 +- dist/css/tableexport.min.css | 2 +- dist/js/tableexport.js | 24 ++++++++++++++++++------ dist/js/tableexport.min.js | 4 ++-- package.json | 2 +- src/stable/css/tableexport.css | 2 +- src/stable/css/tableexport.min.css | 2 +- src/stable/js/tableexport.js | 24 ++++++++++++++++++------ src/stable/js/tableexport.min.js | 4 ++-- 11 files changed, 47 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 9859ac0..adf3cc1 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ $ npm install tableexport * [jQuery](https://jquery.com) (1.2.1 or higher) `*` * [FileSaver.js](https://github.com/clarketm/FileSaver.js/) -> `*` jQuery dependency requirement is removed as of [4.0.0-alpha.2](https://github.com/clarketm/TableExport/tree/v4.0.0-alpha.2) +> `*` jQuery dependency requirement is removed as of [4.0.0-alpha.3](https://github.com/clarketm/TableExport/tree/v4.0.0-alpha.3) #### Optional / Theming: diff --git a/bower.json b/bower.json index 51318f0..39b1adf 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "tableexport.js", - "version": "4.0.0-alpha.2", + "version": "4.0.0-alpha.3", "authors": [ "clarketm " ], diff --git a/dist/css/tableexport.css b/dist/css/tableexport.css index fe500cb..88009bc 100644 --- a/dist/css/tableexport.css +++ b/dist/css/tableexport.css @@ -1,5 +1,5 @@ /*! - * TableExport.js 4.0.0-alpha.2 (https://www.travismclarke.com) + * TableExport.js 4.0.0-alpha.3 (https://www.travismclarke.com) * Copyright 2016 Travis Clarke * Licensed under the MIT license */ diff --git a/dist/css/tableexport.min.css b/dist/css/tableexport.min.css index 3dff191..4e39a03 100644 --- a/dist/css/tableexport.min.css +++ b/dist/css/tableexport.min.css @@ -1,5 +1,5 @@ /*! - * TableExport.js 4.0.0-alpha.2 (https://www.travismclarke.com) + * TableExport.js 4.0.0-alpha.3 (https://www.travismclarke.com) * Copyright 2016 Travis Clarke * Licensed under the MIT license */.top{caption-side:top}.bottom{caption-side:bottom}.button-default,.button-default:active,.button-default:focus,.button-default:hover{text-decoration:none}.button-default{font:700 12px sans-serif;color:#222;cursor:pointer;padding:5px;margin:5px}.button-default.csv:before,.button-default.txt:before,.button-default.xls:before,.button-default.xlsx:before{content:none}.csv:before,.txt:before,.xls:before,.xlsx:before{content:""}.csv,.txt,.xls,.xlsx{margin:4px 0}.csv:before,.txt:before,.xls:before,.xlsx:before{margin-right:10px;padding:11px 15px 12px;box-shadow:1px 1px 2px rgba(0,0,0,.2)}.xlsx:before{background:url(../img/xlsx.svg) center no-repeat #006400}.xls:before{background:url(../img/xls.svg) center no-repeat green}.csv:before{background:url(../img/csv.svg) center no-repeat #00f}.txt:before{background:url(../img/txt.svg) center no-repeat purple} \ No newline at end of file diff --git a/dist/js/tableexport.js b/dist/js/tableexport.js index 6c782ee..8be72ab 100644 --- a/dist/js/tableexport.js +++ b/dist/js/tableexport.js @@ -1,5 +1,5 @@ /*! - * TableExport.js 4.0.0-alpha.2 (https://www.travismclarke.com) + * TableExport.js 4.0.0-alpha.3 (https://www.travismclarke.com) * Copyright 2016 Travis Clarke * Licensed under the MIT license */ @@ -86,8 +86,14 @@ rcMap[ir + i][ic] = 1 } } - if (rcMap[ir] && rcMap[ir][ic]) { - return new Array(rcMap[ir][ic]).concat(val.textContent); + if (rcMap[ir]) { + var total = 0, + min = Math.min.apply(Math, Object.keys(rcMap[ir])), + max = Math.max.apply(Math, Object.keys(rcMap[ir])); + while (min < max && rcMap[ir][min]) { + total += rcMap[ir][min] && delete rcMap[ir][min++]; + } + return new Array(total).concat(val.textContent); } return val.textContent; }); @@ -127,8 +133,14 @@ rcMap[ir + i][ic] = 1 } } - if (rcMap[ir] && rcMap[ir][ic]) { - return new Array(rcMap[ir][ic]).concat(val.textContent); + if (rcMap[ir]) { + var total = 0, + min = Math.min.apply(Math, Object.keys(rcMap[ir])), + max = Math.max.apply(Math, Object.keys(rcMap[ir])); + while (min < max && rcMap[ir][min]) { + total += rcMap[ir][min] && delete rcMap[ir][min++]; + } + return new Array(total).concat(val.textContent); } return val.textContent; }); @@ -277,7 +289,7 @@ * Version. * @memberof TableExport.prototype */ - version: "4.0.0-alpha.2", + version: "4.0.0-alpha.3", /** * Default plugin options. * @memberof TableExport.prototype diff --git a/dist/js/tableexport.min.js b/dist/js/tableexport.min.js index dd59a12..c4d9e40 100644 --- a/dist/js/tableexport.min.js +++ b/dist/js/tableexport.min.js @@ -1,6 +1,6 @@ /*! - * TableExport.js 4.0.0-alpha.2 (https://www.travismclarke.com) + * TableExport.js 4.0.0-alpha.3 (https://www.travismclarke.com) * Copyright 2016 Travis Clarke * Licensed under the MIT license */ -!function(t,e){"function"==typeof define&&define.amd?define(["exports","jquery","blobjs","file-saverjs","xlsx-js"],e):"object"==typeof exports&&"string"!=typeof exports.nodeName?e(exports,require("jquery"),require("blobjs"),require("file-saverjs"),require("xlsx-js")):e(t,t.jQuery,t.Blob,t.saveAs,t.XLSX)}(this,function(t,e,o,n,r){"use strict";function s(){for(var t=arguments,e=1;e tr")),b=n.settings.headings?i(t.querySelectorAll("thead > tr")).concat(b):b,b=n.settings.footers?i(t.querySelectorAll("tfoot > tr")).concat(b):b,h=n.settings.headings?t.querySelectorAll("thead > tr").length:0,v="id"===n.settings.fileName?t.getAttribute("id")?t.getAttribute("id"):p.prototype.defaultFileName:n.settings.fileName,S={xlsx:function(t,e){var o={},n=i(b).map(function(t,e){if(!~y.indexOf(e-h)&&!l(t,d)){var n=t.querySelectorAll("th, td");return i(n).map(function(t,n){if(!~m.indexOf(n)&&!l(t,d)){if(l(t,g))return" ";if(t.hasAttribute("colspan")&&(o[e]=o[e]||{},o[e][n+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var r=1;r":">","'":"'","/":"/"},xlsx:{defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls"},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv"},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt"},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return p.prototype.entityMap[t]})},dateNum:function(t,e){e&&(t+=1462);var o=Date.parse(t);return(o-new Date(Date.UTC(1899,11,30)))/864e5},createSheet:function(t){for(var e={},o={s:{c:1e7,r:1e7},e:{c:0,r:0}},n=0;n!=t.length;++n)for(var s=0;s!=t[n].length;++s){o.s.r>n&&(o.s.r=n),o.s.c>s&&(o.s.c=s),o.e.r tr")),b=n.settings.headings?i(t.querySelectorAll("thead > tr")).concat(b):b,b=n.settings.footers?i(t.querySelectorAll("tfoot > tr")).concat(b):b,g=n.settings.headings?t.querySelectorAll("thead > tr").length:0,v="id"===n.settings.fileName?t.getAttribute("id")?t.getAttribute("id"):p.prototype.defaultFileName:n.settings.fileName,S={xlsx:function(t,e){var o={},n=i(b).map(function(t,e){if(!~x.indexOf(e-g)&&!l(t,d)){var n=t.querySelectorAll("th, td");return i(n).map(function(t,n){if(!~m.indexOf(n)&&!l(t,d)){if(l(t,h))return" ";if(t.hasAttribute("colspan")&&(o[e]=o[e]||{},o[e][n+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var r=1;r":">","'":"'","/":"/"},xlsx:{defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls"},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv"},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt"},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return p.prototype.entityMap[t]})},dateNum:function(t,e){e&&(t+=1462);var o=Date.parse(t);return(o-new Date(Date.UTC(1899,11,30)))/864e5},createSheet:function(t){for(var e={},o={s:{c:1e7,r:1e7},e:{c:0,r:0}},n=0;n!=t.length;++n)for(var s=0;s!=t[n].length;++s){o.s.r>n&&(o.s.r=n),o.s.c>s&&(o.s.c=s),o.e.r" ], diff --git a/src/stable/css/tableexport.css b/src/stable/css/tableexport.css index fe500cb..88009bc 100644 --- a/src/stable/css/tableexport.css +++ b/src/stable/css/tableexport.css @@ -1,5 +1,5 @@ /*! - * TableExport.js 4.0.0-alpha.2 (https://www.travismclarke.com) + * TableExport.js 4.0.0-alpha.3 (https://www.travismclarke.com) * Copyright 2016 Travis Clarke * Licensed under the MIT license */ diff --git a/src/stable/css/tableexport.min.css b/src/stable/css/tableexport.min.css index 3dff191..4e39a03 100644 --- a/src/stable/css/tableexport.min.css +++ b/src/stable/css/tableexport.min.css @@ -1,5 +1,5 @@ /*! - * TableExport.js 4.0.0-alpha.2 (https://www.travismclarke.com) + * TableExport.js 4.0.0-alpha.3 (https://www.travismclarke.com) * Copyright 2016 Travis Clarke * Licensed under the MIT license */.top{caption-side:top}.bottom{caption-side:bottom}.button-default,.button-default:active,.button-default:focus,.button-default:hover{text-decoration:none}.button-default{font:700 12px sans-serif;color:#222;cursor:pointer;padding:5px;margin:5px}.button-default.csv:before,.button-default.txt:before,.button-default.xls:before,.button-default.xlsx:before{content:none}.csv:before,.txt:before,.xls:before,.xlsx:before{content:""}.csv,.txt,.xls,.xlsx{margin:4px 0}.csv:before,.txt:before,.xls:before,.xlsx:before{margin-right:10px;padding:11px 15px 12px;box-shadow:1px 1px 2px rgba(0,0,0,.2)}.xlsx:before{background:url(../img/xlsx.svg) center no-repeat #006400}.xls:before{background:url(../img/xls.svg) center no-repeat green}.csv:before{background:url(../img/csv.svg) center no-repeat #00f}.txt:before{background:url(../img/txt.svg) center no-repeat purple} \ No newline at end of file diff --git a/src/stable/js/tableexport.js b/src/stable/js/tableexport.js index 6c782ee..8be72ab 100644 --- a/src/stable/js/tableexport.js +++ b/src/stable/js/tableexport.js @@ -1,5 +1,5 @@ /*! - * TableExport.js 4.0.0-alpha.2 (https://www.travismclarke.com) + * TableExport.js 4.0.0-alpha.3 (https://www.travismclarke.com) * Copyright 2016 Travis Clarke * Licensed under the MIT license */ @@ -86,8 +86,14 @@ rcMap[ir + i][ic] = 1 } } - if (rcMap[ir] && rcMap[ir][ic]) { - return new Array(rcMap[ir][ic]).concat(val.textContent); + if (rcMap[ir]) { + var total = 0, + min = Math.min.apply(Math, Object.keys(rcMap[ir])), + max = Math.max.apply(Math, Object.keys(rcMap[ir])); + while (min < max && rcMap[ir][min]) { + total += rcMap[ir][min] && delete rcMap[ir][min++]; + } + return new Array(total).concat(val.textContent); } return val.textContent; }); @@ -127,8 +133,14 @@ rcMap[ir + i][ic] = 1 } } - if (rcMap[ir] && rcMap[ir][ic]) { - return new Array(rcMap[ir][ic]).concat(val.textContent); + if (rcMap[ir]) { + var total = 0, + min = Math.min.apply(Math, Object.keys(rcMap[ir])), + max = Math.max.apply(Math, Object.keys(rcMap[ir])); + while (min < max && rcMap[ir][min]) { + total += rcMap[ir][min] && delete rcMap[ir][min++]; + } + return new Array(total).concat(val.textContent); } return val.textContent; }); @@ -277,7 +289,7 @@ * Version. * @memberof TableExport.prototype */ - version: "4.0.0-alpha.2", + version: "4.0.0-alpha.3", /** * Default plugin options. * @memberof TableExport.prototype diff --git a/src/stable/js/tableexport.min.js b/src/stable/js/tableexport.min.js index dd59a12..c4d9e40 100644 --- a/src/stable/js/tableexport.min.js +++ b/src/stable/js/tableexport.min.js @@ -1,6 +1,6 @@ /*! - * TableExport.js 4.0.0-alpha.2 (https://www.travismclarke.com) + * TableExport.js 4.0.0-alpha.3 (https://www.travismclarke.com) * Copyright 2016 Travis Clarke * Licensed under the MIT license */ -!function(t,e){"function"==typeof define&&define.amd?define(["exports","jquery","blobjs","file-saverjs","xlsx-js"],e):"object"==typeof exports&&"string"!=typeof exports.nodeName?e(exports,require("jquery"),require("blobjs"),require("file-saverjs"),require("xlsx-js")):e(t,t.jQuery,t.Blob,t.saveAs,t.XLSX)}(this,function(t,e,o,n,r){"use strict";function s(){for(var t=arguments,e=1;e tr")),b=n.settings.headings?i(t.querySelectorAll("thead > tr")).concat(b):b,b=n.settings.footers?i(t.querySelectorAll("tfoot > tr")).concat(b):b,h=n.settings.headings?t.querySelectorAll("thead > tr").length:0,v="id"===n.settings.fileName?t.getAttribute("id")?t.getAttribute("id"):p.prototype.defaultFileName:n.settings.fileName,S={xlsx:function(t,e){var o={},n=i(b).map(function(t,e){if(!~y.indexOf(e-h)&&!l(t,d)){var n=t.querySelectorAll("th, td");return i(n).map(function(t,n){if(!~m.indexOf(n)&&!l(t,d)){if(l(t,g))return" ";if(t.hasAttribute("colspan")&&(o[e]=o[e]||{},o[e][n+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var r=1;r":">","'":"'","/":"/"},xlsx:{defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls"},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv"},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt"},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return p.prototype.entityMap[t]})},dateNum:function(t,e){e&&(t+=1462);var o=Date.parse(t);return(o-new Date(Date.UTC(1899,11,30)))/864e5},createSheet:function(t){for(var e={},o={s:{c:1e7,r:1e7},e:{c:0,r:0}},n=0;n!=t.length;++n)for(var s=0;s!=t[n].length;++s){o.s.r>n&&(o.s.r=n),o.s.c>s&&(o.s.c=s),o.e.r tr")),b=n.settings.headings?i(t.querySelectorAll("thead > tr")).concat(b):b,b=n.settings.footers?i(t.querySelectorAll("tfoot > tr")).concat(b):b,g=n.settings.headings?t.querySelectorAll("thead > tr").length:0,v="id"===n.settings.fileName?t.getAttribute("id")?t.getAttribute("id"):p.prototype.defaultFileName:n.settings.fileName,S={xlsx:function(t,e){var o={},n=i(b).map(function(t,e){if(!~x.indexOf(e-g)&&!l(t,d)){var n=t.querySelectorAll("th, td");return i(n).map(function(t,n){if(!~m.indexOf(n)&&!l(t,d)){if(l(t,h))return" ";if(t.hasAttribute("colspan")&&(o[e]=o[e]||{},o[e][n+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var r=1;r":">","'":"'","/":"/"},xlsx:{defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls"},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv"},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt"},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return p.prototype.entityMap[t]})},dateNum:function(t,e){e&&(t+=1462);var o=Date.parse(t);return(o-new Date(Date.UTC(1899,11,30)))/864e5},createSheet:function(t){for(var e={},o={s:{c:1e7,r:1e7},e:{c:0,r:0}},n=0;n!=t.length;++n)for(var s=0;s!=t[n].length;++s){o.s.r>n&&(o.s.r=n),o.s.c>s&&(o.s.c=s),o.e.r