问题描述
在我的应用程序中,我使用apache POI 3.8生成报告。
In my application, I am using apache POI 3.8 for report generation.
系统正常工作,并以xls格式生成报告。
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.
这里是我正在使用的响应类型...
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");
我也尝试过...
response.setHeader("Content-Disposition","attachment; filename="+xlsFileName+".xls");
response.setHeader("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
但问题依然存在。在这两种情况下,如果我使用文件扩展名为.xlsx,那么它不会发出任何警告并且正常工作。
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.
所以有人可以建议我为什么会发出警告对于MS-Excel 2003格式?
So can anyone suggest me why it gives warning for MS-Excel 2003 format ??
推荐答案
Apache POI使用HSSFWorkbook对象为xlsx文件创建xls文件和XSSFWorkbook对象。请检查您用于创建xls的对象。
Apache POI uses HSSFWorkbook object for creating xls files and XSSFWorkbook object for xlsx files. Please check what object you used for creating xls.
这篇关于Excel警告:文件的格式与文件扩展名指定的格式不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!