日期:2014-05-17  浏览次数:20379 次

GirdView数据导出问题
GirdView绑定SqlDataScourse数据源

想导出数据到Excel中,不是用流直接下载的,就是在服务器要保留所导出的excel

------解决方案--------------------
本地导出,然后将execel文件上传到服务器
------解决方案--------------------
保存也好处理啊

System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.GridView1.DataSourceId = "SqlDataScourse1";
this.GridView1.DataBind()
this.GridView1.RenderControl(oHtmlTextWriter);
File.WriteAllText(Server.Mappath("~/xxx.xls"),oStringWriter.ToString());