tableExport.min.js 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. tableExport.jquery.plugin
  3. Version 1.9.9
  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,h,u){c instanceof String&&(c=String(c));for(var C=c.length,D=0;D<C;D++){var O=c[D];if(h.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,h,u){c!=Array.prototype&&c!=Object.prototype&&(c[h]=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,h,u,C){if(h){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];h=h(C);h!=C&&null!=h&&$jscomp.defineProperty(u,c,{configurable:!0,writable:!0,value:h})}};
  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(h){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===c(this).find("table").length&&
  12. 1===c(this).parents("table").length})}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,p=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"));a&&"none"!=g&&"always"!=
  13. g&&(g=b.closest("table").data("tableexport-display"));return"none"!==g&&(1==p||"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}));return 0==T||0==
  14. d.length}function Ba(b,d,f){var p=!1;P(b)?0<a.ignoreColumn.length&&(-1!=c.inArray(f,a.ignoreColumn)||-1!=c.inArray(f-d,a.ignoreColumn)||Q.length>f&&"undefined"!=typeof Q[f]&&-1!=c.inArray(Q[f],a.ignoreColumn))&&(p=!0):p=!0;return p}function B(b,d,f,p,g){if("function"===typeof g){var l=!1;"function"===typeof a.onIgnoreRow&&(l=a.onIgnoreRow(c(b),f));if(!1===l&&-1==c.inArray(f,a.ignoreRow)&&-1==c.inArray(f-p,a.ignoreRow)&&P(c(b))){var x=c(b).find(d),r=0;x.each(function(b){var d=c(this),a,l=R(this),p=
  15. S(this);c.each(G,function(){if(f>=this.s.r&&f<=this.e.r&&r>=this.s.c&&r<=this.e.c)for(a=0;a<=this.e.c-this.s.c;++a)g(null,f,r++)});if(!1===Ba(d,x.length,b)){if(p||l)l=l||1,G.push({s:{r:f,c:r},e:{r:f+(p||1)-1,c:r+l-1}});g(this,f,r++)}if(l)for(a=0;a<l-1;++a)g(null,f,r++)});c.each(G,function(){if(f>=this.s.r&&f<=this.e.r&&r>=this.s.c&&r<=this.e.c)for(aa=0;aa<=this.e.c-this.s.c;++aa)g(null,f,r++)})}}}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 f=b.output("blob");saveAs(f,a.fileName+".pdf")}catch(p){H(a.fileName+".pdf","data:application/pdf"+(d?"":";base64")+",",d?b.output("blob"):b.output())}}function oa(b,d,a){var f=0;"undefined"!==typeof a&&(f=a.colspan);if(0<=f){for(var g=b.width,c=b.textPos.x,x=d.table.columns.indexOf(d.column),r=1;r<f;r++)g+=d.table.columns[x+
  17. r].width;1<f&&("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,d,a){"undefined"!=typeof a.images&&d.each(function(){var d=c(this).children();
  18. if(c(this).is("img")){var g=qa(this.src);a.images[g]={url:this.src,src:this.src}}"undefined"!=typeof d&&0<d.length&&pa(b,d,a)})}function Ca(b,d){function a(b){if(b.url){var a=new Image;g=++l;a.crossOrigin="Anonymous";a.onerror=a.onload=function(){if(a.complete&&(0===a.src.indexOf("data:image/")&&(a.width=b.width||a.width||0,a.height=b.height||a.height||0),a.width+a.height)){var c=document.createElement("canvas"),f=c.getContext("2d");c.width=a.width;c.height=a.height;f.drawImage(a,0,0);b.src=c.toDataURL("image/jpeg")}--l||
  19. d(g)};a.src=b.url}}var c,g=0,l=0;if("undefined"!=typeof b.images)for(c in b.images)b.images.hasOwnProperty(c)&&a(b.images[c]);(b=l)||(d(g),b=void 0);return b}function ra(b,d,f){d.each(function(){var d=c(this).children(),g=0;if(c(this).is("div")){var l=ba(M(this,"background-color"),[255,255,255]),x=ba(M(this,"border-top-color"),[0,0,0]),r=ca(this,"border-top-width",a.jspdf.unit),e=this.getBoundingClientRect(),h=this.offsetLeft*f.dw;g=this.offsetTop*f.dh;var k=e.width*f.dw;e=e.height*f.dh;f.doc.setDrawColor.apply(void 0,
  20. x);f.doc.setFillColor.apply(void 0,l);f.doc.setLineWidth(r);f.doc.rect(b.x+h,b.y+g,k,e,r?"FD":"F")}else if(c(this).is("img")&&"undefined"!=typeof f.images&&(l=qa(this.src),l=f.images[l],"undefined"!=typeof l)){x=b.width/b.height;r=this.width/this.height;h=b.width;k=b.height;e=19.049976/25.4;r<=x?(k=Math.min(b.height,this.height),h=this.width*k/this.height):r>x&&(h=Math.min(b.width,this.width),k=this.height*h/this.width);h*=e;k*=e;k<b.height&&(g=(b.height-k)/2);try{f.doc.addImage(l.src,b.textPos.x,
  21. b.y+g,h,k)}catch(Ga){}b.textPos.x+=h}"undefined"!=typeof d&&0<d.length&&ra(b,d,f)})}function sa(b,a,f){if("function"===typeof f.onAutotableText)f.onAutotableText(f.doc,b,a);else{var d=b.textPos.x,g=b.textPos.y,l={halign:b.styles.halign,valign:b.styles.valign};if(a.length){for(a=a[0];a.previousSibling;)a=a.previousSibling;for(var x=!1,r=!1;a;){var e=a.innerText||a.textContent||"";e=(e.length&&" "==e[0]?" ":"")+c.trim(e)+(1<e.length&&" "==e[e.length-1]?" ":"");c(a).is("br")&&(d=b.textPos.x,g+=f.doc.internal.getFontSize());
  22. c(a).is("b")?x=!0:c(a).is("i")&&(r=!0);(x||r)&&f.doc.setFontType(x&&r?"bolditalic":x?"bold":"italic");var h=f.doc.getStringUnitWidth(e)*f.doc.internal.getFontSize();if(h){if("linebreak"===b.styles.overflow&&d>b.textPos.x&&d+h>b.textPos.x+b.width){if(0<=".,!%*;:=-".indexOf(e.charAt(0))){var k=e.charAt(0);h=f.doc.getStringUnitWidth(k)*f.doc.internal.getFontSize();d+h<=b.textPos.x+b.width&&(f.doc.autoTableText(k,d,g,l),e=e.substring(1,e.length));h=f.doc.getStringUnitWidth(e)*f.doc.internal.getFontSize()}d=
  23. b.textPos.x;g+=f.doc.internal.getFontSize()}for(;e.length&&d+h>b.textPos.x+b.width;)e=e.substring(0,e.length-1),h=f.doc.getStringUnitWidth(e)*f.doc.internal.getFontSize();f.doc.autoTableText(e,d,g,l);d+=h}if(x||r)c(a).is("b")?x=!1:c(a).is("i")&&(r=!1),f.doc.setFontType(x||r?x?"bold":"italic":"normal");a=a.nextSibling}b.textPos.x=d;b.textPos.y=g}else f.doc.autoTableText(b.text,b.textPos.x,b.textPos.y,l)}}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,f){var p="";if(null!==b){var g=c(b);if(g[0].hasAttribute("data-tableexport-value"))var l=(l=g.data("tableexport-value"))?l+"":"";else if(l=g.html(),"function"===typeof a.onCellHtmlData)l=a.onCellHtmlData(g,d,f,l);else if(""!=l){var e=
  25. c.parseHTML(l),h=0,k=0;l="";c.each(e,function(){if(c(this).is("input"))l+=g.find("input").eq(h++).val();else if(c(this).is("select"))l+=g.find("select option:selected").eq(k++).text();else if("undefined"===typeof c(this).html())l+=c(this).text();else if(void 0===jQuery().bootstrapTable||!0!==c(this).hasClass("filterControl")&&0===c(b).parents(".detail-view").length)l+=c(this).html()})}if(!0===a.htmlContent)p=c.trim(l);else if(l&&""!=l)if(""!=c(b).data("tableexport-cellformat")){var n=l.replace(/\n/g,
  26. "\u2028").replace(/<br\s*[\/]?>/gi,"\u2060"),m=c("<div/>").html(n).contents();e=!1;n="";c.each(m.text().split("\u2028"),function(b,a){0<b&&(n+=" ");n+=c.trim(a)});c.each(n.split("\u2060"),function(b,a){0<b&&(p+="\n");p+=c.trim(a).replace(/\u00AD/g,"")});if("json"==a.type||"excel"===a.type&&"xmlss"===a.excelFileFormat||!1===a.numbers.output)e=ha(p),!1!==e&&(p=Number(e));else if(a.numbers.html.decimalMark!=a.numbers.output.decimalMark||a.numbers.html.thousandsSeparator!=a.numbers.output.thousandsSeparator)if(e=
  27. ha(p),!1!==e){m=(""+e.substr(0>e?1:0)).split(".");1==m.length&&(m[1]="");var q=3<m[0].length?m[0].length%3:0;p=(0>e?"-":"")+(a.numbers.output.thousandsSeparator?(q?m[0].substr(0,q)+a.numbers.output.thousandsSeparator:"")+m[0].substr(q).replace(/(\d{3})(?=\d)/g,"$1"+a.numbers.output.thousandsSeparator):m[0])+(m[1].length?a.numbers.output.decimalMark+m[1]:"")}}else p=l;!0===a.escape&&(p=escape(p));"function"===typeof a.onCellData&&(p=a.onCellData(g,d,f,p))}return p}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"),p=M(b,"font-style"),g="";"start"==a&&(a="rtl"==M(b,"direction")?"right":"left");700<=c&&(g="bold");"italic"==p&&(g+=p);""===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(f){}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 l={v:a[e][g]};if(null!==l.v){var h=XLSX.utils.encode_cell({c:g,r:e});if("number"===typeof l.v)l.t="n";else if("boolean"===typeof l.v)l.t="b";else if(l.v instanceof Date){l.t="n";l.z=XLSX.SSF._table[14];var r=l;var k=(Date.parse(l.v)-new Date(Date.UTC(1899,11,30)))/864E5;r.v=k}else l.t="s";b[h]=l}}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,c,f){var b=window.navigator.userAgent;if(!1!==a&&window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(new Blob([f]),a);else if(!1!==a&&(0<b.indexOf("MSIE ")||b.match(/Trident.*rv\:11\./))){if(c=document.createElement("iframe")){document.body.appendChild(c);c.setAttribute("style","display:none");
  33. c.contentDocument.open("txt/plain","replace");c.contentDocument.write(f);c.contentDocument.close();c.contentDocument.focus();switch(a.substr(a.lastIndexOf(".")+1)){case "doc":case "json":case "png":case "pdf":case "xls":case "xlsx":a+=".txt"}c.contentDocument.execCommand("SaveAs",!0,a);document.body.removeChild(c)}}else{var g=document.createElement("a");if(g){var d=null;g.style.display="none";!1!==a?g.download=a:g.target="_blank";"object"==typeof f?(window.URL=window.URL||window.webkitURL,d=window.URL.createObjectURL(f),
  34. g.href=d):0<=c.toLowerCase().indexOf("base64,")?g.href=c+L(f):g.href=c+encodeURIComponent(f);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(){d&&window.URL.revokeObjectURL(d);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 l=a.charCodeAt(b);128>l?g+=String.fromCharCode(l):(127<l&&2048>l?g+=String.fromCharCode(l>>6|192):(g+=String.fromCharCode(l>>12|224),g+=String.fromCharCode(l>>6&63|128)),g+=String.fromCharCode(l&63|128))}a=g}for(;e<a.length;){var h=a.charCodeAt(e++);g=a.charCodeAt(e++);b=a.charCodeAt(e++);l=h>>2;h=(h&3)<<4|g>>4;var r=(g&15)<<2|b>>6;var k=b&63;isNaN(g)?r=k=64:isNaN(b)&&(k=64);c=c+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(l)+
  36. "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(h)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(r)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(k)}return c}var a={consoleLog:!1,csvEnclosure:'"',csvSeparator:",",csvUseBOM:!0,displayTableName:!1,escape:!1,excelFileFormat:"xlshtml",excelRTL:!1,excelstyles:[],exportHiddenCells:!1,fileName:"tableExport",htmlContent:!1,ignoreColumn:[],ignoreRow:[],jsonScope:"all",jspdf:{orientation:"p",
  37. 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,outputImages:!0}}},numbers:{html:{decimalMark:".",
  38. 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,q=[],t=[],k=0,m="",Q=[],G=[],K=[],T=!1;c.extend(!0,a,h);Q=O(v);if("csv"==a.type||"tsv"==a.type||"txt"==a.type){var I=
  39. "",W=0;G=[];k=0;var ja=function(b,d,f){b.each(function(){m="";B(this,d,k,f+b.length,function(b,c,d){var g=m,f="";if(null!==b)if(b=z(b,c,d),c=null===b||""===b?"":b.toString(),"tsv"==a.type)b instanceof Date&&b.toLocaleString(),f=da(c,"\t"," ");else if(b instanceof Date)f=a.csvEnclosure+b.toLocaleString()+a.csvEnclosure;else if(f=da(c,a.csvEnclosure,a.csvEnclosure+a.csvEnclosure),0<=f.indexOf(a.csvSeparator)||/[\r\n ]/g.test(f))f=a.csvEnclosure+f+a.csvEnclosure;m=g+(f+("tsv"==a.type?"\t":a.csvSeparator))});
  40. m=c.trim(m).substring(0,m.length-1);0<m.length&&(0<I.length&&(I+="\n"),I+=m);k++});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);if("string"===a.outputMode)return I;if("base64"===a.outputMode)return L(I);if("window"===a.outputMode){H(!1,"data:text/"+("csv"==
  41. 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){k=0;G=[];var w="INSERT INTO `"+a.tableName+"` (";q=c(v).find("thead").first().find(a.theadSelector);q.each(function(){B(this,"th,td",k,q.length,
  42. function(a,c,f){w+="'"+z(a,c,f)+"',"});k++;w=c.trim(w).substring(0,w.length-1)});w+=") VALUES ";t=u(c(v));c(t).each(function(){m="";B(this,"td,th",k,q.length+t.length,function(a,c,f){m+="'"+z(a,c,f)+"',"});3<m.length&&(w+="("+m,w=c.trim(w).substring(0,w.length-1),w+="),");k++});w=c.trim(w).substring(0,w.length-1);w+=";";!0===a.consoleLog&&console.log(w);if("string"===a.outputMode)return w;if("base64"===a.outputMode)return L(w);try{A=new Blob([w],{type:"text/plain;charset=utf-8"}),saveAs(A,a.fileName+
  43. ".sql")}catch(b){H(a.fileName+".sql","data:application/sql;charset=utf-8,",w)}}else if("json"==a.type){var U=[];G=[];q=c(v).find("thead").first().find(a.theadSelector);q.each(function(){var a=[];B(this,"th,td",k,q.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",k,q.length+t.length,function(b,c,g){U.length?a[U[U.length-1][d]]=z(b,c,g):a[d]=z(b,c,g);d++});!1===c.isEmptyObject(a)&&ka.push(a);k++});h="";h="head"==a.jsonScope?JSON.stringify(U):
  44. "data"==a.jsonScope?JSON.stringify(ka):JSON.stringify({header:U,data:ka});!0===a.consoleLog&&console.log(h);if("string"===a.outputMode)return h;if("base64"===a.outputMode)return L(h);try{A=new Blob([h],{type:"application/json;charset=utf-8"}),saveAs(A,a.fileName+".json")}catch(b){H(a.fileName+".json","data:application/json;charset=utf-8;base64,",h)}}else if("xml"===a.type){k=0;G=[];var J='<?xml version="1.0" encoding="utf-8"?>';J+="<tabledata><fields>";q=c(v).find("thead").first().find(a.theadSelector);
  45. q.each(function(){B(this,"th,td",k,q.length,function(a,c,f){J+="<field>"+z(a,c,f)+"</field>"});k++});J+="</fields><data>";var va=1;t=u(c(v));c(t).each(function(){var a=1;m="";B(this,"td,th",k,q.length+t.length,function(b,c,e){m+="<column-"+a+">"+z(b,c,e)+"</column-"+a+">";a++});0<m.length&&"<column-1></column-1>"!=m&&(J+='<row id="'+va+'">'+m+"</row>",va++);k++});J+="</data></tabledata>";!0===a.consoleLog&&console.log(J);if("string"===a.outputMode)return J;if("base64"===a.outputMode)return L(J);try{A=
  46. 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,f=0;m="";B(this,"td,th",k,d+a.length,function(a,d,l){if(null!==a){var e="";d=z(a,d,l);l="String";if(!1!==jQuery.isNumeric(d))l="Number";else{var h=Da(d);!1!==
  47. h&&(d=h,l="Number",e+=' ss:StyleID="pct1"')}"Number"!==l&&(d=d.replace(/\n/g,"<br>"));h=R(a);a=S(a);c.each(g,function(){if(k>=this.s.r&&k<=this.e.r&&f>=this.s.c&&f<=this.e.c)for(var a=0;a<=this.e.c-this.s.c;++a)f++,b++});if(a||h)a=a||1,h=h||1,g.push({s:{r:k,c:f},e:{r:k+a-1,c:f+h-1}});1<h&&(e+=' ss:MergeAcross="'+(h-1)+'"',f+=h-1);1<a&&(e+=' ss:MergeDown="'+(a-1)+'" ss:StyleID="rsp1"');0<b&&(e+=' ss:Index="'+(f+1)+'"',b=0);m+="<Cell"+e+'><Data ss:Type="'+l+'">'+c("<div />").text(d).html()+"</Data></Cell>\r";
  48. f++}});0<m.length&&(E+='<Row ss:AutoFitHeight="0">\r'+m+"</Row>\r");k++});return a.length}var d=c(this),f="";"string"===typeof a.worksheetName&&a.worksheetName.length?f=a.worksheetName+" "+(F.length+1):"undefined"!==typeof a.worksheetName[F.length]&&(f=a.worksheetName[F.length]);f.length||(f=d.find("caption").text()||"");f.length||(f="Table "+(F.length+1));f=c.trim(f.replace(/[\\\/[\]*:?'"]/g,"").substring(0,31));F.push(c("<div />").text(f).html());!1===a.exportHiddenCells&&(K=d.find("tr, th, td").filter(":hidden"),
  49. T=0<K.length);k=0;Q=O(this);E="<Table>\r";f=0;f+=b(d.find("thead").first().find(a.theadSelector),"th,td",f);b(u(d),"td,th",f);E+="</Table>\r";la.push(E);!0===a.consoleLog&&console.log(E)});h={};for(var y={},n,N,V=0,aa=F.length;V<aa;V++)n=F[V],N=h[n],N=h[n]=null==N?1:N+1,2==N&&(F[y[n]]=F[y[n]].substring(0,29)+"-1"),1<h[n]?F[V]=F[V].substring(0,29)+"-"+h[n]:y[n]=V;h='<?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++)h+='<Worksheet ss:Name="'+F[y]+'" ss:RightToLeft="'+(a.excelRTL?"1":"0")+'">\r'+la[y],h=a.excelRTL?h+'<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">\r<DisplayRightToLeft/>\r</WorksheetOptions>\r':h+'<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"/>\r',h+="</Worksheet>\r";h+="</Workbook>\r";!0===a.consoleLog&&console.log(h);if("string"===a.outputMode)return h;if("base64"===a.outputMode)return L(h);try{A=new Blob([h],{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,",h)}}else if("excel"==a.type||"xls"==a.type||"word"==a.type||"doc"==a.type){h="excel"==a.type||"xls"==a.type?"excel":"word";y="excel"==h?"xls":"doc";n='xmlns:x="urn:schemas-microsoft-com:office:'+h+'"';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);k=0;G=[];Q=O(this);E+="<table><thead>";q=b.find("thead").first().find(a.theadSelector);q.each(function(){m="";B(this,"th,td",k,q.length,function(b,f,e){if(null!==b){var g="";m+="<th";for(var d in a.excelstyles)if(a.excelstyles.hasOwnProperty(d)){var h=c(b).css(a.excelstyles[d]);""!==h&&"0px none rgb(0, 0, 0)"!=h&&"rgba(0, 0, 0, 0)"!=h&&(g+=""===g?'style="':";",g+=a.excelstyles[d]+":"+h)}""!==g&&(m+=" "+g+'"');
  54. g=R(b);0<g&&(m+=' colspan="'+g+'"');g=S(b);0<g&&(m+=' rowspan="'+g+'"');m+=">"+z(b,f,e)+"</th>"}});0<m.length&&(E+="<tr>"+m+"</tr>");k++});E+="</thead><tbody>";t=u(b);c(t).each(function(){var b=c(this);m="";B(this,"td,th",k,q.length+t.length,function(d,e,g){if(null!==d){var f=z(d,e,g),h="",k=c(d).data("tableexport-msonumberformat");"undefined"==typeof k&&"function"===typeof a.onMsoNumberFormat&&(k=a.onMsoNumberFormat(d,e,g));"undefined"!=typeof k&&""!==k&&(h="style=\"mso-number-format:'"+k+"'");for(var p in a.excelstyles)a.excelstyles.hasOwnProperty(p)&&
  55. (k=c(d).css(a.excelstyles[p]),""===k&&(k=b.css(a.excelstyles[p])),""!==k&&"0px none rgb(0, 0, 0)"!=k&&"rgba(0, 0, 0, 0)"!=k&&(h+=""===h?'style="':";",h+=a.excelstyles[p]+":"+k));m+="<td";""!==h&&(m+=" "+h+'"');e=R(d);0<e&&(m+=' colspan="'+e+'"');d=S(d);0<d&&(m+=' rowspan="'+d+'"');"string"===typeof f&&""!=f&&(f=f.replace(/\n/g,"<br>"));m+=">"+f+"</td>"}});0<m.length&&(E+="<tr>"+m+"</tr>");k++});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)});n='<html xmlns:o="urn:schemas-microsoft-com:office:office" '+n+' xmlns="http://www.w3.org/TR/REC-html40">'+('<meta http-equiv="content-type" content="application/vnd.ms-'+h+'; charset=UTF-8">')+"<head>";"excel"===h&&(n+="\x3c!--[if gte mso 9]>",n+="<xml>",n+="<x:ExcelWorkbook>",n+="<x:ExcelWorksheets>",n+="<x:ExcelWorksheet>",n+="<x:Name>",n+=X,n+="</x:Name>",n+="<x:WorksheetOptions>",n+="<x:DisplayGridlines/>",a.excelRTL&&(n+="<x:DisplayRightToLeft/>"),
  57. n+="</x:WorksheetOptions>",n+="</x:ExcelWorksheet>",n+="</x:ExcelWorksheets>",n+="</x:ExcelWorkbook>",n+="</xml>",n+="<![endif]--\x3e");n+="<style>br {mso-data-placement:same-cell;}</style>";n+="</head>";n+="<body>";n+=E;n+="</body>";n+="</html>";!0===a.consoleLog&&console.log(n);if("string"===a.outputMode)return n;if("base64"===a.outputMode)return L(n);try{A=new Blob([n],{type:"application/vnd.ms-"+a.type}),saveAs(A,a.fileName+"."+y)}catch(b){H(a.fileName+"."+y,"data:application/vnd.ms-"+h+";base64,",
  58. n)}}else if("xlsx"==a.type){var wa=[],ma=[];k=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",k,t.length,function(d,e,h){if("undefined"!==typeof d&&null!==d){h=z(d,e,h);e=R(d);d=S(d);c.each(ma,function(){if(k>=this.s.r&&k<=this.e.r&&b.length>=this.s.c&&b.length<=this.e.c)for(var a=0;a<=this.e.c-this.s.c;++a)b.push(null)});if(d||e)e=e||1,ma.push({s:{r:k,c:b.length},e:{r:k+(d||1)-1,c:b.length+e-1}});"function"!==typeof a.onCellData&&
  59. ""!==h&&h==+h&&(h=+h);b.push(""!==h?h:null);if(e)for(d=0;d<e-1;++d)b.push(null)}});wa.push(b);k++});h=new ia;y=Fa(wa);y["!merges"]=ma;h.SheetNames.push(a.worksheetName);h.Sheets[a.worksheetName]=y;h=XLSX.write(h,{bookType:a.type,bookSST:!1,type:"binary"});try{A=new Blob([ua(h)],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"}),saveAs(A,a.fileName+"."+a.type)}catch(b){H(a.fileName+"."+a.type,"data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8,",
  60. ua(h))}}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),h=new Uint8Array(e),g=0;g<c.length;g++)h[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);else try{A=new Blob([e],{type:"image/png"}),saveAs(A,a.fileName+".png")}catch(l){H(a.fileName+".png","data:image/png,",A)}});else if("pdf"==a.type)if(!0===
  61. a.pdfmake.enabled){h=[];var xa=[];k=0;G=[];y=function(a,d,e){var b=0;c(a).each(function(){var a=[];B(this,d,k,e,function(b,c,d){if("undefined"!==typeof b&&null!==b){var g=R(b),e=S(b);b=z(b,c,d)||" ";1<g||1<e?a.push({colSpan:g||1,rowSpan:e||1,text:b}):a.push(b)}else a.push(" ")});a.length&&xa.push(a);b<a.length&&(b=a.length);k++});return b};q=c(this).find("thead").first().find(a.theadSelector);n=y(q,"th,td",q.length);for(N=h.length;N<n;N++)h.push("*");t=u(c(this));y(t,"th,td",q.length+t.length);h=
  62. {content:[{table:{headerRows:q.length,widths:h,body:xa}}]};c.extend(!0,h,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(h).getBuffer(function(b){try{var c=new Blob([b],{type:"application/pdf"});saveAs(c,a.fileName+".pdf")}catch(f){H(a.fileName+".pdf","data:application/pdf;base64,",b)}})}else if(!1===a.jspdf.autotable){h=
  63. {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,h,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,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;
  64. 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);!0===e.outputImages&&(e.images={});"undefined"!=typeof e.images&&(c(v).filter(function(){return P(c(this))}).each(function(){var b=
  65. 0;G=[];!1===a.exportHiddenCells&&(K=c(this).find("tr, th, td").filter(":hidden"),T=0<K.length);q=c(this).find("thead").find(a.theadSelector);t=u(c(this));c(t).each(function(){B(this,"td,th",q.length+b,q.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++})}),q=[],t=[]);Ca(e,function(){c(v).filter(function(){return P(c(this))}).each(function(){var b;k=0;G=[];!1===a.exportHiddenCells&&(K=c(this).find("tr, th, td").filter(":hidden"),
  66. 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);c.each(b,function(){0<this.height&&(this.height+=(2-1.15)/
  67. 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/b.row.raw[b.column.dataKey].rowspan:
  68. 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"!==typeof d.createdCell&&(d.createdCell=
  69. 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];return(!0!==c.style.hasOwnProperty("hidden")||
  70. !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,{},e);return!1});e.headerrows=[];q=c(this).find("thead").find(a.theadSelector);
  71. q.each(function(){b=0;e.headerrows[k]=[];B(this,"th,td",k,q.length,function(a,c,d){var g=ta(a);g.title=z(a,c,d);g.key=b++;g.rowIndex=k;e.headerrows[k].push(g)});k++});if(0<k)for(var f=k-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?-1:f-1;var h=0;t=[];t=u(c(this));c(t).each(function(){var a=[];b=0;B(this,"td,th",
  72. k,q.length+t.length,function(d,f,g){if("undefined"===typeof e.columns[b]){var k={title:"",key:b,style:{hidden:!0}};e.columns.push(k)}"undefined"!==typeof d&&null!==d?(k=ta(d),k.kids=c(d).children()):(k=c.extend(!0,{},e.rowoptions[h+":"+(b-1)]),k.colspan=-1);e.rowoptions[h+":"+b++]=k;a.push(z(d,f,g))});a.length&&(e.rows.push(a),h++);k++});if("function"===typeof e.onBeforeAutotable)e.onBeforeAutotable(c(this),e.columns,e.rows,d);e.doc.autoTable(e.columns,e.rows,d);if("function"===typeof e.onAfterAutotable)e.onAfterAutotable(c(this),
  73. 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);