Setting mime type for excel document

后端 未结 7 1949
终归单人心
终归单人心 2020-11-22 06:34

MS Excel has the following observed MIME types:

  • application/vnd.ms-excel (official)
  • application/msexcel
  • appli
相关标签:
7条回答
  • 2020-11-22 06:59

    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"');
    
    0 讨论(0)
  • 2020-11-22 07:03

    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
    
    0 讨论(0)
  • 2020-11-22 07:09

    For anyone who is still stumbling with this after using all of the possible MIME types listed in the question:

    I have found that iMacs tend to also throw a MIME type of "text/xls" for XLS Excel files, hope this helps.

    0 讨论(0)
  • 2020-11-22 07:15

    You should always use below MIME type if you want to serve excel file in xlsx format

    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet 
    
    0 讨论(0)
  • 2020-11-22 07:16

    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
    
    0 讨论(0)
  • 2020-11-22 07:18

    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!

    0 讨论(0)
提交回复
热议问题