While downloading Excel documents both 2003 (xls) and 2007 (xlsx) I am getting a warning message pop-up with "Yes"\"No"
The file you are trying to open, 'download.do' is in a different format than specified by the file extension. Verify that the file is not corrupted and is from
a trusted source before opening the file. Do you want to open the file now?
Though I set the content type header with application/vnd.ms-excel (excel 2003) and application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (excel 2007), I see charset=UTF-8 is appended automatically to the content type header.
Content Type Header: application/vnd.ms-excel; charset=UTF-8
Am I getting the warning message because of the charset being appended at the end of the content type header? If yes, is there a way to remove it?
Any help would be greatly appreciated?
Joined: Nov 15, 2004
After some research, I found the issue is not with the charset getting appended to the content type.
As the warning message states, the browser couldn't recognize the extension. So based on the file extension, I dynamically appended the extension.
.do for all types of files like jpg, pdg, doc, docx, txt, html
replace the .do with .xls(or).xlsx based on the file extension of the attached file. In this way browser does not throw the warning message and opens the xl file.
Put the .xls and .xlsx mappings in web.xml for action class.
subject: Excel 2007 and charset getting appended to ContentType response Header