diff --git a/bower.json b/bower.json index 80b6753..e900c68 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "tableexport.js", - "version": "5.0.0-rc.1", + "version": "5.0.0-rc.2", "authors": [ "clarketm " ], diff --git a/dist/css/tableexport.css b/dist/css/tableexport.css index fbbc2f5..bde2791 100644 --- a/dist/css/tableexport.css +++ b/dist/css/tableexport.css @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.0-rc.1 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.2 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * diff --git a/dist/css/tableexport.min.css b/dist/css/tableexport.min.css index 8945b8c..b8c3d4b 100644 --- a/dist/css/tableexport.min.css +++ b/dist/css/tableexport.min.css @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.0-rc.1 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.2 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * diff --git a/dist/js/tableexport.js b/dist/js/tableexport.js index 7309515..fca9867 100644 --- a/dist/js/tableexport.js +++ b/dist/js/tableexport.js @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.0-rc.1 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.2 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * @@ -142,7 +142,7 @@ * Version. * @memberof TableExport.prototype */ - version: '5.0.0-rc.1', + version: '5.0.0-rc.2', /** * Default library options. * @memberof TableExport.prototype @@ -150,7 +150,7 @@ defaults: { headers: true, // (Boolean), display table headers (th or td elements) in the , (default: true) footers: true, // (Boolean), display table footers (th or td elements) in the , (default: false) - formats: ['xls', 'csv', 'txt'], // (String[]), filetype(s) for the export, (default: ['xls', 'csv', 'txt']) + formats: ['xlsx', 'csv', 'txt'], // (String[]), filetype(s) for the export, (default: ['xlsx', 'csv', 'txt']) filename: 'id', // (id, String), filename for the downloaded file, (default: 'id') bootstrap: false, // (Boolean), style buttons using bootstrap, (default: true) exportButtons: true, // (Boolean), automatically generate the built-in export buttons for each of the specified formats (default: true) diff --git a/dist/js/tableexport.min.js b/dist/js/tableexport.min.js index b978567..178de42 100644 --- a/dist/js/tableexport.min.js +++ b/dist/js/tableexport.min.js @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.0-rc.1 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.2 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * @@ -16,4 +16,4 @@ * limitations under the License. * */ -!function(t,e){if("function"==typeof define&&define.amd)define(function(t){var r;try{r=t("jquery")}catch(o){}return e(r,t("blobjs"),t("file-saverjs"),t("xlsx"))});else if("object"==typeof exports&&"string"!=typeof exports.nodeName){var r;try{r=require("jquery")}catch(o){}module.exports=e(r,require("blobjs"),require("file-saverjs"),require("xlsx"))}else t.TableExport=e(t.jQuery,t.Blob,t.saveAs,t.XLSX)}(this,function(t,e,r,o){"use strict";function n(){for(var t=arguments,e=1;e tr")),e.rows=i.headers?a(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=i.footers?e.rows.concat(a(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=i.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===i.filename?t.getAttribute("id")?t.getAttribute("id"):r.defaultFilename:i.filename?i.filename:r.defaultFilename,e.uuid=g(t),e.checkCaption=function(e){var r=t.querySelectorAll("caption.tableexport-caption");r.length?r[0].appendChild(e):(r=document.createElement("caption"),r.className=i.bootstrapSettings.bootstrapSpacing+i.position+" tableexport-caption",r.appendChild(e),t.insertBefore(r,t.firstChild))},e.setExportData=function(){return function(t){var r=f.getInstance().getItem(t),o=t.substring(t.indexOf("-")+1);s[e.uuid]=s[e.uuid]||{},s[e.uuid][o]=JSON.parse(r)}}(),e.rcMap=(new d).build.call(r,e);var n={};for(var p in h)n[h[p]]=0;i.formats.forEach(function(t){!(!o||v||t!==h.XLS)&&(t=h.BIFF2),!(o&&!v||t!==h.XLSX)&&(t=h.XLS),n[t]||(e.setExportData(r.exporters[t].call(r,e)),n[t]++)})});var p=document.querySelectorAll("button[tableexport-id]");return b(p,"click",r.downloadHandler,r),r};c.prototype={version:"5.0.0-rc.1",defaults:{headers:!0,footers:!0,formats:["xls","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},CONSTANTS:{FORMAT:{XLSX:"xlsx",BIFF2:"biff2",XLS:"xls",CSV:"csv",TXT:"txt"},TYPE:{STRING:"s",NUMBER:"n",BOOLEAN:"b",DATE:"d"}},charset:"charset=utf-8",defaultFilename:"myDownload",defaultButton:"button-default",ignoreCSS:"tableexport-ignore",emptyCSS:"tableexport-empty",bootstrapConfig:["btn","btn-default","btn-toolbar"],rowDel:"\r\n",entityMap:{"&":"&","<":"<",">":">","'":"'","/":"/"},formatConfig:{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"}},typeConfig:{string:{defaultClass:"tableexport-string"},number:{defaultClass:"tableexport-number",assert:function(t){return!isNaN(t)}},"boolean":{defaultClass:"tableexport-boolean",assert:function(t){return"true"===t.toLowerCase()||"false"===t.toLowerCase()}},date:{defaultClass:"tableexport-date",assert:function(t){return!/.*%/.test(t)&&!isNaN(Date.parse(t))}}},exporters:{xlsx:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLSX],n=t.rcMap,i=a(t.rows).map(function(t,o){if(n.isIgnore(o))return n.handleRowColMapProp(n.TYPE.IGNORE);var i=t.querySelectorAll("th, td");return a(i).map(function(t,a){var i={v:r.formatValue(t.textContent),t:e.getType(t.className)};return n.isIgnore(o,a)?n.handleRowColMapProp(n.TYPE.IGNORE):n.isEmpty(o,a)?n.handleRowColMapProp(n.TYPE.EMPTY):n.handleRowColMapProp(n.TYPE.DEFAULT,o,a,i)}).filter(p)}).map(l).filter(p),s=JSON.stringify({data:i,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLSX});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,s,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,s,!0)},biff2:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLS],n=t.rcMap,i=a(t.rows).map(function(t,o){if(n.isIgnore(o))return n.handleRowColMapProp(n.TYPE.IGNORE);var i=t.querySelectorAll("th, td");return a(i).map(function(t,a){var i={v:r.formatValue(t.textContent),t:e.getType(t.className)};return n.isIgnore(o,a)?n.handleRowColMapProp(n.TYPE.IGNORE):n.isEmpty(o,a)?n.handleRowColMapProp(n.TYPE.EMPTY):n.handleRowColMapProp(n.TYPE.DEFAULT,o,a,i)}).filter(p)}).map(l).filter(p),s=JSON.stringify({data:i,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLS});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,s,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,s,!0)},xls:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLS],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a=r.formatValue(t.textContent);return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLS});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)},csv:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.CSV],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a='"'+r.formatValue(t.textContent.replace(/"/g,'""'))+'"';return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.CSV});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)},txt:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.TXT],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a=r.formatValue(t.textContent);return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.TXT});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)}},createObjButton:function(t,e,r,o,n){var a=document.createElement("button");return a.setAttribute("tableexport-id",t),a.className=n.bootstrapClass+n.bootstrapTheme+o,a.textContent=r,a},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return c.prototype.entityMap[t]})},unescapeHtml:function(t){var e=String(t);for(var r in this.entityMap)e=e.replace(RegExp(this.entityMap[r],"g"),r);return e},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=c.prototype.typeConfig;return~t.indexOf(e.string.defaultClass)?m.STRING:~t.indexOf(e.number.defaultClass)?m.NUMBER:~t.indexOf(e["boolean"].defaultClass)?m.BOOLEAN:~t.indexOf(e.date.defaultClass)?m.DATE:""},dateNum:function(t,e){e&&(t+=1462);var r=Date.parse(t),o=(r-new Date(Date.UTC(1899,11,30)))/864e5;return Math.floor(o)},createSheet:function(t){for(var e={},r={s:{c:1e7,r:1e7},e:{c:0,r:0}},n=c.prototype.typeConfig,a=0;a!==t.length;++a)for(var i=0;i!==t[a].length;++i){r.s.r>a&&(r.s.r=a),r.s.c>i&&(r.s.c=i),r.e.r=e?a+p:a:i++,i!==n);u++);return"undefined"!=typeof o?new Array(a).concat(r).join(o):new Array(a).concat(r)}return r},this.handleRowColMapProp=function(t,e,r,o,n){switch(t){case d.prototype.TYPE.IGNORE:return;case d.prototype.TYPE.EMPTY:return" ";case d.prototype.TYPE.DEFAULT:default:return this.convertSpanToArray(e,r,o,n)}}};d.prototype={OFFSET:1,TYPE:{IGNORE:"ignore",EMPTY:"empty",SPAN:"span",DEFAULT:"default"},build:function(t){var e=this,r=e.settings,o=1,n=new d,s=function(t){n.setRowColMapProp(t,void 0,n.TYPE.IGNORE,!0)},p=function(t,e){n.setRowColMapProp(t,e,n.TYPE.IGNORE,!0)},l=function(t,e){n.setRowColMapProp(t,e,n.TYPE.EMPTY,!0)},u=function(t,e,r){var o=t.getAttribute("rowspan"),a=t.hasAttribute("colspan");a&&c(t,e,r);for(var i=1;i tr")),e.rows=i.headers?a(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=i.footers?e.rows.concat(a(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=i.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===i.filename?t.getAttribute("id")?t.getAttribute("id"):r.defaultFilename:i.filename?i.filename:r.defaultFilename,e.uuid=g(t),e.checkCaption=function(e){var r=t.querySelectorAll("caption.tableexport-caption");r.length?r[0].appendChild(e):(r=document.createElement("caption"),r.className=i.bootstrapSettings.bootstrapSpacing+i.position+" tableexport-caption",r.appendChild(e),t.insertBefore(r,t.firstChild))},e.setExportData=function(){return function(t){var r=f.getInstance().getItem(t),o=t.substring(t.indexOf("-")+1);s[e.uuid]=s[e.uuid]||{},s[e.uuid][o]=JSON.parse(r)}}(),e.rcMap=(new d).build.call(r,e);var n={};for(var p in h)n[h[p]]=0;i.formats.forEach(function(t){!(!o||v||t!==h.XLS)&&(t=h.BIFF2),!(o&&!v||t!==h.XLSX)&&(t=h.XLS),n[t]||(e.setExportData(r.exporters[t].call(r,e)),n[t]++)})});var p=document.querySelectorAll("button[tableexport-id]");return b(p,"click",r.downloadHandler,r),r};c.prototype={version:"5.0.0-rc.2",defaults:{headers:!0,footers:!0,formats:["xlsx","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},CONSTANTS:{FORMAT:{XLSX:"xlsx",BIFF2:"biff2",XLS:"xls",CSV:"csv",TXT:"txt"},TYPE:{STRING:"s",NUMBER:"n",BOOLEAN:"b",DATE:"d"}},charset:"charset=utf-8",defaultFilename:"myDownload",defaultButton:"button-default",ignoreCSS:"tableexport-ignore",emptyCSS:"tableexport-empty",bootstrapConfig:["btn","btn-default","btn-toolbar"],rowDel:"\r\n",entityMap:{"&":"&","<":"<",">":">","'":"'","/":"/"},formatConfig:{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"}},typeConfig:{string:{defaultClass:"tableexport-string"},number:{defaultClass:"tableexport-number",assert:function(t){return!isNaN(t)}},"boolean":{defaultClass:"tableexport-boolean",assert:function(t){return"true"===t.toLowerCase()||"false"===t.toLowerCase()}},date:{defaultClass:"tableexport-date",assert:function(t){return!/.*%/.test(t)&&!isNaN(Date.parse(t))}}},exporters:{xlsx:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLSX],n=t.rcMap,i=a(t.rows).map(function(t,o){if(n.isIgnore(o))return n.handleRowColMapProp(n.TYPE.IGNORE);var i=t.querySelectorAll("th, td");return a(i).map(function(t,a){var i={v:r.formatValue(t.textContent),t:e.getType(t.className)};return n.isIgnore(o,a)?n.handleRowColMapProp(n.TYPE.IGNORE):n.isEmpty(o,a)?n.handleRowColMapProp(n.TYPE.EMPTY):n.handleRowColMapProp(n.TYPE.DEFAULT,o,a,i)}).filter(p)}).map(l).filter(p),s=JSON.stringify({data:i,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLSX});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,s,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,s,!0)},biff2:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLS],n=t.rcMap,i=a(t.rows).map(function(t,o){if(n.isIgnore(o))return n.handleRowColMapProp(n.TYPE.IGNORE);var i=t.querySelectorAll("th, td");return a(i).map(function(t,a){var i={v:r.formatValue(t.textContent),t:e.getType(t.className)};return n.isIgnore(o,a)?n.handleRowColMapProp(n.TYPE.IGNORE):n.isEmpty(o,a)?n.handleRowColMapProp(n.TYPE.EMPTY):n.handleRowColMapProp(n.TYPE.DEFAULT,o,a,i)}).filter(p)}).map(l).filter(p),s=JSON.stringify({data:i,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLS});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,s,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,s,!0)},xls:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLS],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a=r.formatValue(t.textContent);return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLS});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)},csv:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.CSV],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a='"'+r.formatValue(t.textContent.replace(/"/g,'""'))+'"';return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.CSV});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)},txt:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.TXT],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a=r.formatValue(t.textContent);return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.TXT});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)}},createObjButton:function(t,e,r,o,n){var a=document.createElement("button");return a.setAttribute("tableexport-id",t),a.className=n.bootstrapClass+n.bootstrapTheme+o,a.textContent=r,a},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return c.prototype.entityMap[t]})},unescapeHtml:function(t){var e=String(t);for(var r in this.entityMap)e=e.replace(RegExp(this.entityMap[r],"g"),r);return e},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=c.prototype.typeConfig;return~t.indexOf(e.string.defaultClass)?m.STRING:~t.indexOf(e.number.defaultClass)?m.NUMBER:~t.indexOf(e["boolean"].defaultClass)?m.BOOLEAN:~t.indexOf(e.date.defaultClass)?m.DATE:""},dateNum:function(t,e){e&&(t+=1462);var r=Date.parse(t),o=(r-new Date(Date.UTC(1899,11,30)))/864e5;return Math.floor(o)},createSheet:function(t){for(var e={},r={s:{c:1e7,r:1e7},e:{c:0,r:0}},n=c.prototype.typeConfig,a=0;a!==t.length;++a)for(var i=0;i!==t[a].length;++i){r.s.r>a&&(r.s.r=a),r.s.c>i&&(r.s.c=i),r.e.r=e?a+p:a:i++,i!==n);u++);return"undefined"!=typeof o?new Array(a).concat(r).join(o):new Array(a).concat(r)}return r},this.handleRowColMapProp=function(t,e,r,o,n){switch(t){case d.prototype.TYPE.IGNORE:return;case d.prototype.TYPE.EMPTY:return" ";case d.prototype.TYPE.DEFAULT:default:return this.convertSpanToArray(e,r,o,n)}}};d.prototype={OFFSET:1,TYPE:{IGNORE:"ignore",EMPTY:"empty",SPAN:"span",DEFAULT:"default"},build:function(t){var e=this,r=e.settings,o=1,n=new d,s=function(t){n.setRowColMapProp(t,void 0,n.TYPE.IGNORE,!0)},p=function(t,e){n.setRowColMapProp(t,e,n.TYPE.IGNORE,!0)},l=function(t,e){n.setRowColMapProp(t,e,n.TYPE.EMPTY,!0)},u=function(t,e,r){var o=t.getAttribute("rowspan"),a=t.hasAttribute("colspan");a&&c(t,e,r);for(var i=1;i /*! - * TableExport.js v5.0.0-rc.1 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.2 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * diff --git a/examples/arabic-language.html b/examples/arabic-language.html index 3e2d535..ec7410d 100644 --- a/examples/arabic-language.html +++ b/examples/arabic-language.html @@ -43,9 +43,7 @@

Arabic

diff --git a/examples/default.html b/examples/default.html index ed35266..afbd706 100644 --- a/examples/default.html +++ b/examples/default.html @@ -15,7 +15,7 @@

Defaults

         headers: true,
         footers: true,
-        formats: ['xls', 'csv', 'txt'],
+        formats: ['xlsx', 'csv', 'txt'],
         filename: 'id',
         bootstrap: false,
         exportButtons: true,
@@ -85,7 +85,7 @@ 

Defaults

new TableExport(DefaultTable, { headers: true, // (Boolean), display table headers (th or td elements) in the , (default: true) footers: true, // (Boolean), display table footers (th or td elements) in the , (default: false) - formats: ['xls', 'csv', 'txt'], // (String[]), filetype(s) for the export, (default: ['xls', 'csv', 'txt']) + formats: ['xlsx', 'csv', 'txt'], // (String[]), filetype(s) for the export, (default: ['xlsx', 'csv', 'txt']) filename: 'id', // (id, String), filename for the downloaded file, (default: 'id') bootstrap: false, // (Boolean), style buttons using bootstrap, (default: false) position: 'bottom', // (top, bottom), position of the caption element relative to table, (default: 'bottom') @@ -99,7 +99,7 @@

Defaults

// $(DefaultTable).tableExport({ // headers: true, // footers: true, - // formats: ['xls', 'csv', 'txt'], + // formats: ['xlsx', 'csv', 'txt'], // filename: 'id', // bootstrap: true, // position: 'bottom', diff --git a/package.json b/package.json index 6890c7b..e2ffe06 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tableexport", - "version": "5.0.0-rc.1", + "version": "5.0.0-rc.2", "authors": [ "clarketm " ], diff --git a/src/stable/css/tableexport.css b/src/stable/css/tableexport.css index fbbc2f5..bde2791 100644 --- a/src/stable/css/tableexport.css +++ b/src/stable/css/tableexport.css @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.0-rc.1 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.2 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * diff --git a/src/stable/css/tableexport.min.css b/src/stable/css/tableexport.min.css index 8945b8c..b8c3d4b 100644 --- a/src/stable/css/tableexport.min.css +++ b/src/stable/css/tableexport.min.css @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.0-rc.1 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.2 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * diff --git a/src/stable/js/tableexport.js b/src/stable/js/tableexport.js index 7309515..fca9867 100644 --- a/src/stable/js/tableexport.js +++ b/src/stable/js/tableexport.js @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.0-rc.1 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.2 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * @@ -142,7 +142,7 @@ * Version. * @memberof TableExport.prototype */ - version: '5.0.0-rc.1', + version: '5.0.0-rc.2', /** * Default library options. * @memberof TableExport.prototype @@ -150,7 +150,7 @@ defaults: { headers: true, // (Boolean), display table headers (th or td elements) in the , (default: true) footers: true, // (Boolean), display table footers (th or td elements) in the , (default: false) - formats: ['xls', 'csv', 'txt'], // (String[]), filetype(s) for the export, (default: ['xls', 'csv', 'txt']) + formats: ['xlsx', 'csv', 'txt'], // (String[]), filetype(s) for the export, (default: ['xlsx', 'csv', 'txt']) filename: 'id', // (id, String), filename for the downloaded file, (default: 'id') bootstrap: false, // (Boolean), style buttons using bootstrap, (default: true) exportButtons: true, // (Boolean), automatically generate the built-in export buttons for each of the specified formats (default: true) diff --git a/src/stable/js/tableexport.min.js b/src/stable/js/tableexport.min.js index b978567..178de42 100644 --- a/src/stable/js/tableexport.min.js +++ b/src/stable/js/tableexport.min.js @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.0-rc.1 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.2 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * @@ -16,4 +16,4 @@ * limitations under the License. * */ -!function(t,e){if("function"==typeof define&&define.amd)define(function(t){var r;try{r=t("jquery")}catch(o){}return e(r,t("blobjs"),t("file-saverjs"),t("xlsx"))});else if("object"==typeof exports&&"string"!=typeof exports.nodeName){var r;try{r=require("jquery")}catch(o){}module.exports=e(r,require("blobjs"),require("file-saverjs"),require("xlsx"))}else t.TableExport=e(t.jQuery,t.Blob,t.saveAs,t.XLSX)}(this,function(t,e,r,o){"use strict";function n(){for(var t=arguments,e=1;e tr")),e.rows=i.headers?a(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=i.footers?e.rows.concat(a(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=i.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===i.filename?t.getAttribute("id")?t.getAttribute("id"):r.defaultFilename:i.filename?i.filename:r.defaultFilename,e.uuid=g(t),e.checkCaption=function(e){var r=t.querySelectorAll("caption.tableexport-caption");r.length?r[0].appendChild(e):(r=document.createElement("caption"),r.className=i.bootstrapSettings.bootstrapSpacing+i.position+" tableexport-caption",r.appendChild(e),t.insertBefore(r,t.firstChild))},e.setExportData=function(){return function(t){var r=f.getInstance().getItem(t),o=t.substring(t.indexOf("-")+1);s[e.uuid]=s[e.uuid]||{},s[e.uuid][o]=JSON.parse(r)}}(),e.rcMap=(new d).build.call(r,e);var n={};for(var p in h)n[h[p]]=0;i.formats.forEach(function(t){!(!o||v||t!==h.XLS)&&(t=h.BIFF2),!(o&&!v||t!==h.XLSX)&&(t=h.XLS),n[t]||(e.setExportData(r.exporters[t].call(r,e)),n[t]++)})});var p=document.querySelectorAll("button[tableexport-id]");return b(p,"click",r.downloadHandler,r),r};c.prototype={version:"5.0.0-rc.1",defaults:{headers:!0,footers:!0,formats:["xls","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},CONSTANTS:{FORMAT:{XLSX:"xlsx",BIFF2:"biff2",XLS:"xls",CSV:"csv",TXT:"txt"},TYPE:{STRING:"s",NUMBER:"n",BOOLEAN:"b",DATE:"d"}},charset:"charset=utf-8",defaultFilename:"myDownload",defaultButton:"button-default",ignoreCSS:"tableexport-ignore",emptyCSS:"tableexport-empty",bootstrapConfig:["btn","btn-default","btn-toolbar"],rowDel:"\r\n",entityMap:{"&":"&","<":"<",">":">","'":"'","/":"/"},formatConfig:{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"}},typeConfig:{string:{defaultClass:"tableexport-string"},number:{defaultClass:"tableexport-number",assert:function(t){return!isNaN(t)}},"boolean":{defaultClass:"tableexport-boolean",assert:function(t){return"true"===t.toLowerCase()||"false"===t.toLowerCase()}},date:{defaultClass:"tableexport-date",assert:function(t){return!/.*%/.test(t)&&!isNaN(Date.parse(t))}}},exporters:{xlsx:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLSX],n=t.rcMap,i=a(t.rows).map(function(t,o){if(n.isIgnore(o))return n.handleRowColMapProp(n.TYPE.IGNORE);var i=t.querySelectorAll("th, td");return a(i).map(function(t,a){var i={v:r.formatValue(t.textContent),t:e.getType(t.className)};return n.isIgnore(o,a)?n.handleRowColMapProp(n.TYPE.IGNORE):n.isEmpty(o,a)?n.handleRowColMapProp(n.TYPE.EMPTY):n.handleRowColMapProp(n.TYPE.DEFAULT,o,a,i)}).filter(p)}).map(l).filter(p),s=JSON.stringify({data:i,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLSX});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,s,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,s,!0)},biff2:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLS],n=t.rcMap,i=a(t.rows).map(function(t,o){if(n.isIgnore(o))return n.handleRowColMapProp(n.TYPE.IGNORE);var i=t.querySelectorAll("th, td");return a(i).map(function(t,a){var i={v:r.formatValue(t.textContent),t:e.getType(t.className)};return n.isIgnore(o,a)?n.handleRowColMapProp(n.TYPE.IGNORE):n.isEmpty(o,a)?n.handleRowColMapProp(n.TYPE.EMPTY):n.handleRowColMapProp(n.TYPE.DEFAULT,o,a,i)}).filter(p)}).map(l).filter(p),s=JSON.stringify({data:i,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLS});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,s,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,s,!0)},xls:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLS],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a=r.formatValue(t.textContent);return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLS});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)},csv:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.CSV],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a='"'+r.formatValue(t.textContent.replace(/"/g,'""'))+'"';return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.CSV});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)},txt:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.TXT],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a=r.formatValue(t.textContent);return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.TXT});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)}},createObjButton:function(t,e,r,o,n){var a=document.createElement("button");return a.setAttribute("tableexport-id",t),a.className=n.bootstrapClass+n.bootstrapTheme+o,a.textContent=r,a},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return c.prototype.entityMap[t]})},unescapeHtml:function(t){var e=String(t);for(var r in this.entityMap)e=e.replace(RegExp(this.entityMap[r],"g"),r);return e},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=c.prototype.typeConfig;return~t.indexOf(e.string.defaultClass)?m.STRING:~t.indexOf(e.number.defaultClass)?m.NUMBER:~t.indexOf(e["boolean"].defaultClass)?m.BOOLEAN:~t.indexOf(e.date.defaultClass)?m.DATE:""},dateNum:function(t,e){e&&(t+=1462);var r=Date.parse(t),o=(r-new Date(Date.UTC(1899,11,30)))/864e5;return Math.floor(o)},createSheet:function(t){for(var e={},r={s:{c:1e7,r:1e7},e:{c:0,r:0}},n=c.prototype.typeConfig,a=0;a!==t.length;++a)for(var i=0;i!==t[a].length;++i){r.s.r>a&&(r.s.r=a),r.s.c>i&&(r.s.c=i),r.e.r=e?a+p:a:i++,i!==n);u++);return"undefined"!=typeof o?new Array(a).concat(r).join(o):new Array(a).concat(r)}return r},this.handleRowColMapProp=function(t,e,r,o,n){switch(t){case d.prototype.TYPE.IGNORE:return;case d.prototype.TYPE.EMPTY:return" ";case d.prototype.TYPE.DEFAULT:default:return this.convertSpanToArray(e,r,o,n)}}};d.prototype={OFFSET:1,TYPE:{IGNORE:"ignore",EMPTY:"empty",SPAN:"span",DEFAULT:"default"},build:function(t){var e=this,r=e.settings,o=1,n=new d,s=function(t){n.setRowColMapProp(t,void 0,n.TYPE.IGNORE,!0)},p=function(t,e){n.setRowColMapProp(t,e,n.TYPE.IGNORE,!0)},l=function(t,e){n.setRowColMapProp(t,e,n.TYPE.EMPTY,!0)},u=function(t,e,r){var o=t.getAttribute("rowspan"),a=t.hasAttribute("colspan");a&&c(t,e,r);for(var i=1;i tr")),e.rows=i.headers?a(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=i.footers?e.rows.concat(a(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=i.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===i.filename?t.getAttribute("id")?t.getAttribute("id"):r.defaultFilename:i.filename?i.filename:r.defaultFilename,e.uuid=g(t),e.checkCaption=function(e){var r=t.querySelectorAll("caption.tableexport-caption");r.length?r[0].appendChild(e):(r=document.createElement("caption"),r.className=i.bootstrapSettings.bootstrapSpacing+i.position+" tableexport-caption",r.appendChild(e),t.insertBefore(r,t.firstChild))},e.setExportData=function(){return function(t){var r=f.getInstance().getItem(t),o=t.substring(t.indexOf("-")+1);s[e.uuid]=s[e.uuid]||{},s[e.uuid][o]=JSON.parse(r)}}(),e.rcMap=(new d).build.call(r,e);var n={};for(var p in h)n[h[p]]=0;i.formats.forEach(function(t){!(!o||v||t!==h.XLS)&&(t=h.BIFF2),!(o&&!v||t!==h.XLSX)&&(t=h.XLS),n[t]||(e.setExportData(r.exporters[t].call(r,e)),n[t]++)})});var p=document.querySelectorAll("button[tableexport-id]");return b(p,"click",r.downloadHandler,r),r};c.prototype={version:"5.0.0-rc.2",defaults:{headers:!0,footers:!0,formats:["xlsx","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},CONSTANTS:{FORMAT:{XLSX:"xlsx",BIFF2:"biff2",XLS:"xls",CSV:"csv",TXT:"txt"},TYPE:{STRING:"s",NUMBER:"n",BOOLEAN:"b",DATE:"d"}},charset:"charset=utf-8",defaultFilename:"myDownload",defaultButton:"button-default",ignoreCSS:"tableexport-ignore",emptyCSS:"tableexport-empty",bootstrapConfig:["btn","btn-default","btn-toolbar"],rowDel:"\r\n",entityMap:{"&":"&","<":"<",">":">","'":"'","/":"/"},formatConfig:{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"}},typeConfig:{string:{defaultClass:"tableexport-string"},number:{defaultClass:"tableexport-number",assert:function(t){return!isNaN(t)}},"boolean":{defaultClass:"tableexport-boolean",assert:function(t){return"true"===t.toLowerCase()||"false"===t.toLowerCase()}},date:{defaultClass:"tableexport-date",assert:function(t){return!/.*%/.test(t)&&!isNaN(Date.parse(t))}}},exporters:{xlsx:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLSX],n=t.rcMap,i=a(t.rows).map(function(t,o){if(n.isIgnore(o))return n.handleRowColMapProp(n.TYPE.IGNORE);var i=t.querySelectorAll("th, td");return a(i).map(function(t,a){var i={v:r.formatValue(t.textContent),t:e.getType(t.className)};return n.isIgnore(o,a)?n.handleRowColMapProp(n.TYPE.IGNORE):n.isEmpty(o,a)?n.handleRowColMapProp(n.TYPE.EMPTY):n.handleRowColMapProp(n.TYPE.DEFAULT,o,a,i)}).filter(p)}).map(l).filter(p),s=JSON.stringify({data:i,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLSX});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,s,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,s,!0)},biff2:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLS],n=t.rcMap,i=a(t.rows).map(function(t,o){if(n.isIgnore(o))return n.handleRowColMapProp(n.TYPE.IGNORE);var i=t.querySelectorAll("th, td");return a(i).map(function(t,a){var i={v:r.formatValue(t.textContent),t:e.getType(t.className)};return n.isIgnore(o,a)?n.handleRowColMapProp(n.TYPE.IGNORE):n.isEmpty(o,a)?n.handleRowColMapProp(n.TYPE.EMPTY):n.handleRowColMapProp(n.TYPE.DEFAULT,o,a,i)}).filter(p)}).map(l).filter(p),s=JSON.stringify({data:i,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLS});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,s,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,s,!0)},xls:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLS],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a=r.formatValue(t.textContent);return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLS});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)},csv:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.CSV],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a='"'+r.formatValue(t.textContent.replace(/"/g,'""'))+'"';return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.CSV});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)},txt:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.TXT],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a=r.formatValue(t.textContent);return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.TXT});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)}},createObjButton:function(t,e,r,o,n){var a=document.createElement("button");return a.setAttribute("tableexport-id",t),a.className=n.bootstrapClass+n.bootstrapTheme+o,a.textContent=r,a},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return c.prototype.entityMap[t]})},unescapeHtml:function(t){var e=String(t);for(var r in this.entityMap)e=e.replace(RegExp(this.entityMap[r],"g"),r);return e},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=c.prototype.typeConfig;return~t.indexOf(e.string.defaultClass)?m.STRING:~t.indexOf(e.number.defaultClass)?m.NUMBER:~t.indexOf(e["boolean"].defaultClass)?m.BOOLEAN:~t.indexOf(e.date.defaultClass)?m.DATE:""},dateNum:function(t,e){e&&(t+=1462);var r=Date.parse(t),o=(r-new Date(Date.UTC(1899,11,30)))/864e5;return Math.floor(o)},createSheet:function(t){for(var e={},r={s:{c:1e7,r:1e7},e:{c:0,r:0}},n=c.prototype.typeConfig,a=0;a!==t.length;++a)for(var i=0;i!==t[a].length;++i){r.s.r>a&&(r.s.r=a),r.s.c>i&&(r.s.c=i),r.e.r=e?a+p:a:i++,i!==n);u++);return"undefined"!=typeof o?new Array(a).concat(r).join(o):new Array(a).concat(r)}return r},this.handleRowColMapProp=function(t,e,r,o,n){switch(t){case d.prototype.TYPE.IGNORE:return;case d.prototype.TYPE.EMPTY:return" ";case d.prototype.TYPE.DEFAULT:default:return this.convertSpanToArray(e,r,o,n)}}};d.prototype={OFFSET:1,TYPE:{IGNORE:"ignore",EMPTY:"empty",SPAN:"span",DEFAULT:"default"},build:function(t){var e=this,r=e.settings,o=1,n=new d,s=function(t){n.setRowColMapProp(t,void 0,n.TYPE.IGNORE,!0)},p=function(t,e){n.setRowColMapProp(t,e,n.TYPE.IGNORE,!0)},l=function(t,e){n.setRowColMapProp(t,e,n.TYPE.EMPTY,!0)},u=function(t,e,r){var o=t.getAttribute("rowspan"),a=t.hasAttribute("colspan");a&&c(t,e,r);for(var i=1;i