I am looking to create an Excel file named "myOrder" with a suffix of the current date. Is there a way to generate a filename in the format of "yyyyMMddhhmmss", for example, "20220704073533"?
$.ajax({
url: kendo.format('@(Server.UrlDecode(Url.Action("myExcel", "NewOrder", new { orderKeys = "{0}" })))', ids.join()),
method: 'POST',
xhrFields: {
responseType: 'blob'
},
success: function (data) {
var downloadDate = new Date().toISOString().replace(/[:-]/g,"").slice(0,14);
var a = document.createElement('a');
var url = window.URL.createObjectURL(data);
a.href = url;
a.download = 'myOrder_' + downloadDate + '.xlsx';
document.body.append(a);
a.click();
a.remove();
window.URL.revokeObjectURL(url);
}
});