diff --git a/bower.json b/bower.json index 48f354f..74af6b6 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "tableExport.jquery.plugin", - "version": "1.6.5", + "version": "1.6.6", "main": "tableExport.min.js", "license": "MIT", "description": "html table export", diff --git a/package.json b/package.json index 93e0fe8..0968f7d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tableexport.jquery.plugin", - "version": "1.6.5", + "version": "1.6.6", "description": "html table export", "main": "tableExport.min.js", "dependencies": { diff --git a/tableExport.min.js b/tableExport.min.js index f8266ae..7010f21 100644 --- a/tableExport.min.js +++ b/tableExport.min.js @@ -14,8 +14,8 @@ b.textPos.x,t=a.table.columns.indexOf(a.column),m=1;mg&&(f=Math.min(b.width,this.width),l=this.height*f/this.width),l/gi,"\u2060");b=c("
").html(t).contents();t="";c.each(b.text().split("\u2028"),function(b,a){0/gi,"\u2060");b=c("
").html(t).contents();t="";c.each(b.text().split("\u2028"),function(b,a){0b?"-":"")+(a.numbers.output.thousandsSeparator?(f?m[0].substr(0,f)+a.numbers.output.thousandsSeparator:"")+m[0].substr(f).replace(/(\d{3})(?=\d)/g,"$1"+a.numbers.output.thousandsSeparator):m[0])+(m[1].length? a.numbers.output.decimalMark+m[1]:"")}}!0===a.escape&&(d=escape(d));"function"===typeof a.onCellData&&(d=a.onCellData(y,h,e,d))}return d}function la(b,a,e){return a+"-"+e.toLowerCase()}function N(b,a){var h=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(b),d=a;h&&(d=[parseInt(h[1]),parseInt(h[2]),parseInt(h[3])]);return d}function fa(b){var a=E(b,"text-align"),e=E(b,"font-weight"),d=E(b,"font-style"),f="";"start"==a&&(a="rtl"==E(b,"direction")?"right":"left");700<=e&&(f="bold");"italic"==d&& (f+=d);""===f&&(f="normal");a={style:{align:a,bcolor:N(E(b,"background-color"),[255,255,255]),color:N(E(b,"color"),[0,0,0]),fstyle:f},colspan:parseInt(c(b).attr("colspan"))||0,rowspan:parseInt(c(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])/,la),window.getComputedStyle(b,null).getPropertyValue(a)):b.currentStyle?b.currentStyle[a]:b.style[a]}catch(e){}return""} @@ -28,32 +28,32 @@ isNaN(f)&&(m=64),b=b+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345 ignoreRow:[],jsonScope:"all",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,outputImages:!0}}},numbers:{html:{decimalMark:".", thousandsSeparator:","},output:{decimalMark:".",thousandsSeparator:","}},onCellData:null,onCellHtmlData:null,outputMode:"file",pdfmake:{enabled:!1},tbodySelector:"tr",tfootSelector:"tr",theadSelector:"tr",tableName:"myTableName",type:"csv",worksheetName:"xlsWorksheetName"},r=this,P=null,p=[],k=[],l=0,A=[],n="",H=[],z;c.extend(!0,a,u);H=R(r);if("csv"==a.type||"txt"==a.type){var D="",I=0,l=0,U=function(b,h,e){b.each(function(){n="";x(this,h,l,e+b.length,function(b,c,e){var d=n,g="";if(null!==b)if(b= w(b,c,e),c=null===b||""===b?"":b.toString(),b instanceof Date)g=a.csvEnclosure+b.toLocaleString()+a.csvEnclosure;else if(g=S(c,a.csvEnclosure,a.csvEnclosure+a.csvEnclosure),0<=g.indexOf(a.csvSeparator)||/[\r\n ]/g.test(g))g=a.csvEnclosure+g+a.csvEnclosure;n=d+(g+a.csvSeparator)});n=c.trim(n).substring(0,n.length-1);0',B=B+"", -p=c(r).find("thead").first().find(a.theadSelector);p.each(function(){x(this,"th,td",l,p.length,function(a,c,e){B+=""+w(a,c,e)+""});l++});var B=B+"",ga=1;c(r).find("tbody").each(function(){k.push.apply(k,c(this).find(a.tbodySelector))});a.tfootSelector.length&&k.push.apply(k,c(r).find("tfoot").find(a.tfootSelector));c(k).each(function(){var a=1;n="";x(this,"td",l,p.length+k.length,function(b,c,d){n+=""+w(b,c,d)+"";a++});0"!= +p=c(r).find("thead").first().find(a.theadSelector);p.each(function(){x(this,"th,td",l,p.length,function(a,c,e){B+=""+w(a,c,e)+""});l++});var B=B+"",ga=1;c(r).find("tbody").each(function(){k.push.apply(k,c(this).find(a.tbodySelector))});a.tfootSelector.length&&k.push.apply(k,c(r).find("tfoot").find(a.tfootSelector));c(k).each(function(){var a=1;n="";x(this,"td,th",l,p.length+k.length,function(b,c,d){n+=""+w(b,c,d)+"";a++});0"!= n&&(B+=''+n+"",ga++);l++});B+="";!0===a.consoleLog&&console.log(B);if("string"===a.outputMode)return B;if("base64"===a.outputMode)return F(B);try{z=new Blob([B],{type:"application/xml;charset=utf-8"}),saveAs(z,a.fileName+".xml")}catch(b){C(a.fileName+".xml","data:application/xml;charset=utf-8;base64,",B)}}else if("excel"==a.type||"xls"==a.type||"word"==a.type||"doc"==a.type){u="excel"==a.type||"xls"==a.type?"excel":"word";var K="excel"==u?"xls":"doc",q='xmlns:x="urn:schemas-microsoft-com:office:'+ u+'"',G="";c(r).filter(function(){return"none"!=c(this).data("tableexport-display")&&(c(this).is(":visible")||"always"==c(this).data("tableexport-display"))}).each(function(){var b=c(this);l=0;H=R(this);G+="";p=b.find("thead").first().find(a.theadSelector);p.each(function(){n="";x(this,"th,td",l,p.length,function(b,e,d){if(null!==b){var f="";n+=""}});0"+n+"");l++});G+="";b.find("tbody").each(function(){k.push.apply(k,c(this).find(a.tbodySelector))});a.tfootSelector.length&&k.push.apply(k,b.find("tfoot").find(a.tfootSelector));c(k).each(function(){var b=c(this);n="";x(this, -"td",l,p.length+k.length,function(e,d,f){if(null!==e){var g="",h=c(e).data("tableexport-msonumberformat");"undefined"==typeof h&&"function"===typeof a.onMsoNumberFormat&&(h=a.onMsoNumberFormat(e,d,f));"undefined"!=typeof h&&""!==h&&(g="style=\"mso-number-format:'"+h+"'");for(var m in a.excelstyles)a.excelstyles.hasOwnProperty(m)&&(h=c(e).css(a.excelstyles[m]),""===h&&(h=b.css(a.excelstyles[m])),""!==h&&"0px none rgb(0, 0, 0)"!=h&&"rgba(0, 0, 0, 0)"!=h&&(g+=""===g?'style="':";",g+=a.excelstyles[m]+ +"td,th",l,p.length+k.length,function(e,d,f){if(null!==e){var g="",h=c(e).data("tableexport-msonumberformat");"undefined"==typeof h&&"function"===typeof a.onMsoNumberFormat&&(h=a.onMsoNumberFormat(e,d,f));"undefined"!=typeof h&&""!==h&&(g="style=\"mso-number-format:'"+h+"'");for(var m in a.excelstyles)a.excelstyles.hasOwnProperty(m)&&(h=c(e).css(a.excelstyles[m]),""===h&&(h=b.css(a.excelstyles[m])),""!==h&&"0px none rgb(0, 0, 0)"!=h&&"rgba(0, 0, 0, 0)"!=h&&(g+=""===g?'style="':";",g+=a.excelstyles[m]+ ":"+h));n+="")+""}});0"+n+"");l++});a.displayTableName&&(G+="");G+="
"+w(c("

"+a.tableName+"

"))+"
";!0===a.consoleLog&&console.log(G)});q=''+ ('')+"";"excel"===u&&(q+="\x3c!--[if gte mso 9]>",q+="",q+="",q+="",q+="",q+="",q+=a.worksheetName,q+="",q+="",q+="",q+="",q+="",q+="",q+="",q+="",q+="br {mso-data-placement:same-cell;}"; q+="";q+="";q+=G;q+="";q+="";!0===a.consoleLog&&console.log(q);if("string"===a.outputMode)return q;if("base64"===a.outputMode)return F(q);try{z=new Blob([q],{type:"application/vnd.ms-"+a.type}),saveAs(z,a.fileName+"."+K)}catch(b){C(a.fileName+"."+K,"data:application/vnd.ms-"+u+";base64,",q)}}else if("xlsx"==a.type){var W=[],X=[],l=0,k=c(r).find("thead").first().find(a.theadSelector);c(r).find("tbody").each(function(){k.push.apply(k,c(this).find(a.tbodySelector))});a.tfootSelector.length&& k.push.apply(k,c(r).find("tfoot").find(a.tfootSelector));c(k).each(function(){var a=[];x(this,"th,td",l,k.length,function(b,c,d){if("undefined"!==typeof b&&null!==b){var e=parseInt(b.getAttribute("colspan")),g=parseInt(b.getAttribute("rowspan"));b=w(b,c,d);""!==b&&b==+b&&(b=+b);X.forEach(function(b){if(l>=b.s.r&&l<=b.e.r&&a.length>=b.s.c&&a.length<=b.e.c)for(var c=0;c<=b.e.c-b.s.c;++c)a.push(null)});if(g||e)e=e||1,X.push({s:{r:l,c:a.length},e:{r:l+(g||1)-1,c:a.length+e-1}});a.push(""!==b?b:null); if(e)for(g=0;gia){a>L.a0[0]&&(Q="a0",M="l");for(var f in L)L.hasOwnProperty(f)&&L[f][1]>a&&(Q=f,M="l",L[f][0]>a&&(M="p"));ia=a}}});a.jspdf.format=""===Q?"a4":Q;a.jspdf.orientation=""===M?"w":M}f.doc= -new jsPDF(a.jspdf.orientation,a.jspdf.unit,a.jspdf.format);!0===f.outputImages&&(f.images={});"undefined"!=typeof f.images&&(c(r).filter(function(){return"none"!=c(this).data("tableexport-display")&&(c(this).is(":visible")||"always"==c(this).data("tableexport-display"))}).each(function(){var b=0;p=c(this).find("thead").find(a.theadSelector);c(this).find("tbody").each(function(){k.push.apply(k,c(this).find(a.tbodySelector))});a.tfootSelector.length&&k.push.apply(k,c(this).find("tfoot").find(a.tfootSelector)); -c(k).each(function(){x(this,"td",p.length+b,p.length+k.length,function(a,b,d){"undefined"!==typeof a&&null!==a&&(b=c(a).children(),"undefined"!=typeof b&&0ia){a>L.a0[0]&&(Q="a0",M="l");for(var f in L)L.hasOwnProperty(f)&&L[f][1]>a&&(Q=f,M="l",L[f][0]>a&&(M="p"));ia=a}}});a.jspdf.format=""===Q?"a4":Q;a.jspdf.orientation= +""===M?"w":M}f.doc=new jsPDF(a.jspdf.orientation,a.jspdf.unit,a.jspdf.format);!0===f.outputImages&&(f.images={});"undefined"!=typeof f.images&&(c(r).filter(function(){return"none"!=c(this).data("tableexport-display")&&(c(this).is(":visible")||"always"==c(this).data("tableexport-display"))}).each(function(){var b=0;p=c(this).find("thead").find(a.theadSelector);c(this).find("tbody").each(function(){k.push.apply(k,c(this).find(a.tbodySelector))});a.tfootSelector.length&&k.push.apply(k,c(this).find("tfoot").find(a.tfootSelector)); +c(k).each(function(){x(this,"td,th",p.length+b,p.length+k.length,function(a,b,d){"undefined"!==typeof a&&null!==a&&(b=c(a).children(),"undefined"!=typeof b&&0a.styles.rowHeight&&(a.styles.rowHeight= g)}"undefined"!=typeof e.style&&!0!==e.style.hidden&&(a.styles.halign=e.style.align,"inherit"===d.styles.fillColor&&(a.styles.fillColor=e.style.bcolor),"inherit"===d.styles.textColor&&(a.styles.textColor=e.style.color),"inherit"===d.styles.fontStyle&&(a.styles.fontStyle=e.style.fstyle))}});"function"!==typeof d.createdCell&&(d.createdCell=function(a,b){var c=f.rowoptions[b.row.index+":"+b.column.dataKey];"undefined"!=typeof c&&"undefined"!=typeof c.style&&!0!==c.style.hidden&&(a.styles.halign=c.style.align, "inherit"===d.styles.fillColor&&(a.styles.fillColor=c.style.bcolor),"inherit"===d.styles.textColor&&(a.styles.textColor=c.style.color),"inherit"===d.styles.fontStyle&&(a.styles.fontStyle=c.style.fstyle))});"function"!==typeof d.drawHeaderCell&&(d.drawHeaderCell=function(a,b){var c=f.columns[b.column.dataKey];return(!0!==c.style.hasOwnProperty("hidden")||!0!==c.style.hidden)&&0<=c.rowIndex?ba(a,b,c):!1});"function"!==typeof d.drawCell&&(d.drawCell=function(a,b){var c=f.rowoptions[b.row.index+":"+b.column.dataKey]; if(ba(a,b,c)){f.doc.rect(a.x,a.y,a.width,a.height,a.styles.fillStyle);if("undefined"!=typeof c&&"undefined"!=typeof c.kids&&0f.dh||"undefined"==typeof f.dh)f.dh=d;f.dw=a.width/c.rect.width;ea(a,c.kids,f)}f.doc.autoTableText(a.text,a.textPos.x,a.textPos.y,{halign:a.styles.halign,valign:a.styles.valign})}return!1});f.headerrows=[];p=c(this).find("thead").find(a.theadSelector);p.each(function(){b=0;f.headerrows[e]=[];x(this,"th,td",e,p.length,function(a, -c,d){var g=fa(a);g.title=w(a,c,d);g.key=b++;g.rowIndex=e;f.headerrows[e].push(g)});e++});0