如何在asp.net中将gridview导出为excel [英] How to export the gridview to excel in asp.net
本文介绍了如何在asp.net中将gridview导出为excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友们。我对gridview的要求在asp.net中表现出色。这里我在下面的代码中用导出按钮编写代码。
Hi friends. i have requirement on gridview to excel in asp.net . here i wrote code in export button in the following code.
Response.Clear();
Response.Buffer = true;
string filename = "GridViewExport_" + DateTime.Now.ToString() + ".xls";
Response.AddHeader("content-disposition", "attachment;filename=" + filename);
Response.Charset = "";
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
gvwReport.RenderControl(hw);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
如果我们要保存文件,空数据即将到来。 />
怎样才能执行此任务以使用标题颜色导出excel。
请帮助我。
高级谢谢。
if we want to save the file, empty data is coming.
how can do the this task to exporting in excel with header color.
please help me anyone.
advanced thanks.
推荐答案
使用SearchBox [ ^ ]位于此站点的右上角。在那里,你会发现成千上万的类似问题和答案。
Use SearchBox[^] on the top-right corner of this site. There you'll find thousands of similar questions with answers.
参考这个...
http://www.aspdotnet-suresh.com/2011/04/how-to-export-gridview- data-to-excel-or.html [ ^ ]
Refer this...
http://www.aspdotnet-suresh.com/2011/04/how-to-export-gridview-data-to-excel-or.html[^]
我做了同样的事情并发布在我的博客中。
只需点击此处 http://kishsharmasoftcode.blogspot.in/ [ ^ ]
对于任何查询评论。
希望帮助你。
谢谢,
i have done the same thing and posted in my blog.
just check here http://kishsharmasoftcode.blogspot.in/[^]
for any query comment on that.
Hope help you.
Thanks,
这篇关于如何在asp.net中将gridview导出为excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文