日期:2014-05-16  浏览次数:20559 次

通过response.ContentType = "application/ms-excel";方法把控件内容倒出到Excel的问题
通过response.ContentType = "application/ms-excel";方法把控件内容倒出到Excel后,打开时提示文件类型和扩展名不匹配,该如何解决该问题呢
xlsx是不是开放标准了,能否导出真正的excel文件呢?
response.AddHeader(...
response.ContentType = "application/ms-excel";
HtmlTextWriter hw = new HtmlTextWriter(swContent);
repeater1.RenderControl(hw);
------解决方案--------------------
可以生成真正的xlsx格式的文件。你可以使用Open XML SDK来生成
http://msdn.microsoft.com/zh-cn/library/bb448854.aspx

例子
http://blogs.msdn.com/b/chrisrae/archive/2011/08/18/creating-a-simple-xlsx-from-scratch-using-the-open-xml-sdk.aspx?Redirected=true

或者使用npoi
https://npoi.codeplex.com/