Windows阻止从Internet上下载的.XLS文件的内容是HTML [英] Windows blocking .XLS files downloaded from the Internet where the contents are HTML

查看:133
本文介绍了Windows阻止从Internet上下载的.XLS文件的内容是HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个遗留的ASP.NET应用程序,允许用户将GridView控件的内容导出到Excel。这是使用此技术

We have a legacy ASP.NET application that allows users to export the contents of a GridView control to Excel. This was achieved using this technique.

最近,用户抱怨说他们无法在Excel中打开他们下载的文件。我自己尝试过,发现Windows正在阻止下载的文件,阻止Excel打开它。

Recently, users have complained that they are unable to open their downloaded files in Excel. I tried it myself and discovered that Windows was blocking the downloaded file, preventing Excel from opening it.

看起来Windows现在看到从网页创建的XLS文件内容为嫌疑人这是最近Windows更新的结果吗?这是从不推荐网页创建Excel文件的技巧吗?

It looks like Windows now regards XLS files that have been created from web page content as suspect. Is this the result of a recent Windows update? And is this technique of creating Excel files from web pages not recommended?

推荐答案

更正,最近的更新有破坏了此行为(感谢 Nikki9696 的文章)。

Correct, recent updates have broken this behavior (thanks to Nikki9696 for the article).

列出了三种解决方法:


  1. 停止使用伪装成XLS的HTML文件

  2. 取消阻止访问单个文件(客户端解决方案)

  3. 或将文件的源添加到Excel中的受信任位置列表(客户端解决方案)

最好的事情是#1。您不应该将具有一种数据类型的文件另存为其他文件类型。它总是为用户生成一个警告。否则知道如何打开XLS文件(例如Office for iPad)的Office客户端将会出现伪装成XLS的HTML文件。

The best thing to do is #1. You should not be serving files with one data type as another file type. It's always generated a warning for users. Many Office clients that otherwise know how to open XLS files (such as Office for iPad) will choke when presented with an HTML file masquerading as XLS.

而是使用库生成一个现代XLSX文件(可以由Office 2003和更高版本打开)。有几种解决方案,例如 EPPlus NPOI 打开XML SDK

Instead, use a library to generate a modern XLSX file (which can be opened by Office 2003 and newer). There are several solutions such as EPPlus, NPOI, and Open XML SDK.

将来,请小心使用受支持的解决方案,而不是拼凑一个黑客,如提供错误扩展名的文件。

In the future, be careful to use supported solutions rather than cobbling together a hack like serving a file with the wrong extension.

这篇关于Windows阻止从Internet上下载的.XLS文件的内容是HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆