Using this :
HttpHeaders headers = new HttpHeaders();
headers.setContentLength(byteArray.length);
headers.setContentType(MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
headers.setCacheControl(CacheControl.noCache());
headers.add("Content-Disposition", "attachment; filename=yourFileName.xlsx");
When the file gets generated then it shows as *.xls.
Ideally file should get generated as *.xlsx, but file name extension is *.xls.
Tried this:
headers.setContentType(MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
But no luck.