这个问题在这里已有答案:
我希望网站上的excel文件在点击时在Excel中打开,不会保存在桌面上,或者在浏览器中嵌入打开等等 . 现在显然这一切都取决于每个用户的所有配置,但最好的内容类型是什么和其他设置,以实现大部分时间?
对于BIFF .xls文件
application/vnd.ms-excel
对于Excel2007及更高版本的.xlsx文件
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
vnd class /特定供应商
vnd class
http://en.wikipedia.org/wiki/Microsoft_Excel#File_formats
请记住,当您尝试上传已打开的文件时, file.getContentType 也可以输出 application/octet-stream 而不是必需的 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet .
file.getContentType
3 回答
对于BIFF .xls文件
对于Excel2007及更高版本的.xlsx文件
vnd class
/特定供应商http://en.wikipedia.org/wiki/Microsoft_Excel#File_formats
请记住,当您尝试上传已打开的文件时,
file.getContentType
也可以输出 application/octet-stream 而不是必需的 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet .