Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Exportar(){
- var tmpElemento = document.createElement('a');
- var data_type = 'data:application/vnd.ms-excel; charset=ISO-8859-1';
- var tabla_div = document.getElementById('tblReporte');
- var tabla_html = tabla_div.outerHTML.replace(/ /g, '%20');
- tmpElemento.href = data_type + ', ' + tabla_html;
- tmpElemento.download = 'LISTADO.xls';
- tmpElemento.click();}
- function Exportar(){
- var uri = 'data:application/vnd.ms-excel;base64,'
- , template = '<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"><meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8"><head><!--[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]--></head><body><table>{table}</table></body></html>'
- , base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) }
- , format = function (s, c) { return s.replace(/{(w+)}/g, function (m, p) { return c[p]; }) }
- var table = 'tblReporte';
- var name = 'nombre_hoja_calculo';
- if (!table.nodeType) table = document.getElementById(table)
- var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML }
- window.location.href = uri + base64(format(template, ctx))
- }
Add Comment
Please, Sign In to add comment