如何将gridview数据导出为ex​​cel。 [英] How to export gridview data to excel.

查看:98
本文介绍了如何将gridview数据导出为ex​​cel。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





如何将网格视图数据导出到excel,



我试过这个,



Hi,

How to export grid view data to excel,

I tried this,

Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Customers.xls"));
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gvDetails.AllowPaging = false;
BindGridview();
//Change the Header Row back to white color
gvDetails.HeaderRow.Style.Add("background-color", "#FFFFFF");
//Applying stlye to gridview header cells
for (int i = 0; i < gvDetails.HeaderRow.Cells.Count; i++)
{
gvDetails.HeaderRow.Cells[i].Style.Add("background-color", "#df5015");
}
gvDetails.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();







但问题是,即时获取链接Excel标题文字,我不想要这个,

请建议我........




But the problem is, im getting Links to Excel header text, io dont want this,
please suggest me........

推荐答案

检查这个链接它会帮助你。



将Gridview数据导出到ASP.NET中的Excel [ ^ ]



http://www.aspsnippets.com/Articles/Export-GridView-to- Excel-in-ASPNet-with-Formatting-using-C-and-VBNet.aspx [ ^ ]
Check this link it will help u.

Export Gridview Data to Excel in ASP.NET[^]

http://www.aspsnippets.com/Articles/Export-GridView-to-Excel-in-ASPNet-with-Formatting-using-C-and-VBNet.aspx[^]


这篇关于如何将gridview数据导出为ex​​cel。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆