使用 Office 2007/2010 打开 .xls 文件时收到扩展检查(强化)警报
我正在开发一个基于 struts 的 Web 应用程序。在该应用程序中,我们从 Jsp 生成并下载 xls 文件。 在Jsp文件和web.xml中,我将内容类型设置为“application/vnd.ms-excel”,
看来jsp页面生成的xls文件不是真正的excel文件,而是MS可以理解的文本格式优秀。因此,Excel 打开文件并显示类似于 MS Excel 保存的 Excel 文件的输出。由于较新版本的 MS Office 2007/2010 会检查文件扩展名和文件内的内容,因此它们会发出文件格式与内容不匹配的警告。
要摆脱警告,我如何确保生成的 xls 是真正的 Office excel 文件。
请帮忙。
I am working on a struts based web application. In that application, we generate and download xls file from Jsp.
In Jsp file and web.xml, I have set the content-type as "application/vnd.ms-excel"
it seems xls files generated by the jsp pages are not real excel files, but a text format that is understood by the MS Excel. Hence excel opens the files and displays the output similar to excel files saved by MS Excel. Since newer versions of MS Office 2007/2010 checks the file extension and the content inside the file, they issue a warning that the file format does not match with the content.
To get rid of the warning how can i ensure that the generated xls is real office excel file .
Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于未来可能需要这个的读者......
即使您的 Excel 文件是“正确的”,只要其结构与扩展名不正确匹配,Excel 无论如何都会抱怨。因此,如果您另存为 .XLS,它会看到经典的 Excel 文件。
您收到的弹出窗口是由于 Office 2007 中的新安全功能(称为“扩展强化”)所致,您可以根据需要禁用它 - 可以在注册表中手动禁用它,也可以将补丁保存到 .REG 文件中并将其共享给您 将下面的这两行
保存到 GiveItSomeName.reg 文件中,然后您可以通过电子邮件发送给您的客户并告诉他们执行它。
For future readers who might need this...
Excel will complain anyway, even if your excel file is 'correct', as long as its structure doesn't properly match the extension. So if you're saving as an .XLS, it expects to see the classic excel file.
The popup you are getting is because of the new security feature in Office 2007, called Extension Hardening and you can disable it if you want - either manually in the registry, or you can save the patch to a .REG file and share it to you clients etc.
Save those 2 line below into a GiveItSomeName.reg file, which you can then email to your clients and tell them to execute it.