tableExport.min.js 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. tableExport.jquery.plugin
  3. Version 1.9.10
  4. Copyright (c) 2015-2018 hhurz, https://github.com/hhurz
  5. Original Work Copyright (c) 2014 Giri Raj
  6. Licensed under the MIT License
  7. */
  8. var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(c,f,u){c instanceof String&&(c=String(c));for(var C=c.length,D=0;D<C;D++){var O=c[D];if(f.call(u,O,D,c))return{i:D,v:O}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(c,f,u){c!=Array.prototype&&c!=Object.prototype&&(c[f]=u.value)};
  9. $jscomp.getGlobal=function(c){return"undefined"!=typeof window&&window===c?c:"undefined"!=typeof global&&null!=global?global:c};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(c,f,u,C){if(f){u=$jscomp.global;c=c.split(".");for(C=0;C<c.length-1;C++){var D=c[C];D in u||(u[D]={});u=u[D]}c=c[c.length-1];C=u[c];f=f(C);f!=C&&null!=f&&$jscomp.defineProperty(u,c,{configurable:!0,writable:!0,value:f})}};
  10. $jscomp.polyfill("Array.prototype.find",function(c){return c?c:function(c,u){return $jscomp.findInternal(this,c,u).v}},"es6","es3");
  11. (function(c){c.fn.tableExport=function(f){function u(b){var d=[];C(b,"tbody").each(function(){d.push.apply(d,D(c(this),a.tbodySelector).toArray())});a.tfootSelector.length&&C(b,"tfoot").each(function(){d.push.apply(d,D(c(this),a.tfootSelector).toArray())});return d}function C(b,d){var a=b.parents("table").length;return b.find(d).filter(function(){return c(this).closest("table").parents("table").length===a})}function D(b,d){return b.find(d).filter(function(){return 0==a.maxNestedTables||c(this).find("table").length<
  12. a.maxNestedTables&&c(this).parents("table").length<=a.maxNestedTables})}function O(b){var d=[];c(b).find("thead").first().find("th").each(function(b,a){void 0!==c(a).attr("data-field")?d[b]=c(a).attr("data-field"):d[b]=b.toString()});return d}function P(b){var d="undefined"!==typeof b[0].cellIndex,a="undefined"!==typeof b[0].rowIndex,r=d||a?Aa(b):b.is(":visible"),g=b.data("tableexport-display");d&&"none"!=g&&"always"!=g&&(b=c(b[0].parentNode),a="undefined"!==typeof b[0].rowIndex,g=b.data("tableexport-display"));
  13. a&&"none"!=g&&"always"!=g&&(g=b.closest("table").data("tableexport-display"));return"none"!==g&&(1==r||"always"==g)}function Aa(b){var d=[];T&&(d=K.filter(function(){var d=!1;this.nodeType==b[0].nodeType&&("undefined"!==typeof this.rowIndex&&this.rowIndex==b[0].rowIndex?d=!0:"undefined"!==typeof this.cellIndex&&this.cellIndex==b[0].cellIndex&&"undefined"!==typeof this.parentNode.rowIndex&&"undefined"!==typeof b[0].parentNode.rowIndex&&this.parentNode.rowIndex==b[0].parentNode.rowIndex&&(d=!0));return d}));
  14. return 0==T||0==d.length}function Ba(b,d,k){var r=!1;P(b)?0<a.ignoreColumn.length&&(-1!=c.inArray(k,a.ignoreColumn)||-1!=c.inArray(k-d,a.ignoreColumn)||Q.length>k&&"undefined"!=typeof Q[k]&&-1!=c.inArray(Q[k],a.ignoreColumn))&&(r=!0):r=!0;return r}function B(b,d,k,r,g){if("function"===typeof g){var h=!1;"function"===typeof a.onIgnoreRow&&(h=a.onIgnoreRow(c(b),k));if(!1===h&&-1==c.inArray(k,a.ignoreRow)&&-1==c.inArray(k-r,a.ignoreRow)&&P(c(b))){var x=c(b).find(d),q=0;x.each(function(b){var d=c(this),
  15. a,h=R(this),r=S(this);c.each(G,function(){if(k>=this.s.r&&k<=this.e.r&&q>=this.s.c&&q<=this.e.c)for(a=0;a<=this.e.c-this.s.c;++a)g(null,k,q++)});if(!1===Ba(d,x.length,b)){if(r||h)h=h||1,G.push({s:{r:k,c:q},e:{r:k+(r||1)-1,c:q+h-1}});g(this,k,q++)}if(h)for(a=0;a<h-1;++a)g(null,k,q++)});c.each(G,function(){if(k>=this.s.r&&k<=this.e.r&&q>=this.s.c&&q<=this.e.c)for(aa=0;aa<=this.e.c-this.s.c;++aa)g(null,k,q++)})}}}function na(b,d){!0===a.consoleLog&&console.log(b.output());if("string"===a.outputMode)return b.output();
  16. if("base64"===a.outputMode)return L(b.output());if("window"===a.outputMode)window.URL=window.URL||window.webkitURL,window.open(window.URL.createObjectURL(b.output("blob")));else try{var k=b.output("blob");saveAs(k,a.fileName+".pdf")}catch(r){H(a.fileName+".pdf","data:application/pdf"+(d?"":";base64")+",",d?b.output("blob"):b.output())}}function oa(b,d,a){var k=0;"undefined"!==typeof a&&(k=a.colspan);if(0<=k){for(var g=b.width,c=b.textPos.x,x=d.table.columns.indexOf(d.column),q=1;q<k;q++)g+=d.table.columns[x+
  17. q].width;1<k&&("right"===b.styles.halign?c=b.textPos.x+g-b.width:"center"===b.styles.halign&&(c=b.textPos.x+(g-b.width)/2));b.width=g;b.textPos.x=c;"undefined"!==typeof a&&1<a.rowspan&&(b.height*=a.rowspan);if("middle"===b.styles.valign||"bottom"===b.styles.valign)a=("string"===typeof b.text?b.text.split(/\r\n|\r|\n/g):b.text).length||1,2<a&&(b.textPos.y-=(2-1.15)/2*d.row.styles.fontSize*(a-2)/3);return!0}return!1}function pa(b,a,k){"undefined"!=typeof k.images&&a.each(function(){var a=c(this).children();
  18. if(c(this).is("img")){var d=qa(this.src);k.images[d]={url:this.src,src:this.src}}"undefined"!=typeof a&&0<a.length&&pa(b,a,k)})}function Ca(b,a){function d(b){if(b.url){var d=new Image;g=++h;d.crossOrigin="Anonymous";d.onerror=d.onload=function(){if(d.complete&&(0===d.src.indexOf("data:image/")&&(d.width=b.width||d.width||0,d.height=b.height||d.height||0),d.width+d.height)){var k=document.createElement("canvas"),c=k.getContext("2d");k.width=d.width;k.height=d.height;c.drawImage(d,0,0);b.src=k.toDataURL("image/jpeg")}--h||
  19. a(g)};d.src=b.url}}var c,g=0,h=0;if("undefined"!=typeof b.images)for(c in b.images)b.images.hasOwnProperty(c)&&d(b.images[c]);(b=h)||(a(g),b=void 0);return b}function ra(b,d,k){d.each(function(){var d=c(this).children(),g=0;if(c(this).is("div")){var h=ba(M(this,"background-color"),[255,255,255]),x=ba(M(this,"border-top-color"),[0,0,0]),q=ca(this,"border-top-width",a.jspdf.unit),e=this.getBoundingClientRect(),f=this.offsetLeft*k.dw;g=this.offsetTop*k.dh;var l=e.width*k.dw;e=e.height*k.dh;k.doc.setDrawColor.apply(void 0,
  20. x);k.doc.setFillColor.apply(void 0,h);k.doc.setLineWidth(q);k.doc.rect(b.x+f,b.y+g,l,e,q?"FD":"F")}else if(c(this).is("img")&&"undefined"!=typeof k.images&&(h=qa(this.src),h=k.images[h],"undefined"!=typeof h)){x=b.width/b.height;q=this.width/this.height;f=b.width;l=b.height;e=19.049976/25.4;q<=x?(l=Math.min(b.height,this.height),f=this.width*l/this.height):q>x&&(f=Math.min(b.width,this.width),l=this.height*f/this.width);f*=e;l*=e;l<b.height&&(g=(b.height-l)/2);try{k.doc.addImage(h.src,b.textPos.x,
  21. b.y+g,f,l)}catch(Ga){}b.textPos.x+=f}"undefined"!=typeof d&&0<d.length&&ra(b,d,k)})}function sa(b,d,a){if("function"===typeof a.onAutotableText)a.onAutotableText(a.doc,b,d);else{var k=b.textPos.x,g=b.textPos.y,h={halign:b.styles.halign,valign:b.styles.valign};if(d.length){for(d=d[0];d.previousSibling;)d=d.previousSibling;for(var x=!1,q=!1;d;){var e=d.innerText||d.textContent||"";e=(e.length&&" "==e[0]?" ":"")+c.trim(e)+(1<e.length&&" "==e[e.length-1]?" ":"");c(d).is("br")&&(k=b.textPos.x,g+=a.doc.internal.getFontSize());
  22. c(d).is("b")?x=!0:c(d).is("i")&&(q=!0);(x||q)&&a.doc.setFontType(x&&q?"bolditalic":x?"bold":"italic");var f=a.doc.getStringUnitWidth(e)*a.doc.internal.getFontSize();if(f){if("linebreak"===b.styles.overflow&&k>b.textPos.x&&k+f>b.textPos.x+b.width){if(0<=".,!%*;:=-".indexOf(e.charAt(0))){var l=e.charAt(0);f=a.doc.getStringUnitWidth(l)*a.doc.internal.getFontSize();k+f<=b.textPos.x+b.width&&(a.doc.autoTableText(l,k,g,h),e=e.substring(1,e.length));f=a.doc.getStringUnitWidth(e)*a.doc.internal.getFontSize()}k=
  23. b.textPos.x;g+=a.doc.internal.getFontSize()}for(;e.length&&k+f>b.textPos.x+b.width;)e=e.substring(0,e.length-1),f=a.doc.getStringUnitWidth(e)*a.doc.internal.getFontSize();a.doc.autoTableText(e,k,g,h);k+=f}if(x||q)c(d).is("b")?x=!1:c(d).is("i")&&(q=!1),a.doc.setFontType(x||q?x?"bold":"italic":"normal");d=d.nextSibling}b.textPos.x=k;b.textPos.y=g}else a.doc.autoTableText(b.text,b.textPos.x,b.textPos.y,h)}}function da(b,a,c){return b.replace(new RegExp(a.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"),
  24. "g"),c)}function ha(b){b=da(b||"0",a.numbers.html.thousandsSeparator,"");b=da(b,a.numbers.html.decimalMark,".");return"number"===typeof b||!1!==jQuery.isNumeric(b)?b:!1}function Da(b){-1<b.indexOf("%")?(b=ha(b.replace(/%/g,"")),!1!==b&&(b/=100)):b=!1;return b}function z(b,d,k){var r="";if(null!==b){var g=c(b);if(g[0].hasAttribute("data-tableexport-value"))var h=(h=g.data("tableexport-value"))?h+"":"";else if(h=g.html(),"function"===typeof a.onCellHtmlData)h=a.onCellHtmlData(g,d,k,h);else if(""!=h){var e=
  25. c.parseHTML(h),f=0,l=0;h="";c.each(e,function(){if(c(this).is("input"))h+=g.find("input").eq(f++).val();else if(c(this).is("select"))h+=g.find("select option:selected").eq(l++).text();else if("undefined"===typeof c(this).html())h+=c(this).text();else if(void 0===jQuery().bootstrapTable||!0!==c(this).hasClass("filterControl")&&0===c(b).parents(".detail-view").length)h+=c(this).html()})}if(!0===a.htmlContent)r=c.trim(h);else if(h&&""!=h)if(""!=c(b).data("tableexport-cellformat")){var m=h.replace(/\n/g,
  26. "\u2028").replace(/<br\s*[\/]?>/gi,"\u2060"),n=c("<div/>").html(m).contents();e=!1;m="";c.each(n.text().split("\u2028"),function(b,a){0<b&&(m+=" ");m+=c.trim(a)});c.each(m.split("\u2060"),function(b,a){0<b&&(r+="\n");r+=c.trim(a).replace(/\u00AD/g,"")});if("json"==a.type||"excel"===a.type&&"xmlss"===a.excelFileFormat||!1===a.numbers.output)e=ha(r),!1!==e&&(r=Number(e));else if(a.numbers.html.decimalMark!=a.numbers.output.decimalMark||a.numbers.html.thousandsSeparator!=a.numbers.output.thousandsSeparator)if(e=
  27. ha(r),!1!==e){n=(""+e.substr(0>e?1:0)).split(".");1==n.length&&(n[1]="");var p=3<n[0].length?n[0].length%3:0;r=(0>e?"-":"")+(a.numbers.output.thousandsSeparator?(p?n[0].substr(0,p)+a.numbers.output.thousandsSeparator:"")+n[0].substr(p).replace(/(\d{3})(?=\d)/g,"$1"+a.numbers.output.thousandsSeparator):n[0])+(n[1].length?a.numbers.output.decimalMark+n[1]:"")}}else r=h;!0===a.escape&&(r=escape(r));"function"===typeof a.onCellData&&(r=a.onCellData(g,d,k,r))}return r}function Ea(b,a,c){return a+"-"+c.toLowerCase()}
  28. function ba(b,a){(b=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(b))&&(a=[parseInt(b[1]),parseInt(b[2]),parseInt(b[3])]);return a}function ta(b){var a=M(b,"text-align"),c=M(b,"font-weight"),r=M(b,"font-style"),g="";"start"==a&&(a="rtl"==M(b,"direction")?"right":"left");700<=c&&(g="bold");"italic"==r&&(g+=r);""===g&&(g="normal");a={style:{align:a,bcolor:ba(M(b,"background-color"),[255,255,255]),color:ba(M(b,"color"),[0,0,0]),fstyle:g},colspan:R(b),rowspan:S(b)};null!==b&&(b=b.getBoundingClientRect(),
  29. a.rect={width:b.width,height:b.height});return a}function R(b){var a=c(b).data("tableexport-colspan");"undefined"==typeof a&&c(b).is("[colspan]")&&(a=c(b).attr("colspan"));return parseInt(a)||0}function S(b){var a=c(b).data("tableexport-rowspan");"undefined"==typeof a&&c(b).is("[rowspan]")&&(a=c(b).attr("rowspan"));return parseInt(a)||0}function M(b,a){try{return window.getComputedStyle?(a=a.replace(/([a-z])([A-Z])/,Ea),window.getComputedStyle(b,null).getPropertyValue(a)):b.currentStyle?b.currentStyle[a]:
  30. b.style[a]}catch(k){}return""}function ca(b,a,c){a=M(b,a).match(/\d+/);if(null!==a){a=a[0];b=b.parentElement;var d=document.createElement("div");d.style.overflow="hidden";d.style.visibility="hidden";b.appendChild(d);d.style.width=100+c;c=100/d.offsetWidth;b.removeChild(d);return a*c}return 0}function ia(){if(!(this instanceof ia))return new ia;this.SheetNames=[];this.Sheets={}}function ua(a){for(var b=new ArrayBuffer(a.length),c=new Uint8Array(b),e=0;e!=a.length;++e)c[e]=a.charCodeAt(e)&255;return b}
  31. function Fa(a){for(var b={},c={s:{c:1E7,r:1E7},e:{c:0,r:0}},e=0;e!=a.length;++e)for(var g=0;g!=a[e].length;++g){c.s.r>e&&(c.s.r=e);c.s.c>g&&(c.s.c=g);c.e.r<e&&(c.e.r=e);c.e.c<g&&(c.e.c=g);var h={v:a[e][g]};if(null!==h.v){var f=XLSX.utils.encode_cell({c:g,r:e});if("number"===typeof h.v)h.t="n";else if("boolean"===typeof h.v)h.t="b";else if(h.v instanceof Date){h.t="n";h.z=XLSX.SSF._table[14];var q=h;var l=(Date.parse(h.v)-new Date(Date.UTC(1899,11,30)))/864E5;q.v=l}else h.t="s";b[f]=h}}1E7>c.s.c&&
  32. (b["!ref"]=XLSX.utils.encode_range(c));return b}function qa(a){var b=0,c;if(0===a.length)return b;var e=0;for(c=a.length;e<c;e++){var g=a.charCodeAt(e);b=(b<<5)-b+g;b|=0}return b}function H(a,d,c){var b=window.navigator.userAgent;if(!1!==a&&window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(new Blob([c]),a);else if(!1!==a&&(0<b.indexOf("MSIE ")||b.match(/Trident.*rv\:11\./))){if(d=document.createElement("iframe")){document.body.appendChild(d);d.setAttribute("style","display:none");
  33. d.contentDocument.open("txt/plain","replace");d.contentDocument.write(c);d.contentDocument.close();d.contentDocument.focus();switch(a.substr(a.lastIndexOf(".")+1)){case "doc":case "json":case "png":case "pdf":case "xls":case "xlsx":a+=".txt"}d.contentDocument.execCommand("SaveAs",!0,a);document.body.removeChild(d)}}else{var g=document.createElement("a");if(g){var h=null;g.style.display="none";!1!==a?g.download=a:g.target="_blank";"object"==typeof c?(window.URL=window.URL||window.webkitURL,h=window.URL.createObjectURL(c),
  34. g.href=h):0<=d.toLowerCase().indexOf("base64,")?g.href=d+L(c):g.href=d+encodeURIComponent(c);document.body.appendChild(g);if(document.createEvent)null===ea&&(ea=document.createEvent("MouseEvents")),ea.initEvent("click",!0,!1),g.dispatchEvent(ea);else if(document.createEventObject)g.fireEvent("onclick");else if("function"==typeof g.onclick)g.onclick();setTimeout(function(){h&&window.URL.revokeObjectURL(h);document.body.removeChild(g)},100)}}}function L(a){var b,c="",e=0;if("string"===typeof a){a=a.replace(/\x0d\x0a/g,
  35. "\n");var g="";for(b=0;b<a.length;b++){var h=a.charCodeAt(b);128>h?g+=String.fromCharCode(h):(127<h&&2048>h?g+=String.fromCharCode(h>>6|192):(g+=String.fromCharCode(h>>12|224),g+=String.fromCharCode(h>>6&63|128)),g+=String.fromCharCode(h&63|128))}a=g}for(;e<a.length;){var f=a.charCodeAt(e++);g=a.charCodeAt(e++);b=a.charCodeAt(e++);h=f>>2;f=(f&3)<<4|g>>4;var q=(g&15)<<2|b>>6;var l=b&63;isNaN(g)?q=l=64:isNaN(b)&&(l=64);c=c+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(h)+
  36. "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(f)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(q)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(l)}return c}var a={consoleLog:!1,csvEnclosure:'"',csvSeparator:",",csvUseBOM:!0,displayTableName:!1,escape:!1,excelFileFormat:"xlshtml",excelPageOrientation:"portrait",excelRTL:!1,excelstyles:[],exportHiddenCells:!1,fileName:"tableExport",htmlContent:!1,ignoreColumn:[],
  37. ignoreRow:[],jsonScope:"all",jspdf:{orientation:"p",unit:"pt",format:"a4",margins:{left:20,right:10,top:10,bottom:10},onDocCreated:null,autotable:{styles:{cellPadding:2,rowHeight:12,fontSize:8,fillColor:255,textColor:50,fontStyle:"normal",overflow:"ellipsize",halign:"left",valign:"middle"},headerStyles:{fillColor:[52,73,94],textColor:255,fontStyle:"bold",halign:"center"},alternateRowStyles:{fillColor:245},tableExport:{doc:null,onAfterAutotable:null,onBeforeAutotable:null,onAutotableText:null,onTable:null,
  38. outputImages:!0}}},maxNestedTables:1,numbers:{html:{decimalMark:".",thousandsSeparator:","},output:{decimalMark:".",thousandsSeparator:","}},onCellData:null,onCellHtmlData:null,onIgnoreRow:null,onMsoNumberFormat:null,outputMode:"file",pdfmake:{enabled:!1,docDefinition:{pageOrientation:"portrait",defaultStyle:{font:"Roboto"}},fonts:{}},tbodySelector:"tr",tfootSelector:"tr",theadSelector:"tr",tableName:"Table",type:"csv",worksheetName:""},v=this,ea=null,p=[],t=[],l=0,n="",Q=[],G=[],K=[],T=!1;c.extend(!0,
  39. a,f);a.maxNestedTables=0<=a.maxNestedTables?a.maxNestedTables:1;Q=O(v);if("csv"==a.type||"tsv"==a.type||"txt"==a.type){var I="",W=0;G=[];l=0;var ja=function(b,d,k){b.each(function(){n="";B(this,d,l,k+b.length,function(b,c,d){var g=n,h="";if(null!==b)if(b=z(b,c,d),c=null===b||""===b?"":b.toString(),"tsv"==a.type)b instanceof Date&&b.toLocaleString(),h=da(c,"\t"," ");else if(b instanceof Date)h=a.csvEnclosure+b.toLocaleString()+a.csvEnclosure;else if(h=da(c,a.csvEnclosure,a.csvEnclosure+a.csvEnclosure),
  40. 0<=h.indexOf(a.csvSeparator)||/[\r\n ]/g.test(h))h=a.csvEnclosure+h+a.csvEnclosure;n=g+(h+("tsv"==a.type?"\t":a.csvSeparator))});n=c.trim(n).substring(0,n.length-1);0<n.length&&(0<I.length&&(I+="\n"),I+=n);l++});return b.length};W+=ja(c(v).find("thead").first().find(a.theadSelector),"th,td",W);C(c(v),"tbody").each(function(){W+=ja(D(c(this),a.tbodySelector),"td,th",W)});a.tfootSelector.length&&ja(c(v).find("tfoot").first().find(a.tfootSelector),"td,th",W);I+="\n";!0===a.consoleLog&&console.log(I);
  41. if("string"===a.outputMode)return I;if("base64"===a.outputMode)return L(I);if("window"===a.outputMode){H(!1,"data:text/"+("csv"==a.type?"csv":"plain")+";charset=utf-8,",I);return}try{var A=new Blob([I],{type:"text/"+("csv"==a.type?"csv":"plain")+";charset=utf-8"});saveAs(A,a.fileName+"."+a.type,"csv"!=a.type||!1===a.csvUseBOM)}catch(b){H(a.fileName+"."+a.type,"data:text/"+("csv"==a.type?"csv":"plain")+";charset=utf-8,"+("csv"==a.type&&a.csvUseBOM?"\ufeff":""),I)}}else if("sql"==a.type){l=0;G=[];var w=
  42. "INSERT INTO `"+a.tableName+"` (";p=c(v).find("thead").first().find(a.theadSelector);p.each(function(){B(this,"th,td",l,p.length,function(a,c,k){w+="'"+z(a,c,k)+"',"});l++;w=c.trim(w).substring(0,w.length-1)});w+=") VALUES ";t=u(c(v));c(t).each(function(){n="";B(this,"td,th",l,p.length+t.length,function(a,c,k){n+="'"+z(a,c,k)+"',"});3<n.length&&(w+="("+n,w=c.trim(w).substring(0,w.length-1),w+="),");l++});w=c.trim(w).substring(0,w.length-1);w+=";";!0===a.consoleLog&&console.log(w);if("string"===a.outputMode)return w;
  43. if("base64"===a.outputMode)return L(w);try{A=new Blob([w],{type:"text/plain;charset=utf-8"}),saveAs(A,a.fileName+".sql")}catch(b){H(a.fileName+".sql","data:application/sql;charset=utf-8,",w)}}else if("json"==a.type){var U=[];G=[];p=c(v).find("thead").first().find(a.theadSelector);p.each(function(){var a=[];B(this,"th,td",l,p.length,function(b,c,e){a.push(z(b,c,e))});U.push(a)});var ka=[];t=u(c(v));c(t).each(function(){var a={},d=0;B(this,"td,th",l,p.length+t.length,function(b,c,g){U.length?a[U[U.length-
  44. 1][d]]=z(b,c,g):a[d]=z(b,c,g);d++});!1===c.isEmptyObject(a)&&ka.push(a);l++});f="";f="head"==a.jsonScope?JSON.stringify(U):"data"==a.jsonScope?JSON.stringify(ka):JSON.stringify({header:U,data:ka});!0===a.consoleLog&&console.log(f);if("string"===a.outputMode)return f;if("base64"===a.outputMode)return L(f);try{A=new Blob([f],{type:"application/json;charset=utf-8"}),saveAs(A,a.fileName+".json")}catch(b){H(a.fileName+".json","data:application/json;charset=utf-8;base64,",f)}}else if("xml"===a.type){l=
  45. 0;G=[];var J='<?xml version="1.0" encoding="utf-8"?>';J+="<tabledata><fields>";p=c(v).find("thead").first().find(a.theadSelector);p.each(function(){B(this,"th,td",l,p.length,function(a,c,e){J+="<field>"+z(a,c,e)+"</field>"});l++});J+="</fields><data>";var va=1;t=u(c(v));c(t).each(function(){var a=1;n="";B(this,"td,th",l,p.length+t.length,function(b,c,e){n+="<column-"+a+">"+z(b,c,e)+"</column-"+a+">";a++});0<n.length&&"<column-1></column-1>"!=n&&(J+='<row id="'+va+'">'+n+"</row>",va++);l++});J+="</data></tabledata>";
  46. !0===a.consoleLog&&console.log(J);if("string"===a.outputMode)return J;if("base64"===a.outputMode)return L(J);try{A=new Blob([J],{type:"application/xml;charset=utf-8"}),saveAs(A,a.fileName+".xml")}catch(b){H(a.fileName+".xml","data:application/xml;charset=utf-8;base64,",J)}}else if("excel"===a.type&&"xmlss"===a.excelFileFormat){var la=[],F=[];c(v).filter(function(){return P(c(this))}).each(function(){function b(a,b,d){var g=[];c(a).each(function(){var b=0,e=0;n="";B(this,"td,th",l,d+a.length,function(a,
  47. d,h){if(null!==a){var k="";d=z(a,d,h);h="String";if(!1!==jQuery.isNumeric(d))h="Number";else{var f=Da(d);!1!==f&&(d=f,h="Number",k+=' ss:StyleID="pct1"')}"Number"!==h&&(d=d.replace(/\n/g,"<br>"));f=R(a);a=S(a);c.each(g,function(){if(l>=this.s.r&&l<=this.e.r&&e>=this.s.c&&e<=this.e.c)for(var a=0;a<=this.e.c-this.s.c;++a)e++,b++});if(a||f)a=a||1,f=f||1,g.push({s:{r:l,c:e},e:{r:l+a-1,c:e+f-1}});1<f&&(k+=' ss:MergeAcross="'+(f-1)+'"',e+=f-1);1<a&&(k+=' ss:MergeDown="'+(a-1)+'" ss:StyleID="rsp1"');0<b&&
  48. (k+=' ss:Index="'+(e+1)+'"',b=0);n+="<Cell"+k+'><Data ss:Type="'+h+'">'+c("<div />").text(d).html()+"</Data></Cell>\r";e++}});0<n.length&&(E+='<Row ss:AutoFitHeight="0">\r'+n+"</Row>\r");l++});return a.length}var d=c(this),e="";"string"===typeof a.worksheetName&&a.worksheetName.length?e=a.worksheetName+" "+(F.length+1):"undefined"!==typeof a.worksheetName[F.length]&&(e=a.worksheetName[F.length]);e.length||(e=d.find("caption").text()||"");e.length||(e="Table "+(F.length+1));e=c.trim(e.replace(/[\\\/[\]*:?'"]/g,
  49. "").substring(0,31));F.push(c("<div />").text(e).html());!1===a.exportHiddenCells&&(K=d.find("tr, th, td").filter(":hidden"),T=0<K.length);l=0;Q=O(this);E="<Table>\r";e=0;e+=b(d.find("thead").first().find(a.theadSelector),"th,td",e);b(u(d),"td,th",e);E+="</Table>\r";la.push(E);!0===a.consoleLog&&console.log(E)});f={};for(var y={},m,N,V=0,aa=F.length;V<aa;V++)m=F[V],N=f[m],N=f[m]=null==N?1:N+1,2==N&&(F[y[m]]=F[y[m]].substring(0,29)+"-1"),1<f[m]?F[V]=F[V].substring(0,29)+"-"+f[m]:y[m]=V;f='<?xml version="1.0" encoding="UTF-8"?>\r<?mso-application progid="Excel.Sheet"?>\r<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"\r xmlns:o="urn:schemas-microsoft-com:office:office"\r xmlns:x="urn:schemas-microsoft-com:office:excel"\r xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"\r xmlns:html="http://www.w3.org/TR/REC-html40">\r<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">\r <Created>'+
  50. (new Date).toISOString()+'</Created>\r</DocumentProperties>\r<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">\r <AllowPNG/>\r</OfficeDocumentSettings>\r<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">\r <WindowHeight>9000</WindowHeight>\r <WindowWidth>13860</WindowWidth>\r <WindowTopX>0</WindowTopX>\r <WindowTopY>0</WindowTopY>\r <ProtectStructure>False</ProtectStructure>\r <ProtectWindows>False</ProtectWindows>\r</ExcelWorkbook>\r<Styles>\r <Style ss:ID="Default" ss:Name="Normal">\r <Alignment ss:Vertical="Bottom"/>\r <Borders/>\r <Font/>\r <Interior/>\r <NumberFormat/>\r <Protection/>\r </Style>\r <Style ss:ID="rsp1">\r <Alignment ss:Vertical="Center"/>\r </Style>\r <Style ss:ID="pct1">\r <NumberFormat ss:Format="Percent"/>\r </Style>\r</Styles>\r';
  51. for(y=0;y<la.length;y++)f+='<Worksheet ss:Name="'+F[y]+'" ss:RightToLeft="'+(a.excelRTL?"1":"0")+'">\r'+la[y],f=a.excelRTL?f+'<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">\r<DisplayRightToLeft/>\r</WorksheetOptions>\r':f+'<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"/>\r',f+="</Worksheet>\r";f+="</Workbook>\r";!0===a.consoleLog&&console.log(f);if("string"===a.outputMode)return f;if("base64"===a.outputMode)return L(f);try{A=new Blob([f],{type:"application/xml;charset=utf-8"}),
  52. saveAs(A,a.fileName+".xml")}catch(b){H(a.fileName+".xml","data:application/xml;charset=utf-8;base64,",f)}}else if("excel"==a.type||"xls"==a.type||"word"==a.type||"doc"==a.type){f="excel"==a.type||"xls"==a.type?"excel":"word";y="excel"==f?"xls":"doc";m='xmlns:x="urn:schemas-microsoft-com:office:'+f+'"';var E="",X="";c(v).filter(function(){return P(c(this))}).each(function(){var b=c(this);""===X&&(X=a.worksheetName||b.find("caption").text()||"Table",X=c.trim(X.replace(/[\\\/[\]*:?'"]/g,"").substring(0,
  53. 31)));!1===a.exportHiddenCells&&(K=b.find("tr, th, td").filter(":hidden"),T=0<K.length);l=0;G=[];Q=O(this);E+="<table><thead>";p=b.find("thead").first().find(a.theadSelector);p.each(function(){n="";B(this,"th,td",l,p.length,function(b,e,f){if(null!==b){var d="";n+="<th";for(var h in a.excelstyles)if(a.excelstyles.hasOwnProperty(h)){var k=c(b).css(a.excelstyles[h]);""!==k&&"0px none rgb(0, 0, 0)"!=k&&"rgba(0, 0, 0, 0)"!=k&&(d+=""===d?'style="':";",d+=a.excelstyles[h]+":"+k)}""!==d&&(n+=" "+d+'"');
  54. d=R(b);0<d&&(n+=' colspan="'+d+'"');d=S(b);0<d&&(n+=' rowspan="'+d+'"');n+=">"+z(b,e,f)+"</th>"}});0<n.length&&(E+="<tr>"+n+"</tr>");l++});E+="</thead><tbody>";t=u(b);c(t).each(function(){var b=c(this);n="";B(this,"td,th",l,p.length+t.length,function(d,e,g){if(null!==d){var h=z(d,e,g),k="",f=c(d).data("tableexport-msonumberformat");"undefined"==typeof f&&"function"===typeof a.onMsoNumberFormat&&(f=a.onMsoNumberFormat(d,e,g));"undefined"!=typeof f&&""!==f&&(k="style=\"mso-number-format:'"+f+"'");for(var l in a.excelstyles)a.excelstyles.hasOwnProperty(l)&&
  55. (f=c(d).css(a.excelstyles[l]),""===f&&(f=b.css(a.excelstyles[l])),""!==f&&"0px none rgb(0, 0, 0)"!=f&&"rgba(0, 0, 0, 0)"!=f&&(k+=""===k?'style="':";",k+=a.excelstyles[l]+":"+f));n+="<td";""!==k&&(n+=" "+k+'"');e=R(d);0<e&&(n+=' colspan="'+e+'"');d=S(d);0<d&&(n+=' rowspan="'+d+'"');"string"===typeof h&&""!=h&&(h=h.replace(/\n/g,"<br>"));n+=">"+h+"</td>"}});0<n.length&&(E+="<tr>"+n+"</tr>");l++});a.displayTableName&&(E+="<tr><td></td></tr><tr><td></td></tr><tr><td>"+z(c("<p>"+a.tableName+"</p>"))+"</td></tr>");
  56. E+="</tbody></table>";!0===a.consoleLog&&console.log(E)});m='<html xmlns:o="urn:schemas-microsoft-com:office:office" '+m+' xmlns="http://www.w3.org/TR/REC-html40">'+('<meta http-equiv="content-type" content="application/vnd.ms-'+f+'; charset=UTF-8">')+"<head>";"excel"===f&&(m+="\x3c!--[if gte mso 9]>",m+="<xml>",m+="<x:ExcelWorkbook>",m+="<x:ExcelWorksheets>",m+="<x:ExcelWorksheet>",m+="<x:Name>",m+=X,m+="</x:Name>",m+="<x:WorksheetOptions>",m+="<x:DisplayGridlines/>",a.excelRTL&&(m+="<x:DisplayRightToLeft/>"),
  57. m+="</x:WorksheetOptions>",m+="</x:ExcelWorksheet>",m+="</x:ExcelWorksheets>",m+="</x:ExcelWorkbook>",m+="</xml>",m+="<![endif]--\x3e");m+="<style>";"landscape"===a.excelPageOrientation&&(m+="@page { size:"+a.excelPageOrientation+"; mso-page-orientation:"+a.excelPageOrientation+"; }");m+="br {mso-data-placement:same-cell;}";m+="</style>";m+="</head>";m+="<body>";m+=E;m+="</body>";m+="</html>";!0===a.consoleLog&&console.log(m);if("string"===a.outputMode)return m;if("base64"===a.outputMode)return L(m);
  58. try{A=new Blob([m],{type:"application/vnd.ms-"+a.type}),saveAs(A,a.fileName+"."+y)}catch(b){H(a.fileName+"."+y,"data:application/vnd.ms-"+f+";base64,",m)}}else if("xlsx"==a.type){var wa=[],ma=[];l=0;t=c(v).find("thead").first().find(a.theadSelector).toArray();t.push.apply(t,u(c(v)));c(t).each(function(){var b=[];B(this,"th,td",l,t.length,function(d,e,f){if("undefined"!==typeof d&&null!==d){f=z(d,e,f);e=R(d);d=S(d);c.each(ma,function(){if(l>=this.s.r&&l<=this.e.r&&b.length>=this.s.c&&b.length<=this.e.c)for(var a=
  59. 0;a<=this.e.c-this.s.c;++a)b.push(null)});if(d||e)e=e||1,ma.push({s:{r:l,c:b.length},e:{r:l+(d||1)-1,c:b.length+e-1}});"function"!==typeof a.onCellData&&""!==f&&f==+f&&(f=+f);b.push(""!==f?f:null);if(e)for(d=0;d<e-1;++d)b.push(null)}});wa.push(b);l++});f=new ia;y=Fa(wa);y["!merges"]=ma;XLSX.utils.book_append_sheet(f,y,a.worksheetName);f=XLSX.write(f,{type:"binary",bookType:a.type,bookSST:!1});try{A=new Blob([ua(f)],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"}),
  60. saveAs(A,a.fileName+"."+a.type)}catch(b){H(a.fileName+"."+a.type,"data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8,",ua(f))}}else if("png"==a.type)html2canvas(c(v)[0]).then(function(b){b=b.toDataURL();for(var c=atob(b.substring(22)),e=new ArrayBuffer(c.length),f=new Uint8Array(e),g=0;g<c.length;g++)f[g]=c.charCodeAt(g);!0===a.consoleLog&&console.log(c);if("string"===a.outputMode)return c;if("base64"===a.outputMode)return L(b);if("window"===a.outputMode)window.open(b);
  61. else try{A=new Blob([e],{type:"image/png"}),saveAs(A,a.fileName+".png")}catch(h){H(a.fileName+".png","data:image/png,",A)}});else if("pdf"==a.type)if(!0===a.pdfmake.enabled){f=[];var xa=[];l=0;G=[];y=function(a,d,e){var b=0;c(a).each(function(){var a=[];B(this,d,l,e,function(b,c,d){if("undefined"!==typeof b&&null!==b){var e=R(b),g=S(b);b=z(b,c,d)||" ";1<e||1<g?a.push({colSpan:e||1,rowSpan:g||1,text:b}):a.push(b)}else a.push(" ")});a.length&&xa.push(a);b<a.length&&(b=a.length);l++});return b};p=c(this).find("thead").first().find(a.theadSelector);
  62. m=y(p,"th,td",p.length);for(N=f.length;N<m;N++)f.push("*");t=u(c(this));y(t,"th,td",p.length+t.length);f={content:[{table:{headerRows:p.length,widths:f,body:xa}}]};c.extend(!0,f,a.pdfmake.docDefinition);pdfMake.fonts={Roboto:{normal:"Roboto-Regular.ttf",bold:"Roboto-Medium.ttf",italics:"Roboto-Italic.ttf",bolditalics:"Roboto-MediumItalic.ttf"}};c.extend(!0,pdfMake.fonts,a.pdfmake.fonts);pdfMake.createPdf(f).getBuffer(function(b){try{var c=new Blob([b],{type:"application/pdf"});saveAs(c,a.fileName+
  63. ".pdf")}catch(k){H(a.fileName+".pdf","data:application/pdf;base64,",b)}})}else if(!1===a.jspdf.autotable){f={dim:{w:ca(c(v).first().get(0),"width","mm"),h:ca(c(v).first().get(0),"height","mm")},pagesplit:!1};var ya=new jsPDF(a.jspdf.orientation,a.jspdf.unit,a.jspdf.format);ya.addHTML(c(v).first(),a.jspdf.margins.left,a.jspdf.margins.top,f,function(){na(ya,!1)})}else{var e=a.jspdf.autotable.tableExport;if("string"===typeof a.jspdf.format&&"bestfit"===a.jspdf.format.toLowerCase()){var Y={a0:[2383.94,
  64. 3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89]},fa="",Z="",za=0;c(v).each(function(){if(P(c(this))){var a=ca(c(this).get(0),"width","pt");if(a>za){a>Y.a0[0]&&(fa="a0",Z="l");for(var d in Y)Y.hasOwnProperty(d)&&Y[d][1]>a&&(fa=d,Z="l",Y[d][0]>a&&(Z="p"));za=a}}});a.jspdf.format=""===fa?"a4":fa;a.jspdf.orientation=""===Z?"w":Z}if(null==e.doc&&(e.doc=new jsPDF(a.jspdf.orientation,a.jspdf.unit,a.jspdf.format),"function"===typeof a.jspdf.onDocCreated))a.jspdf.onDocCreated(e.doc);
  65. !0===e.outputImages&&(e.images={});"undefined"!=typeof e.images&&(c(v).filter(function(){return P(c(this))}).each(function(){var b=0;G=[];!1===a.exportHiddenCells&&(K=c(this).find("tr, th, td").filter(":hidden"),T=0<K.length);p=c(this).find("thead").find(a.theadSelector);t=u(c(this));c(t).each(function(){B(this,"td,th",p.length+b,p.length+t.length,function(a){if("undefined"!==typeof a&&null!==a){var b=c(a).children();"undefined"!=typeof b&&0<b.length&&pa(a,b,e)}});b++})}),p=[],t=[]);Ca(e,function(){c(v).filter(function(){return P(c(this))}).each(function(){var b;
  66. l=0;G=[];!1===a.exportHiddenCells&&(K=c(this).find("tr, th, td").filter(":hidden"),T=0<K.length);Q=O(this);e.columns=[];e.rows=[];e.rowoptions={};if("function"===typeof e.onTable&&!1===e.onTable(c(this),a))return!0;a.jspdf.autotable.tableExport=null;var d=c.extend(!0,{},a.jspdf.autotable);a.jspdf.autotable.tableExport=e;d.margin={};c.extend(!0,d.margin,a.jspdf.margins);d.tableExport=e;"function"!==typeof d.beforePageContent&&(d.beforePageContent=function(a){if(1==a.pageCount){var b=a.table.rows.concat(a.table.headerRow);
  67. c.each(b,function(){0<this.height&&(this.height+=(2-1.15)/2*this.styles.fontSize,a.table.height+=(2-1.15)/2*this.styles.fontSize)})}});"function"!==typeof d.createdHeaderCell&&(d.createdHeaderCell=function(a,b){a.styles=c.extend({},b.row.styles);if("undefined"!=typeof e.columns[b.column.dataKey]){var g=e.columns[b.column.dataKey];if("undefined"!=typeof g.rect){a.contentWidth=g.rect.width;if("undefined"==typeof e.heightRatio||0===e.heightRatio){var f=b.row.raw[b.column.dataKey].rowspan?b.row.raw[b.column.dataKey].rect.height/
  68. b.row.raw[b.column.dataKey].rowspan:b.row.raw[b.column.dataKey].rect.height;e.heightRatio=a.styles.rowHeight/f}f=b.row.raw[b.column.dataKey].rect.height*e.heightRatio;f>a.styles.rowHeight&&(a.styles.rowHeight=f)}"undefined"!=typeof g.style&&!0!==g.style.hidden&&(a.styles.halign=g.style.align,"inherit"===d.styles.fillColor&&(a.styles.fillColor=g.style.bcolor),"inherit"===d.styles.textColor&&(a.styles.textColor=g.style.color),"inherit"===d.styles.fontStyle&&(a.styles.fontStyle=g.style.fstyle))}});"function"!==
  69. typeof d.createdCell&&(d.createdCell=function(a,b){b=e.rowoptions[b.row.index+":"+b.column.dataKey];"undefined"!=typeof b&&"undefined"!=typeof b.style&&!0!==b.style.hidden&&(a.styles.halign=b.style.align,"inherit"===d.styles.fillColor&&(a.styles.fillColor=b.style.bcolor),"inherit"===d.styles.textColor&&(a.styles.textColor=b.style.color),"inherit"===d.styles.fontStyle&&(a.styles.fontStyle=b.style.fstyle))});"function"!==typeof d.drawHeaderCell&&(d.drawHeaderCell=function(a,b){var c=e.columns[b.column.dataKey];
  70. return(!0!==c.style.hasOwnProperty("hidden")||!0!==c.style.hidden)&&0<=c.rowIndex?oa(a,b,c):!1});"function"!==typeof d.drawCell&&(d.drawCell=function(a,b){var c=e.rowoptions[b.row.index+":"+b.column.dataKey];if(oa(a,b,c))if(e.doc.rect(a.x,a.y,a.width,a.height,a.styles.fillStyle),"undefined"!=typeof c&&"undefined"!=typeof c.kids&&0<c.kids.length){b=a.height/c.rect.height;if(b>e.dh||"undefined"==typeof e.dh)e.dh=b;e.dw=a.width/c.rect.width;b=a.textPos.y;ra(a,c.kids,e);a.textPos.y=b;sa(a,c.kids,e)}else sa(a,
  71. {},e);return!1});e.headerrows=[];p=c(this).find("thead").find(a.theadSelector);p.each(function(){b=0;e.headerrows[l]=[];B(this,"th,td",l,p.length,function(a,c,d){var f=ta(a);f.title=z(a,c,d);f.key=b++;f.rowIndex=l;e.headerrows[l].push(f)});l++});if(0<l)for(var f=l-1;0<=f;)c.each(e.headerrows[f],function(){var a=this;0<f&&null===this.rect&&(a=e.headerrows[f-1][this.key]);null!==a&&0<=a.rowIndex&&(!0!==a.style.hasOwnProperty("hidden")||!0!==a.style.hidden)&&e.columns.push(a)}),f=0<e.columns.length?
  72. -1:f-1;var m=0;t=[];t=u(c(this));c(t).each(function(){var a=[];b=0;B(this,"td,th",l,p.length+t.length,function(d,f,g){if("undefined"===typeof e.columns[b]){var h={title:"",key:b,style:{hidden:!0}};e.columns.push(h)}"undefined"!==typeof d&&null!==d?(h=ta(d),h.kids=c(d).children()):(h=c.extend(!0,{},e.rowoptions[m+":"+(b-1)]),h.colspan=-1);e.rowoptions[m+":"+b++]=h;a.push(z(d,f,g))});a.length&&(e.rows.push(a),m++);l++});if("function"===typeof e.onBeforeAutotable)e.onBeforeAutotable(c(this),e.columns,
  73. e.rows,d);e.doc.autoTable(e.columns,e.rows,d);if("function"===typeof e.onAfterAutotable)e.onAfterAutotable(c(this),d);a.jspdf.autotable.startY=e.doc.autoTableEndPosY()+d.margin.top});na(e.doc,"undefined"!=typeof e.images&&!1===jQuery.isEmptyObject(e.images));"undefined"!=typeof e.headerrows&&(e.headerrows.length=0);"undefined"!=typeof e.columns&&(e.columns.length=0);"undefined"!=typeof e.rows&&(e.rows.length=0);delete e.doc;e.doc=null})}return this}})(jQuery);