I used below code for that but its works only in Firefox. It also not allow customize exported file name. It takes a random file name.
var tableToExcel = (f
Try a blob. Should work in IE10+, Chrome/Safari and Fx
window.URL = window.URL || window.webkitURL;
var blob = new Blob([format(template, ctx)]); // format is part of OP's code
var blobURL = window.URL.createObjectURL(blob);
if (blobURL) {
$("")
.attr("href", blobURL)
.attr("download", fileName)
.text("Download "+fileName+" for import")
.appendTo('#downloadLink');
}
else {
$("#downloadLink").html("Please cut and paste from the table below");
}