Excel 警告:文件格式与文件扩展名指定的格式不同 [英] Excel warning : File is in different format than specified by the file extension
问题描述
在我的应用程序中,我使用 apache POI 3.8 来生成报告.
系统运行良好,生成的报告为 xls 格式.
但是当我打开 xls 文件时,它在打开文件之前给了我警告.
这是我使用的响应类型...
response.setHeader("Content-Type", "application/vnd.ms-excel");response.setHeader("Content-Disposition","attachment; filename="+xlsFileName+".xls");
我也试过...
response.setHeader("Content-Disposition","attachment; filename="+xlsFileName+".xls");response.setHeader("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
但是问题依然存在.在这两种情况下,如果我使用文件扩展名作为.xlsx",那么它不会发出任何警告并且工作正常.
那么谁能告诉我为什么它会为 MS-Excel 2003 格式发出警告??
Apache POI 使用 HSSFWorkbook 对象来创建 xls 文件和 XSSFWorkbook 对象来创建 xlsx 文件.请检查您用于创建 xls 的对象.
http://poi.apache.org/spreadsheet/quick-guide.html>
In my application, I am using apache POI 3.8 for report generation.
The system is working fine and its generating report in xls format.
But when I open the xls file it given me warning before opening the file.
And here is the response type I am using...
response.setHeader("Content-Type", "application/vnd.ms-excel");
response.setHeader("Content-Disposition","attachment; filename="+xlsFileName+".xls");
I also tried with ...
response.setHeader("Content-Disposition","attachment; filename="+xlsFileName+".xls");
response.setHeader("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
But the problem still exist. Here in both of the case If I use file extension as ".xlsx" then Its not giving any warning and works fine.
So can anyone suggest me why it gives warning for MS-Excel 2003 format ??
Apache POI uses HSSFWorkbook object for creating xls files and XSSFWorkbook object for xlsx files. Please check what object you used for creating xls.
http://poi.apache.org/spreadsheet/quick-guide.html
这篇关于Excel 警告:文件格式与文件扩展名指定的格式不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!