将gridview数据导出到ecxel的代码 [英] Code to export gridview data to ecxel
本文介绍了将gridview数据导出到ecxel的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
需要按钮代码将gridview数据导出到ecxel,pls帮助
need button code to export gridview data to ecxel,pls help
推荐答案
使用以下代码
use below code
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Buffer = true;
Response.ContentType = "application/vnd.xls";
Response.Charset = "";
EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
ClearControls(grd);
GridView1.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
http://www.codeproject.com /KB/aspnet/GridViewFaqs.aspx#heading0010 [ ^ ]应该会有所帮助.
http://www.codeproject.com/KB/aspnet/GridViewFaqs.aspx#heading0010[^] should help.
搜索引擎是查找有关此类问题的详细信息的最佳媒体之一.
必应搜索结果
Search Engines are one of the best media to find details around this kind of Questions.
Google Search Result
Bing Search Result
这篇关于将gridview数据导出到ecxel的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文