I click on a button and this function runs to export into .xls file but the name of it is download.xls - I want to be able to change the download name... Does anyone know how to add this functionality...
here is the code for the button
<li class="button"><a href="javascript:;" onclick="fnExcelReport();"
style="background-color: #4cae4c;">Export EXCEL</a></li>
and here is the script
function fnExcelReport()
{
var tab_text = "<table border='2px'>";
tab_text += "<tr bgcolor='#eeeeee' height='50'><th colspan='12' ";
tab_text += "style='text-align:center; font-size:20px;'>COMPLETED "
tab_text += "TRIPS </th></tr><tr bgcolor='#bf997e' height='50'"
tab_text += "color='#FFFFFF'>";
var i = 0;
var tab = document.getElementById('completed_trips_prov'); // id of table
for(i = 0 ; i < tab.rows.length ; i++)
{
tab_text = tab_text + tab.rows[i].innerHTML+"</tr>";
//tab_text=tab_text+"</tr>";
}
tab_text = tab_text + "</table>";
//remove if u want links in your table
tab_text = tab_text.replace(/<a[^>]*>|<\/a>/g, "");
// remove if u want images in your table
tab_text = tab_text.replace(/<img[^>]*>/gi,"");
// reomves input params
tab_text = tab_text.replace(/<input[^>]*>|<\/input>/gi, "");
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
// If Internet Explorer
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))
{
txtArea1.document.open("txt/html","replace");
txtArea1.document.write(tab_text);
txtArea1.document.close();
txtArea1.focus();
sa = txtArea1.document.execCommand("SaveAs",true,"Say T.xls");
}
//other browser not tested on IE 11
else {
sa = window.open('data:application/vnd.ms-excel,'
+ encodeURIComponent(tab_text));
}
return (sa);
}