php - firefox 将 xlsx 文件检测为 97-2003 工作簿 (.xls),将文件另存为 example.xlsx.xls

标签 php firefox phpexcel

我将 xlsx 文件保存在 firefox 中,浏览器将其识别为 97-2003 工作簿 (.xls)

When i save my file

当我打开 xls 文件时,它会生成弹出窗口

enter image description here

我也在不同的机器上尝试过这个,它在 firefox 中工作正常,它检测到它作为 Microsoft Office Excel 工作表(用于 .xlsx)

enter image description here

我还尝试打开浏览器首选项,我在内容类型列表中的第二台机器 Microsoft Excel 工作表的应用程序选项卡中找到

enter image description here

但在第一台机器的内容类型列表中只包含 microsoft excel 97-2003 工作表。是这个问题吗?如果是,请指导如何解决?

还想更新这个: First Machine Firefox 版本是 39.0.3 第二台机器 Firefox 版本是 40.0.2

编辑:

在代码中,我使用 PHPExcel 库生成 excel 文件,我在标题中将 application/vnd.ms-excel 作为 mime 类型传递。

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

如果这是问题所在,请告诉我?

最佳答案

application/vnd.ms-excelBIFF 格式 .xls 文件的 mime/内容类型。

OfficeOpenXML 格式 .xlsx 文件的 mime/内容类型是 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

Firefox 仅解释您在 header 中发送的内容类型,这与您发送的文件的扩展名或格式不匹配。

供PHPExcel引用

  • OfficeOpenXML 格式文件

    • Excel2007 编写器
    • .xlsx 扩展名
    • application/vnd.openxmlformats-officedocument.spreadsheetml.sheet 内容/mime 类型
  • BIFF格式文件

    • Excel5 编写器
    • .xls 扩展名
    • application/vnd.ms-excel 内容/mime 类型

关于php - firefox 将 xlsx 文件检测为 97-2003 工作簿 (.xls),将文件另存为 example.xlsx.xls,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32090311/

相关文章:

php - 为 phpDocumentor 表示数组数据类型的正确方法?

php - 如何压缩整个目录并使用php下载

jQuery .each() 方法在 Firefox 中不起作用

PHP excel - 数据循环?

php - PHP 5.4.10 版本对异常的态度有变化吗?

javascript - 从动态表单插入多个值

php - 使用 PHPExcel_RichText() 不会显示换行符

php - 使用 phpexcel 在所有打印页面中设置页脚

asp.net - 在回发上保持滚动位置不适用于 Firefox

javascript - 火狐 "window.event is undefined"错误