• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Excel 2007 and charset getting appended to ContentType response Header

 
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Example:

.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.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic