Setting mime type for excel document
I was setting MIME type from .NET code as below -
File(generatedFileName, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
My application generates excel using OpenXML SDK. This MIME type worked -
vnd.openxmlformats-officedocument.spreadsheetml.sheet
Waking up an old thread here I see, but I felt the urge to add the "new" .xlsx format.
According to http://filext.com/file-extension/XLSX the extension for .xlsx is application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
. It might be a good idea to include it when checking for mime types!
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"');
For .xls use the following content-type
application/vnd.ms-excel
For Excel 2007 version and above .xlsx files format
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet