Setting mime type for excel document

MS Excel has the following observed MIME types:

  • application/vnd.ms-excel (official)
  • application/msexcel
  • application/x-msexcel
  • application/x-ms-excel
  • application/x-excel
  • application/x-dos_ms_excel
  • application/xls
  • application/x-xls
  • application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (xlsx)

Is there any one type that would work for all versions? If not, do we need to set response.setContentType() with each one of these mime types individually?

Also, we use file streaming in our application to display document (not just excel – any type of document). In doing so, how can we retain the filename if the user opts to save the file – currently, the name of the servlet that renders the file appears as the default name.

6 Answers
6

Leave a Comment