I'm exporting an xls file from a Java backend but when the client receives it, it is recognised as an xlsx file despite it having the .xls extension in the name. I am using JasperXlsExporterBuilder to build the xls file.
When sending the file, I set the response type:response.type("application/vnd.ms-excel");
and the response headers: response.header("Content-Disposition", "attachment;filename=" + file.getName());
where file name is filename.xls
But still when the client receives it, the file is called filename.xls but it says You have chosen to open: filename.xls which is Excel 2007 spreadsheet (5kB) from: blob:
this causes an issue as some excel versions can't handle the mismatch between the recognised type and the file extension.
Nothing you're doing is causing that; the computer that is downloading your file has a broken installation. For example, if the registry 'links' the .xls extension, you'd get that. You cannot detect this and cannot fix it (because you're a webserver; if you could detect or fix such things, you could also do malicious things, hence, you can't, and you never will be able to do such things from web servers).
One last ditch effort you can try which probably won't work (at which point you've exhausted all options available to you server-side) is to ensure that the URL itself ends in .xls. Make sure the user is following a link like https://www.user3274server.com/foo/bar/filename.xls
.