Buenas amigos, estoy probando una funcion que encontre que genera un excel de una tabla HTML
aqui el codigo
Código Javascript
:
Ver originalfunction fncEnviaExcel(){
var tab_text='<table border="1px">style="font-size:20px" ">';
var textRange; var j=0;
tab = document.getElementById('tablaLiquidacion');
var lines = tab.rows.length;
if (lines>0){
tab_text = tab_text + '<tr bgcolor="#DFDFDF">' + tab.rows[0].innerHTML + '</tr>';
}
alert("a");
for(j = 1 ; j < lines ; j++)
{
tab_text=tab_text+"<tr>"+tab.rows[j].innerHTML+"</tr>";
//tab_text=tab_text+"</tr>";
}
alert("b");
tab_text=tab_text+"</table>";
tab_text= tab_text.replace(/<A[^>]*>|<\/A>/g, "");//remove if u want links in your table
tab_text= tab_text.replace(/<img[^>]*>/gi,""); // remove if u want images in your table
tab_text= tab_text.replace(/<input[^>]*>|<\/input>/gi, ""); // reomves input params
alert("c");
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // If Internet Explorer
{
txtArea1.document.open("txt/html","replace");
txtArea1.document.write(tab_text);
txtArea1.document.close();
txtArea1.focus();
sa=txtArea1.document.execCommand("SaveAs",true,"Liquidacion.xls");
}else{ //other browser not tested on IE 11
sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text));
return (sa);
}
}
ya he leido y probado varias opciones pero no logro que genere un archivo...es decir crea lo que parece ser un EXCEL pero no lo abre y ademas no se como personalizar el nombre para MOZILLA...
Ojala alguien me pueda dar alguna idea, para seguir.
Gracias