In my application, I have an option to download the excel file from the folder by the user, all functions are working well but it shows only the response in the console and I can not download the excel file at the same time the browser does not show the save or download option.
Note : I used all possible ContentType("application/vnd.openxmlformats officedocument.spreadsheetml.sheet").
String downloadFolder = request.getRealPath(fileDetail.getFilePath()+fileDetail.getFileName());
Path file = Paths.get(downloadFolder);
if(Files.exists(file)){
response.reset();
response.setContentType("application/vnd.openxmlformats officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment; filename=\"Demo.xlsx");
try {
Files.copy(file, response.getOutputStream());
response.getOutputStream().flush();
} catch (IOException e){
return null;
}
}
How can I solve this problem? I need to download the excel file when the method is called.Thank you
.xls
in Notepad? Does not seem like you should be able to to me. - Matt Clark