我对这个问题做了一些相当深入的搜索,但没有运气。在过去的几天里,从 HTML 到 XLS 的输出似乎已停止在我支持的许多旧版(阅读:经典 ASP)系统上运行。我已经能够在多个服务器、从 Office 2010 到 Office 2016 的多个独立源代码上重现此内容。我已经查看了我能想到的所有内容,但没有成功,所以我很想知道是否有我可能忽略的内容。我开始认为这可能是一个糟糕的 Office 更新造成的。
有效且已运行多年的示例:
<%
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment;filename=TestExcel.xls"
%>
<html>
<body>
<table>
<thead>
<tr>
<th>column 1 header</th>
<th>column 2 header</th>
</tr>
</thead>
<tbody>
<tr>
<td>column 1 value</td>
<td>column 2 value</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Footer 1</td>
<td>Footer 2</td>
</tr>
</tfoot>
</table>
</body>
</html>
奇怪的是,XLS 文件实际上已创建,但打开时 Excel 会打开,但文件不存在。
更奇怪的是,当您使用某些文本编辑器(例如记事本)打开 XLS 文件并只需“文件”->“另存为”时,它就可以毫无问题地打开。
该问题与 2016 年 7 月 12 日发布的 Microsoft Excel 安全更新 KB3115262 有关。可以在 Microsoft 安全公告 MS16-088 - 严重中找到安全更新信息。
我找到了三种解决方法(按照我的偏好顺序):
- 不要单击“打开”,而是保存文件然后打开它
- 在 Excel 信任中心 > 信任中心设置 > 受保护的视图中,取消选中顶部的两个选项。这可能是不安全的。
- 卸载安全更新。
以下是有关该问题的几个链接,供进一步阅读。https://social.technet.microsoft.com/Forums/en-US/d2d84793-9920-45e3-baef-5027a4ac1ae0/kb3170008-for-office-2016-breaks-功能性-ms16088?forum=officeitpro https://social.technet.microsoft.com/Forums/en-US/d2d84793-9920-45e3-baef-5027a4ac1ae0/kb3170008-for-office-2016-breaks-functionality-ms16088?forum=officeitpro
https://technet.microsoft.com/library/security/MS16-088 https://technet.microsoft.com/library/security/MS16-088
https://salesforce.stackexchange.com/questions/131404/end-user-cannot-open-a-xls-report-exported-from-salesforce https://salesforce.stackexchange.com/questions/131404/end-user-cannot-open-a-xls-report-exported-from-salesforce
将 HTML 表导出到 Excel - 无法在 Office 2010 中打开 https://stackoverflow.com/questions/38377796/export-html-table-to-excel-doesnt-open-in-office-2010
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)