【发布时间】:2013-07-31 20:16:34
【问题描述】:
我必须在 excel 文件中写入一些数据。但是当我用这些数据打开 excel 文件时,会出现一个警告:
`The file you are trying to open, 'name.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a thrusted source before opening the file. Do you want to open the file now?`
我使用的是 Microsoft Excel 2010。 当我创建 HttpServletResponse 响应时,我正在添加有关标头和内容类型的此类信息:
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", some info about file name + ".xls\"");
我也尝试设置另一个标题,如:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet 和文件格式为.xlsx,但这也无济于事,因为警告仍然出现。
当我尝试使用 .csv 或 .xml 格式时,我没有这个问题,因为没有出现警告。是否有可能以编程方式消除此警告?
【问题讨论】:
-
你推送到服务器的内容是什么?
-
我想我不太清楚你的评论。什么意思?
-
您可以将您尝试写入的数据(内容)发布到 xls 吗?
-
我正在尝试在一个空文档上这样做
标签: java excel warnings office-2010 httpserver