I have a problem; I have a method to generate an excel from a table and it works but in Google Chrome, however I will try in mozilla and it does not work ...
Any suggestions?
CODE
<title>Reportes Equipo</title>
<meta charset="utf-8">
<!--Librerias para Exportar excel-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="JS/exportarExcel.js" type="text/javascript"></script>
<!--Librerias para datepicker-->
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
<script src="JS/datepicker.js" type="text/javascript"></script>
The structure of the table is basic;
And with this botton
I create the excel.
<input type='submit' value="EXPORTAR" style='background:url("IMG/excel.png") no-repeat; padding-left: 30px ; height: 30px' id="btnExport" />
Finally, this is the part of what creates the excel.
$(document).ready(function() {
$("#btnExport").click(function(e) {
e.preventDefault();
// calculamos la fecha actual
var hoy = new Date();
dia = hoy.getDate();
mes = hoy.getMonth() + 1 ;
anio= hoy.getFullYear();
fecha_actual = String(dia + "_" + mes + "_" + anio);
// Pagina que hizo el llamado
var pagina = document.getElementById('pagina').value;
//Obtenemos los valores de la tabla
var data_type = 'data:application/vnd.ms-excel';
var table_div = document.getElementById('table_wrapper');
var table_html = table_div.outerHTML.replace(/ /g, '%20');
var a = document.createElement('a');
a.href = data_type + ', ' + table_html;
a.download = 'Reporte ' + pagina + ' '+ fecha_actual + '.xls';
a.click();
});
});
It does not generate any errors, just do not create the excel.
Any solution?