注册 登录
编程论坛 ASP.NET技术论坛

求怎么获取GridView里面的数据。。然后把数据导出为Excel或txt文档的ASP.NET源码

drychq 发布于 2008-11-26 08:48, 1575 次点击
求怎么获取GridView里面的数据。。然后把数据导出为Excel或txt文档的源码
有谁有这样的源码。。。
麻烦告诉我一下哦。。。谢谢 啊。。。
QQ:272021656
2 回复
#2
bygg2008-11-26 09:42
简单代码:

Response.ClearContent();
Response.AddHeader("content-disposition", "attachment; filename=ExportFile.xls");
Response.ContentType = "application/excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
GridView1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
#3
ruanjian21102008-11-26 09:51
1