编程论坛
注册
登录
编程论坛
→
ASP.NET技术论坛
求怎么获取GridView里面的数据。。然后把数据导出为Excel或txt文档的ASP.NET源码
drychq
发布于 2008-11-26 08:48, 1575 次点击
求怎么获取GridView里面的数据。。然后把数据导出为Excel或txt文档的源码
有谁有这样的源码。。。
麻烦告诉我一下哦。。。谢谢 啊。。。
QQ:272021656
2 回复
#2
bygg
2008-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
ruanjian2110
2008-11-26 09:51
https://bbs.bccn.net/viewthread.php?tid=213563&highlight=GridView%B5%BC%B3%F6
这里有很详细的介绍。。
1