Excel警告:文件格式与文件扩展名指定的格式不同

时间:2022-10-24 10:11:53

In my application, I am using apache POI 3.8 for report generation.

在我的应用程序中,我使用apache POI 3.8生成报告。

The system is working fine and its generating report in xls format.

系统工作正常,并以xls格式生成报告。

But when I open the xls file it given me warning before opening the file.

但是当我打开xls文件时,它会在打开文件之前给出警告。

Excel警告:文件格式与文件扩展名指定的格式不同

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.

但问题仍然存在。在这两种情况下如果我使用文件扩展名为“.xlsx”,那么它没有给出任何警告并且工作正常。

So can anyone suggest me why it gives warning for MS-Excel 2003 format ??

所以有人可以建议我为什么它会给MS-Excel 2003格式发出警告?

1 个解决方案

#1


8  

Apache POI uses HSSFWorkbook object for creating xls files and XSSFWorkbook object for xlsx files. Please check what object you used for creating xls.

Apache POI使用HSSFWorkbook对象为xlsx文件创建xls文件和XSSFWorkbook对象。请检查您用于创建xls的对象。

http://poi.apache.org/spreadsheet/quick-guide.html

http://poi.apache.org/spreadsheet/quick-guide.html

#1


8  

Apache POI uses HSSFWorkbook object for creating xls files and XSSFWorkbook object for xlsx files. Please check what object you used for creating xls.

Apache POI使用HSSFWorkbook对象为xlsx文件创建xls文件和XSSFWorkbook对象。请检查您用于创建xls的对象。

http://poi.apache.org/spreadsheet/quick-guide.html

http://poi.apache.org/spreadsheet/quick-guide.html