加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – Excel XML的MIME类型(ASP.NET 3.5)

发布时间:2020-12-15 07:58:13 所属栏目:百科 来源:网络整理
导读:我使用CarlosAG-Dll为我创建一个 XML-Excel文件(在MemoryStream中). Response.ContentType = "application/vnd.ms-excel";Response.AppendHeader("content-disposition","myfile.xml");memory.WriteTo(Response.OutputStream); 我的问题是,我在客户端获得myf
我使用CarlosAG-Dll为我创建一个 XML-Excel文件(在MemoryStream中).
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("content-disposition","myfile.xml");
memory.WriteTo(Response.OutputStream);

我的问题是,我在客户端获得myfile.xls(IE)或myfile.xml.xls(FF),因此从excel获得恼人的安全警告.

我也尝试使用application / vnd.openxmlformats-officedocument.spreadsheetml.sheet(xlsx),但它甚至都不会打开.

所以我需要剪切.xml并将其作为vnd.ms-excel(如何?)发送或者采用另一种MIME类型(但是哪一个?).

编辑:我发现了一个错误描述here

我想知道这是否仍然是开放的,为什么?

解决方法

像这样使用
Response.ContentType = "application/vnd.ms-excel";

Response.AppendHeader("content-disposition","attachment; filename=myfile.xls");

对于Excel 2007及更高版本,MIME类型不同

Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

Response.AppendHeader("content-disposition","attachment; filename=myfile.xlsx");

请参阅MIME类型列表

Office 2007 File Format MIME Types

编辑:

If the content is not a native Excel file format,but is instead a
text based format (such as CSV,TXT,XML),then the web site can add
the following HTTP header to their GET response to tell IE to use an
alternate name,and in the name you can set the extension to the right
content type:

06002

有关详细信息,请参阅this link

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读