From 48edb3cbec4dd773fe68c5f4a6443a9f43c310e0 Mon Sep 17 00:00:00 2001 From: Travis Clarke Date: Mon, 22 May 2017 23:17:52 -0700 Subject: [PATCH] v4.0.4 - add method to retrieve ArrayBuffer bytes --- bower.json | 2 +- dist/css/tableexport.css | 2 +- dist/css/tableexport.min.css | 2 +- dist/js/tableexport.js | 41 +++++++++++++++++------------- dist/js/tableexport.min.js | 4 +-- examples/examples.css | 3 +++ examples/examples.less | 4 +++ examples/exportButtons.html | 18 +++++++++++++ package.json | 2 +- src/stable/css/tableexport.css | 2 +- src/stable/css/tableexport.min.css | 2 +- src/stable/js/tableexport.js | 41 +++++++++++++++++------------- src/stable/js/tableexport.min.js | 4 +-- 13 files changed, 81 insertions(+), 46 deletions(-) diff --git a/bower.json b/bower.json index 9a4a797..1352a4b 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "tableexport.js", - "version": "4.0.2", + "version": "4.0.4", "authors": [ "clarketm " ], diff --git a/dist/css/tableexport.css b/dist/css/tableexport.css index 2d5aa76..a7ffa81 100644 --- a/dist/css/tableexport.css +++ b/dist/css/tableexport.css @@ -1,5 +1,5 @@ /*! - * TableExport.js v4.0.2 (https://www.travismclarke.com) + * TableExport.js v4.0.4 (https://www.travismclarke.com) * Copyright 2017 Travis Clarke * Licensed under the MIT license */ diff --git a/dist/css/tableexport.min.css b/dist/css/tableexport.min.css index adb325e..ef2abc1 100644 --- a/dist/css/tableexport.min.css +++ b/dist/css/tableexport.min.css @@ -1,5 +1,5 @@ /*! - * TableExport.js v4.0.2 (https://www.travismclarke.com) + * TableExport.js v4.0.4 (https://www.travismclarke.com) * Copyright 2017 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,.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{content:"";background:#006400 url(../img/xlsx.svg) no-repeat center}.xls:before{content:"";background:green url(../img/xls.svg) no-repeat center}.csv:before{content:"";background:#00f url(../img/csv.svg) no-repeat center}.txt:before{content:"";background:purple url(../img/txt.svg) no-repeat center} \ No newline at end of file diff --git a/dist/js/tableexport.js b/dist/js/tableexport.js index 70f521f..2899530 100644 --- a/dist/js/tableexport.js +++ b/dist/js/tableexport.js @@ -1,5 +1,5 @@ /*! - * TableExport.js v4.0.2 (https://www.travismclarke.com) + * TableExport.js v4.0.4 (https://www.travismclarke.com) * Copyright 2017 Travis Clarke * Licensed under the MIT license */ @@ -124,7 +124,7 @@ * Version. * @memberof TableExport.prototype */ - version: '4.0.2', + version: '4.0.4', /** * Default library options. * @memberof TableExport.prototype @@ -694,22 +694,7 @@ * @param extension {String} file extension */ export2file: function (data, mime, name, extension) { - if (XLSX && !isMobile && extension.substr(0, 4) === '.xls') { - var wb = new this.Workbook(), - ws = this.createSheet(data), - bookType = extension.substr(1) === _type.xls ? _type.biff2 : _type.xlsx; - - wb.SheetNames.push(name); - wb.Sheets[name] = ws; - var wopts = { - bookType: bookType, - bookSST: false, - type: 'binary' - }, - wbout = XLSX.write(wb, wopts); - - data = this.string2ArrayBuffer(wbout); - } + data = this.getBinaryData(data, extension, name); if (isMobile) { var dataURI = 'data:' + mime + ';' + this.charset + ',' + data; @@ -728,6 +713,26 @@ document.body.appendChild(link); link.click(); }, + getBinaryData: function (data, extension, name) { + if (XLSX && !isMobile && extension.substr(0, 4) === '.xls') { + var wb = new this.Workbook(), + ws = this.createSheet(data), + bookType = extension.substr(1) === _type.xls ? _type.biff2 : _type.xlsx; + + name = name || ''; + wb.SheetNames.push(name); + wb.Sheets[name] = ws; + var wopts = { + bookType: bookType, + bookSST: false, + type: 'binary' + }, + wbout = XLSX.write(wb, wopts); + + data = this.string2ArrayBuffer(wbout); + } + return data; + }, /** * Updates the library instance with new/updated options * @param options {Object} TableExport configuration options diff --git a/dist/js/tableexport.min.js b/dist/js/tableexport.min.js index e42c162..03facf9 100644 --- a/dist/js/tableexport.min.js +++ b/dist/js/tableexport.min.js @@ -1,6 +1,6 @@ /*! - * TableExport.js v4.0.2 (https://www.travismclarke.com) + * TableExport.js v4.0.4 (https://www.travismclarke.com) * Copyright 2017 Travis Clarke * Licensed under the MIT license */ -!function(t,e){"function"==typeof define&&define.amd?define(["jquery","blobjs","file-saverjs","xlsx"],e):"object"==typeof exports&&"string"!=typeof exports.nodeName?module.exports=e(require("jquery"),require("blobjs"),require("file-saverjs"),require("xlsx")):t.TableExport=e(t.jQuery,t.Blob,t.saveAs,t.XLSX)}(this,function(t,e,n,r){"use strict";function o(){for(var t=arguments,e=1;e tr")),e.rows=a.headers?i(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=a.footers?e.rows.concat(i(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=a.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===a.filename?t.getAttribute("id")?t.getAttribute("id"):n.defaultFilename:a.filename?a.filename:n.defaultFilename,e.uuid=p(t),e.checkCaption=function(e){var n=t.querySelectorAll("caption.tableexport-caption");n.length?n[0].appendChild(e):(n=document.createElement("caption"),n.className=a.bootstrapSettings.bootstrapSpacing+a.position+" tableexport-caption",n.appendChild(e),t.insertBefore(n,t.firstChild))},e.setExportData=function(){return function(t){var n=u.getInstance().getItem(t),r=t.substring(t.indexOf("-")+1);c[e.uuid]=c[e.uuid]||{},c[e.uuid][r]=JSON.parse(n)}}();var o={};for(var s in f)o[s]=0;a.formats.forEach(function(t){!(!r||m||t!==f.xls)&&(t=f.biff2),!(r&&!m||t!==f.xlsx)&&(t=f.xls),o[t]||(e.setExportData(n.exporters[t].call(n,e)),o[t]++)})});var x=document.querySelectorAll("button[tableexport-id]");return d(x,"click",n.downloadHandler,n),n};l.prototype={version:"4.0.2",defaults:{headers:!0,footers:!0,formats:["xls","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},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:{"&":"&","<":"<",">":">","'":"'","/":"/"},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"},types:{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,n=e.settings,r={},o=i(t.rows).map(function(o,s){if(!~n.ignoreRows.indexOf(s-t.thAdj)&&!a(o,n.ignoreCSS)){var l=o.querySelectorAll("th, td");return i(l).map(function(t,o){if(!~n.ignoreCols.indexOf(o)&&!a(t,n.ignoreCSS)){if(a(t,n.emptyCSS))return" ";if(t.hasAttribute("colspan")&&(r[s]=r[s]||{},r[s][o+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var i=1;i=o?u+r[s][i]:u:p++,p!==l);i++);return new Array(u).concat({v:n.formatValue(t.textContent),t:e.getType(t.className)})}return{v:n.formatValue(t.textContent),t:e.getType(t.className)}}}).filter(function(t){return"undefined"!=typeof t})}}).map(function(t){return t&&[].concat.apply([],t)}).filter(function(t){return"undefined"!=typeof t}),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xlsx.mimeType,fileExtension:l.prototype.xlsx.fileExtension}),p=l.prototype.xlsx.buttonContent,d=l.prototype.xlsx.defaultClass,m=c({uuid:t.uuid,type:f.xlsx}),x=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,s,!0),m},biff2:function(t){var e=this,n=e.settings,r={},o=i(t.rows).map(function(o,s){if(!~n.ignoreRows.indexOf(s-t.thAdj)&&!a(o,n.ignoreCSS)){var l=o.querySelectorAll("th, td");return i(l).map(function(t,o){if(!~n.ignoreCols.indexOf(o)&&!a(t,n.ignoreCSS)){if(a(t,n.emptyCSS))return" ";if(t.hasAttribute("colspan")&&(r[s]=r[s]||{},r[s][o+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var i=1;i=o?u+r[s][i]:u:p++,p!==l);i++);return new Array(u).concat({v:n.formatValue(t.textContent),t:e.getType(t.className)})}return{v:n.formatValue(t.textContent),t:e.getType(t.className)}}}).filter(function(t){return"undefined"!=typeof t})}}).map(function(t){return t&&[].concat.apply([],t)}).filter(function(t){return"undefined"!=typeof t}),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xls.mimeType,fileExtension:l.prototype.xls.fileExtension}),p=l.prototype.xls.buttonContent,d=l.prototype.xls.defaultClass,m=c({uuid:t.uuid,type:f.xls}),x=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,s,!0),m},xls:function(t){var e=this,n=e.settings,r=l.prototype.xls.separator,o=i(t.rows).map(function(e,o){if(!~n.ignoreRows.indexOf(o-t.thAdj)&&!a(e,n.ignoreCSS)){var s=e.querySelectorAll("th, td");return i(s).map(function(t,e){if(!~n.ignoreCols.indexOf(e)&&!a(t,n.ignoreCSS))return a(t,n.emptyCSS)?" ":t.textContent}).filter(function(t){return"undefined"!=typeof t}).join(r)}}).filter(function(t){return"undefined"!=typeof t}).join(e.rowDel),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xls.mimeType,fileExtension:l.prototype.xls.fileExtension}),p=l.prototype.xls.buttonContent,d=l.prototype.xls.defaultClass,m=c({uuid:t.uuid,type:f.xls}),x=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,s,!0),m},csv:function(t){var e=this,n=e.settings,r=l.prototype.csv.separator,o=i(t.rows).map(function(e,o){if(!~n.ignoreRows.indexOf(o-t.thAdj)&&!a(e,n.ignoreCSS)){var s=e.querySelectorAll("th, td");return i(s).map(function(t,e){if(!~n.ignoreCols.indexOf(e)&&!a(t,n.ignoreCSS))return a(t,n.emptyCSS)?" ":'"'+n.formatValue(t.textContent.replace(/"/g,'""'))+'"'}).filter(function(t){return"undefined"!=typeof t}).join(r)}}).filter(function(t){return"undefined"!=typeof t}).join(e.rowDel),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.csv.mimeType,fileExtension:l.prototype.csv.fileExtension}),p=l.prototype.csv.buttonContent,d=l.prototype.csv.defaultClass,m=c({uuid:t.uuid,type:f.csv}),x=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,s,!0),m},txt:function(t){var e=this,n=e.settings,r=l.prototype.txt.separator,o=i(t.rows).map(function(e,o){if(!~n.ignoreRows.indexOf(o-t.thAdj)&&!a(e,n.ignoreCSS)){var s=e.querySelectorAll("th, td");return i(s).map(function(t,e){if(!~n.ignoreCols.indexOf(e)&&!a(t,n.ignoreCSS))return a(t,n.emptyCSS)?" ":n.formatValue(t.textContent)}).filter(function(t){return"undefined"!=typeof t}).join(r)}}).filter(function(t){return"undefined"!=typeof t}).join(e.rowDel),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.txt.mimeType,fileExtension:l.prototype.txt.fileExtension}),p=l.prototype.txt.buttonContent,d=l.prototype.txt.defaultClass,m=c({uuid:t.uuid,type:f.txt}),x=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,s,!0),m}},createObjButton:function(t,e,n,r,o){var i=document.createElement("button");return i.setAttribute("tableexport-id",t),i.className=o.bootstrapClass+o.bootstrapTheme+r,i.textContent=n,i},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return l.prototype.entityMap[t]})},unescapeHtml:function(t){var e=String(t);for(var n in this.entityMap)e=e.replace(RegExp(this.entityMap[n],"g"),n);return e},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=l.prototype.types;return~t.indexOf(e.string.defaultClass)?"s":~t.indexOf(e.number.defaultClass)?"n":~t.indexOf(e["boolean"].defaultClass)?"b":~t.indexOf(e.date.defaultClass)?"d":""},dateNum:function(t,e){e&&(t+=1462);var n=Date.parse(t);return(n-new Date(Date.UTC(1899,11,30)))/864e5},createSheet:function(t){for(var e={},n={s:{c:1e7,r:1e7},e:{c:0,r:0}},o=l.prototype.types,i=0;i!==t.length;++i)for(var a=0;a!==t[i].length;++a){n.s.r>i&&(n.s.r=i),n.s.c>a&&(n.s.c=a),n.e.r tr")),e.rows=a.headers?i(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=a.footers?e.rows.concat(i(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=a.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===a.filename?t.getAttribute("id")?t.getAttribute("id"):n.defaultFilename:a.filename?a.filename:n.defaultFilename,e.uuid=p(t),e.checkCaption=function(e){var n=t.querySelectorAll("caption.tableexport-caption");n.length?n[0].appendChild(e):(n=document.createElement("caption"),n.className=a.bootstrapSettings.bootstrapSpacing+a.position+" tableexport-caption",n.appendChild(e),t.insertBefore(n,t.firstChild))},e.setExportData=function(){return function(t){var n=u.getInstance().getItem(t),r=t.substring(t.indexOf("-")+1);c[e.uuid]=c[e.uuid]||{},c[e.uuid][r]=JSON.parse(n)}}();var o={};for(var s in f)o[s]=0;a.formats.forEach(function(t){!(!r||m||t!==f.xls)&&(t=f.biff2),!(r&&!m||t!==f.xlsx)&&(t=f.xls),o[t]||(e.setExportData(n.exporters[t].call(n,e)),o[t]++)})});var g=document.querySelectorAll("button[tableexport-id]");return d(g,"click",n.downloadHandler,n),n};l.prototype={version:"4.0.4",defaults:{headers:!0,footers:!0,formats:["xls","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},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:{"&":"&","<":"<",">":">","'":"'","/":"/"},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"},types:{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,n=e.settings,r={},o=i(t.rows).map(function(o,s){if(!~n.ignoreRows.indexOf(s-t.thAdj)&&!a(o,n.ignoreCSS)){var l=o.querySelectorAll("th, td");return i(l).map(function(t,o){if(!~n.ignoreCols.indexOf(o)&&!a(t,n.ignoreCSS)){if(a(t,n.emptyCSS))return" ";if(t.hasAttribute("colspan")&&(r[s]=r[s]||{},r[s][o+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var i=1;i=o?u+r[s][i]:u:p++,p!==l);i++);return new Array(u).concat({v:n.formatValue(t.textContent),t:e.getType(t.className)})}return{v:n.formatValue(t.textContent),t:e.getType(t.className)}}}).filter(function(t){return"undefined"!=typeof t})}}).map(function(t){return t&&[].concat.apply([],t)}).filter(function(t){return"undefined"!=typeof t}),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xlsx.mimeType,fileExtension:l.prototype.xlsx.fileExtension}),p=l.prototype.xlsx.buttonContent,d=l.prototype.xlsx.defaultClass,m=c({uuid:t.uuid,type:f.xlsx}),g=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return g&&t.checkCaption(g),u.getInstance().setItem(m,s,!0),m},biff2:function(t){var e=this,n=e.settings,r={},o=i(t.rows).map(function(o,s){if(!~n.ignoreRows.indexOf(s-t.thAdj)&&!a(o,n.ignoreCSS)){var l=o.querySelectorAll("th, td");return i(l).map(function(t,o){if(!~n.ignoreCols.indexOf(o)&&!a(t,n.ignoreCSS)){if(a(t,n.emptyCSS))return" ";if(t.hasAttribute("colspan")&&(r[s]=r[s]||{},r[s][o+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var i=1;i=o?u+r[s][i]:u:p++,p!==l);i++);return new Array(u).concat({v:n.formatValue(t.textContent),t:e.getType(t.className)})}return{v:n.formatValue(t.textContent),t:e.getType(t.className)}}}).filter(function(t){return"undefined"!=typeof t})}}).map(function(t){return t&&[].concat.apply([],t)}).filter(function(t){return"undefined"!=typeof t}),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xls.mimeType,fileExtension:l.prototype.xls.fileExtension}),p=l.prototype.xls.buttonContent,d=l.prototype.xls.defaultClass,m=c({uuid:t.uuid,type:f.xls}),g=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return g&&t.checkCaption(g),u.getInstance().setItem(m,s,!0),m},xls:function(t){var e=this,n=e.settings,r=l.prototype.xls.separator,o=i(t.rows).map(function(e,o){if(!~n.ignoreRows.indexOf(o-t.thAdj)&&!a(e,n.ignoreCSS)){var s=e.querySelectorAll("th, td");return i(s).map(function(t,e){if(!~n.ignoreCols.indexOf(e)&&!a(t,n.ignoreCSS))return a(t,n.emptyCSS)?" ":t.textContent}).filter(function(t){return"undefined"!=typeof t}).join(r)}}).filter(function(t){return"undefined"!=typeof t}).join(e.rowDel),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xls.mimeType,fileExtension:l.prototype.xls.fileExtension}),p=l.prototype.xls.buttonContent,d=l.prototype.xls.defaultClass,m=c({uuid:t.uuid,type:f.xls}),g=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return g&&t.checkCaption(g),u.getInstance().setItem(m,s,!0),m},csv:function(t){var e=this,n=e.settings,r=l.prototype.csv.separator,o=i(t.rows).map(function(e,o){if(!~n.ignoreRows.indexOf(o-t.thAdj)&&!a(e,n.ignoreCSS)){var s=e.querySelectorAll("th, td");return i(s).map(function(t,e){if(!~n.ignoreCols.indexOf(e)&&!a(t,n.ignoreCSS))return a(t,n.emptyCSS)?" ":'"'+n.formatValue(t.textContent.replace(/"/g,'""'))+'"'}).filter(function(t){return"undefined"!=typeof t}).join(r)}}).filter(function(t){return"undefined"!=typeof t}).join(e.rowDel),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.csv.mimeType,fileExtension:l.prototype.csv.fileExtension}),p=l.prototype.csv.buttonContent,d=l.prototype.csv.defaultClass,m=c({uuid:t.uuid,type:f.csv}),g=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return g&&t.checkCaption(g),u.getInstance().setItem(m,s,!0),m},txt:function(t){var e=this,n=e.settings,r=l.prototype.txt.separator,o=i(t.rows).map(function(e,o){if(!~n.ignoreRows.indexOf(o-t.thAdj)&&!a(e,n.ignoreCSS)){var s=e.querySelectorAll("th, td");return i(s).map(function(t,e){if(!~n.ignoreCols.indexOf(e)&&!a(t,n.ignoreCSS))return a(t,n.emptyCSS)?" ":n.formatValue(t.textContent)}).filter(function(t){return"undefined"!=typeof t}).join(r)}}).filter(function(t){return"undefined"!=typeof t}).join(e.rowDel),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.txt.mimeType,fileExtension:l.prototype.txt.fileExtension}),p=l.prototype.txt.buttonContent,d=l.prototype.txt.defaultClass,m=c({uuid:t.uuid,type:f.txt}),g=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return g&&t.checkCaption(g),u.getInstance().setItem(m,s,!0),m}},createObjButton:function(t,e,n,r,o){var i=document.createElement("button");return i.setAttribute("tableexport-id",t),i.className=o.bootstrapClass+o.bootstrapTheme+r,i.textContent=n,i},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return l.prototype.entityMap[t]})},unescapeHtml:function(t){var e=String(t);for(var n in this.entityMap)e=e.replace(RegExp(this.entityMap[n],"g"),n);return e},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=l.prototype.types;return~t.indexOf(e.string.defaultClass)?"s":~t.indexOf(e.number.defaultClass)?"n":~t.indexOf(e["boolean"].defaultClass)?"b":~t.indexOf(e.date.defaultClass)?"d":""},dateNum:function(t,e){e&&(t+=1462);var n=Date.parse(t);return(n-new Date(Date.UTC(1899,11,30)))/864e5},createSheet:function(t){for(var e={},n={s:{c:1e7,r:1e7},e:{c:0,r:0}},o=l.prototype.types,i=0;i!==t.length;++i)for(var a=0;a!==t[i].length;++a){n.s.r>i&&(n.s.r=i),n.s.c>a&&(n.s.c=a),n.e.rExportButtons +
+ +
Additionally, the raw binary data (and byte length) can be retrieved using the getBinaryData prototype method. +
+
+// get raw binary data (i.e. filesize)
+var bytes = TableExport.prototype.getBinaryData(exportData.data, exportData.fileExtension);
+var byteLength = bytes.byteLength;
+
+
+
+ + @@ -126,6 +139,11 @@

ExportButtons // // "id" of selector // format var exportData = instance.getExportData()['export-buttons-table']['xls']; + // get raw binary data (i.e. filesize) + var bytes = TableExport.prototype.getBinaryData(exportData.data, exportData.fileExtension).byteLength; + + console.log('filesize:', bytes + 'B'); + var XLSbutton = document.getElementById('customXLSButton'); XLSbutton.addEventListener('click', function (e) { // // data // mime // name // extension diff --git a/package.json b/package.json index f6f77c8..bf5a350 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tableexport", - "version": "4.0.2", + "version": "4.0.4", "authors": [ "clarketm " ], diff --git a/src/stable/css/tableexport.css b/src/stable/css/tableexport.css index 2d5aa76..a7ffa81 100644 --- a/src/stable/css/tableexport.css +++ b/src/stable/css/tableexport.css @@ -1,5 +1,5 @@ /*! - * TableExport.js v4.0.2 (https://www.travismclarke.com) + * TableExport.js v4.0.4 (https://www.travismclarke.com) * Copyright 2017 Travis Clarke * Licensed under the MIT license */ diff --git a/src/stable/css/tableexport.min.css b/src/stable/css/tableexport.min.css index adb325e..ef2abc1 100644 --- a/src/stable/css/tableexport.min.css +++ b/src/stable/css/tableexport.min.css @@ -1,5 +1,5 @@ /*! - * TableExport.js v4.0.2 (https://www.travismclarke.com) + * TableExport.js v4.0.4 (https://www.travismclarke.com) * Copyright 2017 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,.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{content:"";background:#006400 url(../img/xlsx.svg) no-repeat center}.xls:before{content:"";background:green url(../img/xls.svg) no-repeat center}.csv:before{content:"";background:#00f url(../img/csv.svg) no-repeat center}.txt:before{content:"";background:purple url(../img/txt.svg) no-repeat center} \ No newline at end of file diff --git a/src/stable/js/tableexport.js b/src/stable/js/tableexport.js index 70f521f..2899530 100644 --- a/src/stable/js/tableexport.js +++ b/src/stable/js/tableexport.js @@ -1,5 +1,5 @@ /*! - * TableExport.js v4.0.2 (https://www.travismclarke.com) + * TableExport.js v4.0.4 (https://www.travismclarke.com) * Copyright 2017 Travis Clarke * Licensed under the MIT license */ @@ -124,7 +124,7 @@ * Version. * @memberof TableExport.prototype */ - version: '4.0.2', + version: '4.0.4', /** * Default library options. * @memberof TableExport.prototype @@ -694,22 +694,7 @@ * @param extension {String} file extension */ export2file: function (data, mime, name, extension) { - if (XLSX && !isMobile && extension.substr(0, 4) === '.xls') { - var wb = new this.Workbook(), - ws = this.createSheet(data), - bookType = extension.substr(1) === _type.xls ? _type.biff2 : _type.xlsx; - - wb.SheetNames.push(name); - wb.Sheets[name] = ws; - var wopts = { - bookType: bookType, - bookSST: false, - type: 'binary' - }, - wbout = XLSX.write(wb, wopts); - - data = this.string2ArrayBuffer(wbout); - } + data = this.getBinaryData(data, extension, name); if (isMobile) { var dataURI = 'data:' + mime + ';' + this.charset + ',' + data; @@ -728,6 +713,26 @@ document.body.appendChild(link); link.click(); }, + getBinaryData: function (data, extension, name) { + if (XLSX && !isMobile && extension.substr(0, 4) === '.xls') { + var wb = new this.Workbook(), + ws = this.createSheet(data), + bookType = extension.substr(1) === _type.xls ? _type.biff2 : _type.xlsx; + + name = name || ''; + wb.SheetNames.push(name); + wb.Sheets[name] = ws; + var wopts = { + bookType: bookType, + bookSST: false, + type: 'binary' + }, + wbout = XLSX.write(wb, wopts); + + data = this.string2ArrayBuffer(wbout); + } + return data; + }, /** * Updates the library instance with new/updated options * @param options {Object} TableExport configuration options diff --git a/src/stable/js/tableexport.min.js b/src/stable/js/tableexport.min.js index e42c162..03facf9 100644 --- a/src/stable/js/tableexport.min.js +++ b/src/stable/js/tableexport.min.js @@ -1,6 +1,6 @@ /*! - * TableExport.js v4.0.2 (https://www.travismclarke.com) + * TableExport.js v4.0.4 (https://www.travismclarke.com) * Copyright 2017 Travis Clarke * Licensed under the MIT license */ -!function(t,e){"function"==typeof define&&define.amd?define(["jquery","blobjs","file-saverjs","xlsx"],e):"object"==typeof exports&&"string"!=typeof exports.nodeName?module.exports=e(require("jquery"),require("blobjs"),require("file-saverjs"),require("xlsx")):t.TableExport=e(t.jQuery,t.Blob,t.saveAs,t.XLSX)}(this,function(t,e,n,r){"use strict";function o(){for(var t=arguments,e=1;e tr")),e.rows=a.headers?i(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=a.footers?e.rows.concat(i(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=a.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===a.filename?t.getAttribute("id")?t.getAttribute("id"):n.defaultFilename:a.filename?a.filename:n.defaultFilename,e.uuid=p(t),e.checkCaption=function(e){var n=t.querySelectorAll("caption.tableexport-caption");n.length?n[0].appendChild(e):(n=document.createElement("caption"),n.className=a.bootstrapSettings.bootstrapSpacing+a.position+" tableexport-caption",n.appendChild(e),t.insertBefore(n,t.firstChild))},e.setExportData=function(){return function(t){var n=u.getInstance().getItem(t),r=t.substring(t.indexOf("-")+1);c[e.uuid]=c[e.uuid]||{},c[e.uuid][r]=JSON.parse(n)}}();var o={};for(var s in f)o[s]=0;a.formats.forEach(function(t){!(!r||m||t!==f.xls)&&(t=f.biff2),!(r&&!m||t!==f.xlsx)&&(t=f.xls),o[t]||(e.setExportData(n.exporters[t].call(n,e)),o[t]++)})});var x=document.querySelectorAll("button[tableexport-id]");return d(x,"click",n.downloadHandler,n),n};l.prototype={version:"4.0.2",defaults:{headers:!0,footers:!0,formats:["xls","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},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:{"&":"&","<":"<",">":">","'":"'","/":"/"},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"},types:{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,n=e.settings,r={},o=i(t.rows).map(function(o,s){if(!~n.ignoreRows.indexOf(s-t.thAdj)&&!a(o,n.ignoreCSS)){var l=o.querySelectorAll("th, td");return i(l).map(function(t,o){if(!~n.ignoreCols.indexOf(o)&&!a(t,n.ignoreCSS)){if(a(t,n.emptyCSS))return" ";if(t.hasAttribute("colspan")&&(r[s]=r[s]||{},r[s][o+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var i=1;i=o?u+r[s][i]:u:p++,p!==l);i++);return new Array(u).concat({v:n.formatValue(t.textContent),t:e.getType(t.className)})}return{v:n.formatValue(t.textContent),t:e.getType(t.className)}}}).filter(function(t){return"undefined"!=typeof t})}}).map(function(t){return t&&[].concat.apply([],t)}).filter(function(t){return"undefined"!=typeof t}),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xlsx.mimeType,fileExtension:l.prototype.xlsx.fileExtension}),p=l.prototype.xlsx.buttonContent,d=l.prototype.xlsx.defaultClass,m=c({uuid:t.uuid,type:f.xlsx}),x=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,s,!0),m},biff2:function(t){var e=this,n=e.settings,r={},o=i(t.rows).map(function(o,s){if(!~n.ignoreRows.indexOf(s-t.thAdj)&&!a(o,n.ignoreCSS)){var l=o.querySelectorAll("th, td");return i(l).map(function(t,o){if(!~n.ignoreCols.indexOf(o)&&!a(t,n.ignoreCSS)){if(a(t,n.emptyCSS))return" ";if(t.hasAttribute("colspan")&&(r[s]=r[s]||{},r[s][o+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var i=1;i=o?u+r[s][i]:u:p++,p!==l);i++);return new Array(u).concat({v:n.formatValue(t.textContent),t:e.getType(t.className)})}return{v:n.formatValue(t.textContent),t:e.getType(t.className)}}}).filter(function(t){return"undefined"!=typeof t})}}).map(function(t){return t&&[].concat.apply([],t)}).filter(function(t){return"undefined"!=typeof t}),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xls.mimeType,fileExtension:l.prototype.xls.fileExtension}),p=l.prototype.xls.buttonContent,d=l.prototype.xls.defaultClass,m=c({uuid:t.uuid,type:f.xls}),x=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,s,!0),m},xls:function(t){var e=this,n=e.settings,r=l.prototype.xls.separator,o=i(t.rows).map(function(e,o){if(!~n.ignoreRows.indexOf(o-t.thAdj)&&!a(e,n.ignoreCSS)){var s=e.querySelectorAll("th, td");return i(s).map(function(t,e){if(!~n.ignoreCols.indexOf(e)&&!a(t,n.ignoreCSS))return a(t,n.emptyCSS)?" ":t.textContent}).filter(function(t){return"undefined"!=typeof t}).join(r)}}).filter(function(t){return"undefined"!=typeof t}).join(e.rowDel),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xls.mimeType,fileExtension:l.prototype.xls.fileExtension}),p=l.prototype.xls.buttonContent,d=l.prototype.xls.defaultClass,m=c({uuid:t.uuid,type:f.xls}),x=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,s,!0),m},csv:function(t){var e=this,n=e.settings,r=l.prototype.csv.separator,o=i(t.rows).map(function(e,o){if(!~n.ignoreRows.indexOf(o-t.thAdj)&&!a(e,n.ignoreCSS)){var s=e.querySelectorAll("th, td");return i(s).map(function(t,e){if(!~n.ignoreCols.indexOf(e)&&!a(t,n.ignoreCSS))return a(t,n.emptyCSS)?" ":'"'+n.formatValue(t.textContent.replace(/"/g,'""'))+'"'}).filter(function(t){return"undefined"!=typeof t}).join(r)}}).filter(function(t){return"undefined"!=typeof t}).join(e.rowDel),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.csv.mimeType,fileExtension:l.prototype.csv.fileExtension}),p=l.prototype.csv.buttonContent,d=l.prototype.csv.defaultClass,m=c({uuid:t.uuid,type:f.csv}),x=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,s,!0),m},txt:function(t){var e=this,n=e.settings,r=l.prototype.txt.separator,o=i(t.rows).map(function(e,o){if(!~n.ignoreRows.indexOf(o-t.thAdj)&&!a(e,n.ignoreCSS)){var s=e.querySelectorAll("th, td");return i(s).map(function(t,e){if(!~n.ignoreCols.indexOf(e)&&!a(t,n.ignoreCSS))return a(t,n.emptyCSS)?" ":n.formatValue(t.textContent)}).filter(function(t){return"undefined"!=typeof t}).join(r)}}).filter(function(t){return"undefined"!=typeof t}).join(e.rowDel),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.txt.mimeType,fileExtension:l.prototype.txt.fileExtension}),p=l.prototype.txt.buttonContent,d=l.prototype.txt.defaultClass,m=c({uuid:t.uuid,type:f.txt}),x=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,s,!0),m}},createObjButton:function(t,e,n,r,o){var i=document.createElement("button");return i.setAttribute("tableexport-id",t),i.className=o.bootstrapClass+o.bootstrapTheme+r,i.textContent=n,i},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return l.prototype.entityMap[t]})},unescapeHtml:function(t){var e=String(t);for(var n in this.entityMap)e=e.replace(RegExp(this.entityMap[n],"g"),n);return e},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=l.prototype.types;return~t.indexOf(e.string.defaultClass)?"s":~t.indexOf(e.number.defaultClass)?"n":~t.indexOf(e["boolean"].defaultClass)?"b":~t.indexOf(e.date.defaultClass)?"d":""},dateNum:function(t,e){e&&(t+=1462);var n=Date.parse(t);return(n-new Date(Date.UTC(1899,11,30)))/864e5},createSheet:function(t){for(var e={},n={s:{c:1e7,r:1e7},e:{c:0,r:0}},o=l.prototype.types,i=0;i!==t.length;++i)for(var a=0;a!==t[i].length;++a){n.s.r>i&&(n.s.r=i),n.s.c>a&&(n.s.c=a),n.e.r tr")),e.rows=a.headers?i(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=a.footers?e.rows.concat(i(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=a.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===a.filename?t.getAttribute("id")?t.getAttribute("id"):n.defaultFilename:a.filename?a.filename:n.defaultFilename,e.uuid=p(t),e.checkCaption=function(e){var n=t.querySelectorAll("caption.tableexport-caption");n.length?n[0].appendChild(e):(n=document.createElement("caption"),n.className=a.bootstrapSettings.bootstrapSpacing+a.position+" tableexport-caption",n.appendChild(e),t.insertBefore(n,t.firstChild))},e.setExportData=function(){return function(t){var n=u.getInstance().getItem(t),r=t.substring(t.indexOf("-")+1);c[e.uuid]=c[e.uuid]||{},c[e.uuid][r]=JSON.parse(n)}}();var o={};for(var s in f)o[s]=0;a.formats.forEach(function(t){!(!r||m||t!==f.xls)&&(t=f.biff2),!(r&&!m||t!==f.xlsx)&&(t=f.xls),o[t]||(e.setExportData(n.exporters[t].call(n,e)),o[t]++)})});var g=document.querySelectorAll("button[tableexport-id]");return d(g,"click",n.downloadHandler,n),n};l.prototype={version:"4.0.4",defaults:{headers:!0,footers:!0,formats:["xls","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},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:{"&":"&","<":"<",">":">","'":"'","/":"/"},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"},types:{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,n=e.settings,r={},o=i(t.rows).map(function(o,s){if(!~n.ignoreRows.indexOf(s-t.thAdj)&&!a(o,n.ignoreCSS)){var l=o.querySelectorAll("th, td");return i(l).map(function(t,o){if(!~n.ignoreCols.indexOf(o)&&!a(t,n.ignoreCSS)){if(a(t,n.emptyCSS))return" ";if(t.hasAttribute("colspan")&&(r[s]=r[s]||{},r[s][o+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var i=1;i=o?u+r[s][i]:u:p++,p!==l);i++);return new Array(u).concat({v:n.formatValue(t.textContent),t:e.getType(t.className)})}return{v:n.formatValue(t.textContent),t:e.getType(t.className)}}}).filter(function(t){return"undefined"!=typeof t})}}).map(function(t){return t&&[].concat.apply([],t)}).filter(function(t){return"undefined"!=typeof t}),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xlsx.mimeType,fileExtension:l.prototype.xlsx.fileExtension}),p=l.prototype.xlsx.buttonContent,d=l.prototype.xlsx.defaultClass,m=c({uuid:t.uuid,type:f.xlsx}),g=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return g&&t.checkCaption(g),u.getInstance().setItem(m,s,!0),m},biff2:function(t){var e=this,n=e.settings,r={},o=i(t.rows).map(function(o,s){if(!~n.ignoreRows.indexOf(s-t.thAdj)&&!a(o,n.ignoreCSS)){var l=o.querySelectorAll("th, td");return i(l).map(function(t,o){if(!~n.ignoreCols.indexOf(o)&&!a(t,n.ignoreCSS)){if(a(t,n.emptyCSS))return" ";if(t.hasAttribute("colspan")&&(r[s]=r[s]||{},r[s][o+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var i=1;i=o?u+r[s][i]:u:p++,p!==l);i++);return new Array(u).concat({v:n.formatValue(t.textContent),t:e.getType(t.className)})}return{v:n.formatValue(t.textContent),t:e.getType(t.className)}}}).filter(function(t){return"undefined"!=typeof t})}}).map(function(t){return t&&[].concat.apply([],t)}).filter(function(t){return"undefined"!=typeof t}),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xls.mimeType,fileExtension:l.prototype.xls.fileExtension}),p=l.prototype.xls.buttonContent,d=l.prototype.xls.defaultClass,m=c({uuid:t.uuid,type:f.xls}),g=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return g&&t.checkCaption(g),u.getInstance().setItem(m,s,!0),m},xls:function(t){var e=this,n=e.settings,r=l.prototype.xls.separator,o=i(t.rows).map(function(e,o){if(!~n.ignoreRows.indexOf(o-t.thAdj)&&!a(e,n.ignoreCSS)){var s=e.querySelectorAll("th, td");return i(s).map(function(t,e){if(!~n.ignoreCols.indexOf(e)&&!a(t,n.ignoreCSS))return a(t,n.emptyCSS)?" ":t.textContent}).filter(function(t){return"undefined"!=typeof t}).join(r)}}).filter(function(t){return"undefined"!=typeof t}).join(e.rowDel),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xls.mimeType,fileExtension:l.prototype.xls.fileExtension}),p=l.prototype.xls.buttonContent,d=l.prototype.xls.defaultClass,m=c({uuid:t.uuid,type:f.xls}),g=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return g&&t.checkCaption(g),u.getInstance().setItem(m,s,!0),m},csv:function(t){var e=this,n=e.settings,r=l.prototype.csv.separator,o=i(t.rows).map(function(e,o){if(!~n.ignoreRows.indexOf(o-t.thAdj)&&!a(e,n.ignoreCSS)){var s=e.querySelectorAll("th, td");return i(s).map(function(t,e){if(!~n.ignoreCols.indexOf(e)&&!a(t,n.ignoreCSS))return a(t,n.emptyCSS)?" ":'"'+n.formatValue(t.textContent.replace(/"/g,'""'))+'"'}).filter(function(t){return"undefined"!=typeof t}).join(r)}}).filter(function(t){return"undefined"!=typeof t}).join(e.rowDel),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.csv.mimeType,fileExtension:l.prototype.csv.fileExtension}),p=l.prototype.csv.buttonContent,d=l.prototype.csv.defaultClass,m=c({uuid:t.uuid,type:f.csv}),g=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return g&&t.checkCaption(g),u.getInstance().setItem(m,s,!0),m},txt:function(t){var e=this,n=e.settings,r=l.prototype.txt.separator,o=i(t.rows).map(function(e,o){if(!~n.ignoreRows.indexOf(o-t.thAdj)&&!a(e,n.ignoreCSS)){var s=e.querySelectorAll("th, td");return i(s).map(function(t,e){if(!~n.ignoreCols.indexOf(e)&&!a(t,n.ignoreCSS))return a(t,n.emptyCSS)?" ":n.formatValue(t.textContent)}).filter(function(t){return"undefined"!=typeof t}).join(r)}}).filter(function(t){return"undefined"!=typeof t}).join(e.rowDel),s=JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.txt.mimeType,fileExtension:l.prototype.txt.fileExtension}),p=l.prototype.txt.buttonContent,d=l.prototype.txt.defaultClass,m=c({uuid:t.uuid,type:f.txt}),g=n.exportButtons&&l.prototype.createObjButton(m,s,p,d,n.bootstrapSettings);return g&&t.checkCaption(g),u.getInstance().setItem(m,s,!0),m}},createObjButton:function(t,e,n,r,o){var i=document.createElement("button");return i.setAttribute("tableexport-id",t),i.className=o.bootstrapClass+o.bootstrapTheme+r,i.textContent=n,i},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return l.prototype.entityMap[t]})},unescapeHtml:function(t){var e=String(t);for(var n in this.entityMap)e=e.replace(RegExp(this.entityMap[n],"g"),n);return e},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=l.prototype.types;return~t.indexOf(e.string.defaultClass)?"s":~t.indexOf(e.number.defaultClass)?"n":~t.indexOf(e["boolean"].defaultClass)?"b":~t.indexOf(e.date.defaultClass)?"d":""},dateNum:function(t,e){e&&(t+=1462);var n=Date.parse(t);return(n-new Date(Date.UTC(1899,11,30)))/864e5},createSheet:function(t){for(var e={},n={s:{c:1e7,r:1e7},e:{c:0,r:0}},o=l.prototype.types,i=0;i!==t.length;++i)for(var a=0;a!==t[i].length;++a){n.s.r>i&&(n.s.r=i),n.s.c>a&&(n.s.c=a),n.e.r