apollodec/Apollo/bower_components/ng-table-excel-export/ng-table-excel-export.min
2018-04-11 14:35:42 +05:30

15 lines
2.9 KiB
Plaintext
Executable File

/**
* ngTableExcelExport 1.0.0
* JavaScript export to Excel or CSV from HTML tables automatically in the browser and also compatible with all browsers.
*
* @author: Murugavel Ramachandran (blsrm@yahoo.com)
* @url: https://github.com/blsrm/ngTableExcelExport
*
*/
/*jslint browser: true, bitwise: true, vars: true, white: true */
/*global define, exports, module */
(function(m){var g=function(){function g(h,a,e){a=a||"";e=e||512;h=window.atob(h);var c=[],b;for(b=0;b<h.length;b+=e){var f=h.slice(b,b+e),k=Array(f.length),d;for(d=0;d<f.length;d+=1)k[d]=f.charCodeAt(d);f=new window.Uint8Array(k);c.push(f)}return new window.Blob(c,{type:a})}function q(h,a,e,c){if(window.navigator.msSaveBlob)return a=g(a,e),window.navigator.msSaveBlob(a,c),!1;window.URL.createObjectURL?(a=g(a,e),e=window.URL.createObjectURL(a,e,c),h.href=e):(h.download=c,h.href="data:"+e+";base64,"+
a);return!0}var n=",",p="\r\n",m=function(h,a){return h.replace(RegExp("{(\\w+)}","g"),function(e,c){return a[c]})};return{excel:function(h,a,e){a=a.nodeType?a:document.getElementById(a);var c="",b,f,k,d;for(b=0;b<a.rows.length;b+=1){k=a.rows[b];var l="";if(-1===k.className.indexOf("ng-table-filters")){for(f=""===a.rows[0].cells[0].textContent.trim()?1:0;f<k.cells.length;f+=1)d=k.cells[f],l=0===b?l+("<th>"+d.textContent.trim()+"</th>"):l+("<td>"+d.textContent.trim()+"</td>");c+="<tr>"+l+"</tr>"}}a=
window.btoa(window.unescape(encodeURIComponent(m('<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta name=ProgId content=Excel.Sheet> <meta name=Generator content="Microsoft Excel 11"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\x3c!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--\x3e</head><body><table border="1">{table}</table></body></html>',
{worksheet:e||"Worksheet",table:c}))));return q(h,a,"application/vnd.ms-excel",e+".xls")},csv:function(h,a,e,c,b){void 0!==c&&c&&(n=c);void 0!==b&&b&&(p=b);a=a.nodeType?a:document.getElementById(a);c="SEP="+n+p;var f,k,d;for(b=0;b<a.rows.length;b+=1){k=a.rows[b];var l="";if(-1===k.className.indexOf("ng-table-filters")){for(f=""===a.rows[0].cells[0].textContent.trim()?1:0;f<k.cells.length;f+=1){d=k.cells[f];var g=d.textContent.trim();d=g;var m=-1!==g.indexOf(n)||-1!==g.indexOf("\r")||-1!==g.indexOf("\n");
(g=-1!==g.indexOf('"'))&&(d=d.replace(/"/g,'""'));if(m||g)d='"'+d+'"';l=l+d+(f?n:" ")}l=l.slice(0,l.length-1);c+=l+p}}a=window.btoa(window.unescape(encodeURIComponent(c)));return q(h,a,"application/csv",e+".csv")}}}();"function"===typeof define&&define.amd?define(function(){return g}):"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(exports=module.exports=g),exports.ngTableExcelExport=g):m.ngTableExcelExport=g})(this);