Sub*_*ian 340 excel mime content-type
MS Excel具有以下观察到的MIME类型:
application/vnd.ms-excel (官方)application/msexcelapplication/x-msexcelapplication/x-ms-excelapplication/x-excelapplication/x-dos_ms_excelapplication/xlsapplication/x-xlsapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet (XLSX)是否有任何一种适用于所有版本的类型?如果没有,我们是否需要response.setContentType()单独设置这些mime类型中的每一个?
此外,我们在应用程序中使用文件流来显示文档(不仅仅是excel - 任何类型的文档).这样做,如果用户选择保存文件,我们如何保留文件名 - 目前,呈现文件的servlet名称显示为默认名称.
jbo*_*chi 334
我相信Excel文件的标准MIME类型是application/vnd.ms-excel.
关于文档的名称,您应该在响应中设置以下标题:
header('Content-Disposition: attachment; filename="name_of_excel_file.xls"');
Run Code Online (Sandbox Code Playgroud)
Kar*_*ode 159
我在这里唤醒了一个旧线程,但我觉得有必要添加"新".xlsx格式.
根据http://filext.com/file-extension/XLSX,.xlsx的扩展名是application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.在检查mime类型时包含它可能是个好主意!
Siv*_*mar 38
如果要以xlsx格式提供excel文件,则应始终使用以下MIME类型
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Run Code Online (Sandbox Code Playgroud)
我从.NET代码设置MIME类型如下 -
File(generatedFileName, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
Run Code Online (Sandbox Code Playgroud)
我的应用程序使用OpenXML SDK生成excel.这种MIME类型有效 -
vnd.openxmlformats-officedocument.spreadsheetml.sheet
Run Code Online (Sandbox Code Playgroud)
For .xls use the following content-type
application/vnd.ms-excel
Run Code Online (Sandbox Code Playgroud)
For Excel 2007 version and above .xlsx files format
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Run Code Online (Sandbox Code Playgroud)