forked from hhurz/tableExport.jquery.plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtableExport.min.js
38 lines (38 loc) · 18.9 KB
/
tableExport.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(function(e){e.fn.extend({tableExport:function(t){function aa(b,a,f){var g=null;e.each(b,function(){if(this.rowIndex==f&&this.key==a)return g=this,!1});return g}function P(b){var a=[];e(b).find("thead").first().find("th").each(function(b,g){void 0!==e(g).attr("data-field")&&(a[b]=e(g).attr("data-field"))});return a}function B(b,l,f,g,I){if(-1==e.inArray(f,a.ignoreRow)&&-1==e.inArray(f-g,a.ignoreRow)){var m=e(b).filter(function(){return"none"!=e(this).data("tableexport-display")&&(e(this).is(":visible")||
"always"==e(this).data("tableexport-display")||"always"==e(this).closest("table").data("tableexport-display"))}).find(l),p=0;m.each(function(b){if("always"==e(this).data("tableexport-display")||"none"!=e(this).css("display")&&"hidden"!=e(this).css("visibility")&&"none"!=e(this).data("tableexport-display")){var l=b,g=!1;0<a.ignoreColumn.length&&("string"==typeof a.ignoreColumn[0]?H.length>l&&"undefined"!=typeof H[l]&&-1!=e.inArray(H[l],a.ignoreColumn)&&(g=!0):"number"!=typeof a.ignoreColumn[0]||-1==
e.inArray(l,a.ignoreColumn)&&-1==e.inArray(l-m.length,a.ignoreColumn)||(g=!0));if(0==g&&"function"===typeof I){var g=0,d,h=0;if("undefined"!=typeof y[f]&&0<y[f].length)for(l=0;l<=b;l++)"undefined"!=typeof y[f][l]&&(I(null,f,l),delete y[f][l],b++);e(this).is("[colspan]")&&(g=parseInt(e(this).attr("colspan")),p+=0<g?g-1:0);e(this).is("[rowspan]")&&(h=parseInt(e(this).attr("rowspan")));I(this,f,b);for(l=0;l<g-1;l++)I(null,f,b+l);if(h)for(d=1;d<h;d++)for("undefined"==typeof y[f+d]&&(y[f+d]=[]),y[f+d][b+
p]="",l=1;l<g;l++)y[f+d][b+p-l]=""}}});if("undefined"!=typeof y[f]&&0<y[f].length)for(c=0;c<=y[f].length;c++)"undefined"!=typeof y[f][c]&&(I(null,f,c),delete y[f][c])}}function R(b){!0===a.consoleLog&&console.log(b.output());if("string"===a.outputMode)return b.output();if("base64"===a.outputMode)return F(b.output());try{var l=b.output("blob");saveAs(l,a.fileName+".pdf")}catch(f){G(a.fileName+".pdf","data:application/pdf;base64,",b.output())}}function S(b,a,f){var g=0;"undefined"!=typeof f&&(g=f.colspan);
if(0<=g){for(var e=b.width,m=b.textPos.x,p=a.table.columns.indexOf(a.column),d=1;d<g;d++)e+=a.table.columns[p+d].width;1<g&&("right"===b.styles.halign?m=b.textPos.x+e-b.width:"center"===b.styles.halign&&(m=b.textPos.x+(e-b.width)/2));b.width=e;b.textPos.x=m;"undefined"!=typeof f&&1<f.rowspan&&(b.height*=f.rowspan);if("middle"===b.styles.valign||"bottom"===b.styles.valign)f=("string"===typeof b.text?b.text.split(/\r\n|\r|\n/g):b.text).length||1,2<f&&(b.textPos.y-=(2-1.15)/2*a.row.styles.fontSize*(f-
2)/3);return!0}return!1}function T(b,l,f){l.each(function(){var l=e(this).children();if(e(this).is("div")){var d=L(E(this,"background-color"),[255,255,255]),m=L(E(this,"border-top-color"),[0,0,0]),p=M(this,"border-top-width",a.jspdf.unit),h=this.getBoundingClientRect(),k=this.offsetLeft*f.dw,n=this.offsetTop*f.dh,q=h.width*f.dw,h=h.height*f.dh;f.doc.setDrawColor.apply(void 0,m);f.doc.setFillColor.apply(void 0,d);f.doc.setLineWidth(p);f.doc.rect(b.x+k,b.y+n,q,h,p?"FD":"F")}"undefined"!=typeof l&&0<
l.length&&T(b,l,f)})}function Q(b,a,f){return b.replace(new RegExp(a.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"),"g"),f)}function ba(b){b=Q(b||"0",a.numbers.html.decimalMark,".");b=Q(b,a.numbers.html.thousandsSeparator,"");return"number"===typeof b||!1!==jQuery.isNumeric(b)?b:!1}function z(b,l,f){var g="";if(null!=b){b=e(b);var d;d=b[0].hasAttribute("data-tableexport-value")?b.data("tableexport-value"):b.html();"function"===typeof a.onCellHtmlData&&(d=a.onCellHtmlData(b,l,f,d));if(!0===a.htmlContent)g=
e.trim(d);else{var m=d.replace(/\n/g,"\u2028").replace(/<br\s*[\/]?>/gi,"\u2060");d=e("<div/>").html(m).contents();m="";e.each(d.text().split("\u2028"),function(b,a){0<b&&(m+=" ");m+=e.trim(a)});e.each(m.split("\u2060"),function(b,a){0<b&&(g+="\n");g+=e.trim(a).replace(/\u00AD/g,"")});if(a.numbers.html.decimalMark!=a.numbers.output.decimalMark||a.numbers.html.thousandsSeparator!=a.numbers.output.thousandsSeparator)if(d=ba(g),!1!==d){var p=(""+d).split(".");1==p.length&&(p[1]="");var h=3<p[0].length?
p[0].length%3:0,g=(0>d?"-":"")+(a.numbers.output.thousandsSeparator?(h?p[0].substr(0,h)+a.numbers.output.thousandsSeparator:"")+p[0].substr(h).replace(/(\d{3})(?=\d)/g,"$1"+a.numbers.output.thousandsSeparator):p[0])+(p[1].length?a.numbers.output.decimalMark+p[1]:"")}}!0===a.escape&&(g=escape(g));"function"===typeof a.onCellData&&(g=a.onCellData(b,l,f,g))}return g}function ca(b,a,f){return a+"-"+f.toLowerCase()}function L(b,a){var f=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(b),g=a;f&&(g=
[parseInt(f[1]),parseInt(f[2]),parseInt(f[3])]);return g}function U(b){var a=E(b,"text-align"),f=E(b,"font-weight"),g=E(b,"font-style"),d="";"start"==a&&(a="rtl"==E(b,"direction")?"right":"left");700<=f&&(d="bold");"italic"==g&&(d+=g);""==d&&(d="normal");a={style:{align:a,bcolor:L(E(b,"background-color"),[255,255,255]),color:L(E(b,"color"),[0,0,0]),fstyle:d},colspan:parseInt(e(b).attr("colspan"))||0,rowspan:parseInt(e(b).attr("rowspan"))||0};null!==b&&(b=b.getBoundingClientRect(),a.rect={width:b.width,
height:b.height});return a}function E(b,a){try{return window.getComputedStyle?(a=a.replace(/([a-z])([A-Z])/,ca),window.getComputedStyle(b,null).getPropertyValue(a)):b.currentStyle?b.currentStyle[a]:b.style[a]}catch(f){}return""}function M(b,a,f){a=E(b,a).match(/\d+/);if(null!==a){a=a[0];b=b.parentElement;var g=document.createElement("div");g.style.overflow="hidden";g.style.visibility="hidden";b.appendChild(g);g.style.width=100+f;f=100/g.offsetWidth;b.removeChild(g);return a*f}return 0}function G(a,
e,f){var g=window.navigator.userAgent;if(0<g.indexOf("MSIE ")||g.match(/Trident.*rv\:11\./)){if(e=document.createElement("iframe"))document.body.appendChild(e),e.setAttribute("style","display:none"),e.contentDocument.open("txt/html","replace"),e.contentDocument.write(f),e.contentDocument.close(),e.focus(),e.contentDocument.execCommand("SaveAs",!0,a),document.body.removeChild(e)}else if(g=document.createElement("a")){g.style.display="none";g.download=a;0<=e.toLowerCase().indexOf("base64,")?g.href=
e+F(f):g.href=e+encodeURIComponent(f);document.body.appendChild(g);if(document.createEvent)null==N&&(N=document.createEvent("MouseEvents")),N.initEvent("click",!0,!1),g.dispatchEvent(N);else if(document.createEventObject)g.fireEvent("onclick");else if("function"==typeof g.onclick)g.onclick();document.body.removeChild(g)}}function F(a){var e="",f,g,d,m,p,h,k=0;a=a.replace(/\x0d\x0a/g,"\n");g="";for(d=0;d<a.length;d++)m=a.charCodeAt(d),128>m?g+=String.fromCharCode(m):(127<m&&2048>m?g+=String.fromCharCode(m>>
6|192):(g+=String.fromCharCode(m>>12|224),g+=String.fromCharCode(m>>6&63|128)),g+=String.fromCharCode(m&63|128));for(a=g;k<a.length;)f=a.charCodeAt(k++),g=a.charCodeAt(k++),d=a.charCodeAt(k++),m=f>>2,f=(f&3)<<4|g>>4,p=(g&15)<<2|d>>6,h=d&63,isNaN(g)?p=h=64:isNaN(d)&&(h=64),e=e+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(m)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(f)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(p)+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(h);return e}var a={consoleLog:!1,csvEnclosure:'"',csvSeparator:",",csvUseBOM:!0,displayTableName:!1,escape:!1,excelstyles:["border-bottom","border-top","border-left","border-right"],fileName:"tableExport",htmlContent:!1,ignoreColumn:[],ignoreRow:[],jspdf:{orientation:"p",unit:"pt",format:"a4",margins:{left:20,right:10,top:10,bottom:10},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:{onAfterAutotable:null,onBeforeAutotable:null,onTable:null}}},numbers:{html:{decimalMark:".",thousandsSeparator:","},output:{decimalMark:".",thousandsSeparator:","}},onCellData:null,onCellHtmlData:null,outputMode:"file",tbodySelector:"tr",theadSelector:"tr",tableName:"myTableName",type:"csv",worksheetName:"xlsWorksheetName"},
v=this,N=null,u=[],r=[],q=0,y=[],h="",H=[];e.extend(!0,a,t);H=P(v);if("csv"==a.type||"txt"==a.type){t=function(b,d,f,g){r=e(v).find(b).first().find(d);r.each(function(){h="";B(this,f,q,g+r.length,function(b,f,e){var g=h,d="";if(null!=b)if(b=z(b,f,e),f=null===b||""==b?"":b.toString(),b instanceof Date)d=a.csvEnclosure+b.toLocaleString()+a.csvEnclosure;else if(d=Q(f,a.csvEnclosure,a.csvEnclosure+a.csvEnclosure),0<=d.indexOf(a.csvSeparator)||/[\r\n ]/g.test(d))d=a.csvEnclosure+d+a.csvEnclosure;h=g+(d+
a.csvSeparator)});h=e.trim(h).substring(0,h.length-1);0<h.length&&(0<A.length&&(A+="\n"),A+=h);q++});return r.length};var A="",C=0,q=0,C=C+t("thead",a.theadSelector,"th,td",C),C=C+t("tbody",a.tbodySelector,"td",C);t("tfoot",a.tbodySelector,"td",C);A+="\n";!0===a.consoleLog&&console.log(A);if("string"===a.outputMode)return A;if("base64"===a.outputMode)return F(A);try{var D=new Blob([A],{type:"text/"+("csv"==a.type?"csv":"plain")+";charset=utf-8"});saveAs(D,a.fileName+"."+a.type,"csv"!=a.type||!1===
a.csvUseBOM)}catch(b){G(a.fileName+"."+a.type,"data:text/"+("csv"==a.type?"csv":"plain")+";charset=utf-8,"+("csv"==a.type&&a.csvUseBOM?"\ufeff":""),A)}}else if("sql"==a.type){var q=0,n="INSERT INTO `"+a.tableName+"` (",u=e(v).find("thead").first().find(a.theadSelector);u.each(function(){B(this,"th,td",q,u.length,function(a,e,f){n+="'"+z(a,e,f)+"',"});q++;n=e.trim(n);n=e.trim(n).substring(0,n.length-1)});n+=") VALUES ";r=e(v).find("tbody").first().find(a.tbodySelector);r.each(function(){h="";B(this,
"td",q,u.length+r.length,function(a,e,f){h+="'"+z(a,e,f)+"',"});3<h.length&&(n+="("+h,n=e.trim(n).substring(0,n.length-1),n+="),");q++});n=e.trim(n).substring(0,n.length-1);n+=";";!0===a.consoleLog&&console.log(n);if("string"===a.outputMode)return n;if("base64"===a.outputMode)return F(n);try{D=new Blob([n],{type:"text/plain;charset=utf-8"}),saveAs(D,a.fileName+".sql")}catch(b){G(a.fileName+".sql","data:application/sql;charset=utf-8,",n)}}else if("json"==a.type){var V=[],u=e(v).find("thead").first().find(a.theadSelector);
u.each(function(){var a=[];B(this,"th,td",q,u.length,function(e,f,d){a.push(z(e,f,d))});V.push(a)});var W=[],r=e(v).find("tbody").first().find(a.tbodySelector);r.each(function(){var a=[];B(this,"td",q,u.length+r.length,function(e,f,d){a.push(z(e,f,d))});0<a.length&&(1!=a.length||""!=a[0])&&W.push(a);q++});t=[];t.push({header:V,data:W});t=JSON.stringify(t);!0===a.consoleLog&&console.log(t);if("string"===a.outputMode)return t;if("base64"===a.outputMode)return F(t);try{D=new Blob([t],{type:"application/json;charset=utf-8"}),
saveAs(D,a.fileName+".json")}catch(b){G(a.fileName+".json","data:application/json;charset=utf-8;base64,",t)}}else if("xml"===a.type){var q=0,w='<?xml version="1.0" encoding="utf-8"?>',w=w+"<tabledata><fields>",u=e(v).find("thead").first().find(a.theadSelector);u.each(function(){B(this,"th,td",q,r.length,function(a,e,f){w+="<field>"+z(a,e,f)+"</field>"});q++});var w=w+"</fields><data>",X=1,r=e(v).find("tbody").first().find(a.tbodySelector);r.each(function(){var a=1;h="";B(this,"td",q,u.length+r.length,
function(e,f,d){h+="<column-"+a+">"+z(e,f,d)+"</column-"+a+">";a++});0<h.length&&"<column-1></column-1>"!=h&&(w+='<row id="'+X+'">'+h+"</row>",X++);q++});w+="</data></tabledata>";!0===a.consoleLog&&console.log(w);if("string"===a.outputMode)return w;if("base64"===a.outputMode)return F(w);try{D=new Blob([w],{type:"application/xml;charset=utf-8"}),saveAs(D,a.fileName+".xml")}catch(b){G(a.fileName+".xml","data:application/xml;charset=utf-8;base64,",w)}}else if("excel"==a.type||"xls"==a.type||"word"==
a.type||"doc"==a.type){t="excel"==a.type||"xls"==a.type?"excel":"word";var C="excel"==t?"xls":"doc",d="xls"==C?'xmlns:x="urn:schemas-microsoft-com:office:excel"':'xmlns:w="urn:schemas-microsoft-com:office:word"',x="";e(v).filter(function(){return"none"!=e(this).data("tableexport-display")&&(e(this).is(":visible")||"always"==e(this).data("tableexport-display"))}).each(function(){q=0;H=P(this);x+="<table><thead>";u=e(this).find("thead").first().find(a.theadSelector);u.each(function(){h="";B(this,"th,td",
q,u.length,function(b,d,f){if(null!=b){h+='<th style="';for(var g in a.excelstyles)a.excelstyles.hasOwnProperty(g)&&(h+=a.excelstyles[g]+": "+e(b).css(a.excelstyles[g])+";");e(b).is("[colspan]")&&(h+='" colspan="'+e(b).attr("colspan"));e(b).is("[rowspan]")&&(h+='" rowspan="'+e(b).attr("rowspan"));h+='">'+z(b,d,f)+"</th>"}});0<h.length&&(x+="<tr>"+h+"</tr>");q++});x+="</thead><tbody>";r=e(this).find("tbody").first().find(a.tbodySelector);r.each(function(){h="";B(this,"td",q,u.length+r.length,function(b,
d,f){if(null!=b){h+='<td style="';for(var g in a.excelstyles)a.excelstyles.hasOwnProperty(g)&&(h+=a.excelstyles[g]+": "+e(b).css(a.excelstyles[g])+";");e(b).is("[colspan]")&&(h+='" colspan="'+e(b).attr("colspan"));e(b).is("[rowspan]")&&(h+='" rowspan="'+e(b).attr("rowspan"));h+='">'+z(b,d,f)+"</td>"}});0<h.length&&(x+="<tr>"+h+"</tr>");q++});a.displayTableName&&(x+="<tr><td></td></tr><tr><td></td></tr><tr><td>"+z(e("<p>"+a.tableName+"</p>"))+"</td></tr>");x+="</tbody></table>";!0===a.consoleLog&&
console.log(x)});d='<html xmlns:o="urn:schemas-microsoft-com:office:office" '+d+' xmlns="http://www.w3.org/TR/REC-html40">'+('<meta http-equiv="content-type" content="application/vnd.ms-'+t+'; charset=UTF-8">');d+="<head>";"excel"===t&&(d+="\x3c!--[if gte mso 9]>",d+="<xml>",d+="<x:ExcelWorkbook>",d+="<x:ExcelWorksheets>",d+="<x:ExcelWorksheet>",d+="<x:Name>",d+=a.worksheetName,d+="</x:Name>",d+="<x:WorksheetOptions>",d+="<x:DisplayGridlines/>",d+="</x:WorksheetOptions>",d+="</x:ExcelWorksheet>",
d+="</x:ExcelWorksheets>",d+="</x:ExcelWorkbook>",d+="</xml>",d+="<![endif]--\x3e");d+="</head>";d+="<body>";d+=x;d+="</body>";d+="</html>";!0===a.consoleLog&&console.log(d);if("string"===a.outputMode)return d;if("base64"===a.outputMode)return F(d);try{D=new Blob([d],{type:"application/vnd.ms-"+a.type}),saveAs(D,a.fileName+"."+C)}catch(b){G(a.fileName+"."+C,"data:application/vnd.ms-"+t+";base64,",d)}}else if("png"==a.type)html2canvas(e(v)[0],{allowTaint:!0,background:"#fff",onrendered:function(b){b=
b.toDataURL();b=b.substring(22);for(var e=atob(b),f=new ArrayBuffer(e.length),d=new Uint8Array(f),h=0;h<e.length;h++)d[h]=e.charCodeAt(h);!0===a.consoleLog&&console.log(e);if("string"===a.outputMode)return e;if("base64"===a.outputMode)return F(b);try{var m=new Blob([f],{type:"image/png"});saveAs(m,a.fileName+".png")}catch(p){G(a.fileName+".png","data:image/png;base64,",b)}}});else if("pdf"==a.type)if(!1===a.jspdf.autotable){var D={dim:{w:M(e(v).first().get(0),"width","mm"),h:M(e(v).first().get(0),
"height","mm")},pagesplit:!1},Y=new jsPDF(a.jspdf.orientation,a.jspdf.unit,a.jspdf.format);Y.addHTML(e(v).first(),a.jspdf.margins.left,a.jspdf.margins.top,D,function(){R(Y)})}else{var k=a.jspdf.autotable.tableExport;if("string"===typeof a.jspdf.format&&"bestfit"===a.jspdf.format.toLowerCase()){var J={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]},O="",K="",Z=0;e(v).filter(":visible").each(function(){if("none"!=e(this).css("display")){var a=M(e(this).get(0),
"width","pt");if(a>Z){a>J.a0[0]&&(O="a0",K="l");for(var d in J)J.hasOwnProperty(d)&&J[d][1]>a&&(O=d,K="l",J[d][0]>a&&(K="p"));Z=a}}});a.jspdf.format=""==O?"a4":O;a.jspdf.orientation=""==K?"w":K}k.doc=new jsPDF(a.jspdf.orientation,a.jspdf.unit,a.jspdf.format);e(v).filter(function(){return"none"!=e(this).data("tableexport-display")&&(e(this).is(":visible")||"always"==e(this).data("tableexport-display"))}).each(function(){var b,d=0;H=P(this);k.columns=[];k.rows=[];k.rowoptions={};if("function"===typeof k.onTable&&
!1===k.onTable(e(this),a))return!0;a.jspdf.autotable.tableExport=null;var f=e.extend(!0,{},a.jspdf.autotable);a.jspdf.autotable.tableExport=k;f.margin={};e.extend(!0,f.margin,a.jspdf.margins);f.tableExport=k;"function"!==typeof f.beforePageContent&&(f.beforePageContent=function(a){1==a.pageCount&&a.table.rows.concat(a.table.headerRow).forEach(function(b){0<b.height&&(b.height+=(2-1.15)/2*b.styles.fontSize,a.table.height+=(2-1.15)/2*b.styles.fontSize)})});"function"!==typeof f.createdHeaderCell&&(f.createdHeaderCell=
function(a,b){a.styles=Object.assign({},b.row.styles);if("undefined"!=typeof k.columns[b.column.dataKey]){var d=k.columns[b.column.dataKey];if("undefined"!=typeof d.rect){var e;a.contentWidth=d.rect.width;if("undefined"==typeof k.heightRatio||0==k.heightRatio)e=b.row.raw[b.column.dataKey].rowspan?b.row.raw[b.column.dataKey].rect.height/b.row.raw[b.column.dataKey].rowspan:b.row.raw[b.column.dataKey].rect.height,k.heightRatio=a.styles.rowHeight/e;e=b.row.raw[b.column.dataKey].rect.height*k.heightRatio;
e>a.styles.rowHeight&&(a.styles.rowHeight=e)}"undefined"!=typeof d.style&&!0!==d.style.hidden&&(a.styles.halign=d.style.align,"inherit"===f.styles.fillColor&&(a.styles.fillColor=d.style.bcolor),"inherit"===f.styles.textColor&&(a.styles.textColor=d.style.color),"inherit"===f.styles.fontStyle&&(a.styles.fontStyle=d.style.fstyle))}});"function"!==typeof f.createdCell&&(f.createdCell=function(a,b){var d=k.rowoptions[b.row.index+":"+b.column.dataKey];"undefined"!=typeof d&&"undefined"!=typeof d.style&&
!0!==d.style.hidden&&(a.styles.halign=d.style.align,"inherit"===f.styles.fillColor&&(a.styles.fillColor=d.style.bcolor),"inherit"===f.styles.textColor&&(a.styles.textColor=d.style.color),"inherit"===f.styles.fontStyle&&(a.styles.fontStyle=d.style.fstyle))});"function"!==typeof f.drawHeaderCell&&(f.drawHeaderCell=function(a,b){var d=k.columns[b.column.dataKey];return(1!=d.style.hasOwnProperty("hidden")||!0!==d.style.hidden)&&0<=d.rowIndex?S(a,b,d):!1});"function"!==typeof f.drawCell&&(f.drawCell=function(a,
b){var d=k.rowoptions[b.row.index+":"+b.column.dataKey];if(S(a,b,d)){k.doc.rect(a.x,a.y,a.width,a.height,a.styles.fillStyle);if("undefined"!=typeof d&&"undefined"!=typeof d.kids&&0<d.kids.length){var e=a.height/d.rect.height;if(e>k.dh||"undefined"==typeof k.dh)k.dh=e;k.dw=a.width/d.rect.width;T(a,d.kids,k)}k.doc.autoTableText(a.text,a.textPos.x,a.textPos.y,{halign:a.styles.halign,valign:a.styles.valign})}return!1});var g=[];u=e(this).find("thead").find(a.theadSelector);u.each(function(){b=0;B(this,
"th,td",d,u.length,function(a,e,f){var h=U(a);h.title=z(a,e,f);h.key=b++;h.rowIndex=d;g.push(h)});d++});0<d&&e.each(g,function(){this.rowIndex==d-1&&(obj=1<d&&null==this.rect?aa(g,this.key,d-2):this,null!=obj&&k.columns.push(obj))});var h=0;r=e(this).find("tbody").find(a.tbodySelector);r.each(function(){var a=[];b=0;B(this,"td",d,u.length+r.length,function(d,f,g){if("undefined"===typeof k.columns[b]){var l={title:"",key:b,style:{hidden:!0}};k.columns.push(l)}"undefined"!==typeof d&&null!=d?(l=U(d),
l.kids=e(d).children()):(l=e.extend(!0,{},k.rowoptions[h+":"+(b-1)]),l.colspan=-1);k.rowoptions[h+":"+b++]=l;a.push(z(d,f,g))});a.length&&(k.rows.push(a),h++);d++});if("function"===typeof k.onBeforeAutotable)k.onBeforeAutotable(e(this),k.columns,k.rows,f);k.doc.autoTable(k.columns,k.rows,f);if("function"===typeof k.onAfterAutotable)k.onAfterAutotable(e(this),f);a.jspdf.autotable.startY=k.doc.autoTableEndPosY()+f.margin.top});R(k.doc);k.columns.length=0;k.rows.length=0;delete k.doc;k.doc=null}return this}})})(jQuery);