if you want to change default file name according to @Axel Richter's answer, try this:
var link = document.createElement('a');
link.download = 'filename.xls';
...
link.href = uri + base64(format(template, ctx));
link.click();
...
replace window.location.href with link.href