Manish Gadhock
Manish Gadhock

Reputation: 163

firefox detecting xlsx file as 97-2003 workbook(.xls) which saves the file as example.xlsx.xls

I am saving the xlsx file in firefox and the browser recognized it as 97-2003 workbook(.xls)

When i save my file

when I open the xls file it generates pop-up window

enter image description here

I have also tried this in the different machine in which it works fine in firefox where it detects it as Microsoft Office Excel Worksheet( which is for .xlsx)

enter image description here

I have also tried to open the browser preferences where I found in application tab of second machine microsoft excel worksheet in content type list

enter image description here

but in the first machine content-type list contains only microsoft excel 97-2003 worksheet. Is that the issue ? If yes, please guide how to fix that ?

Also want to update on this : First Machine Firefox Version is 39.0.3 Second Machine Firefox Version is 40.0.2

Edit :

In the code , I am using PHPExcel library for generating excel file where I am passing application/vnd.ms-excel as mime type in the header.

header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=\"example.xlsx\"");
header("Cache-Control: max-age=0");

If this is the issue,then please let me know ?

Upvotes: 4

Views: 2461

Answers (1)

Mark Baker
Mark Baker

Reputation: 212452

application/vnd.ms-excel is the mime/content type for a BIFF format .xls file.

The mime/content type for an OfficeOpenXML format .xlsx file is application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

Firefox is only interpreting the content type that you send in your headers, and this doesn't match with the extension or format of the file that you're sending.

For reference with PHPExcel

  • OfficeOpenXML format files

    • Excel2007 Writer
    • .xlsx Extension
    • application/vnd.openxmlformats-officedocument.spreadsheetml.sheet content/mime type
  • BIFF format files

    • Excel5 Writer
    • .xls Extension
    • application/vnd.ms-excel content/mime type

Upvotes: 6

Related Questions