views:

2571

answers:

2

MS Excel has the following acceptable mime types:

  • application/vnd.ms-excel (official)
  • application/msexcel
  • application/x-msexcel
  • application/x-ms-excel
  • application/vnd.ms-excel
  • application/x-excel
  • application/x-dos_ms_excel
  • application/xls application/x-xls

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.

A: 

All of those MIME types you listed are just aliases of application/vnd.ms-excel, but there are also some other excel related ones which are not.

I'm not sure about your second question.

Gaz Davidson
+6  A: 

I believe the standard MIME type for excel files is application/vnd.ms-excel.

Regarding the name of the document, you should set the following header in the response:

header('Content-Disposition: attachment; filename="name_of_excel_file.xls"');
jbochi