本文介绍了如何在asp.net中将Repeater导出到Excel中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我在网页上有一个转发器,并且导出编码在它下面给出但是它没有导出到excel。
Hi All,
I have a repeater in web page and did Exporting coding give below it but it is not exporting into excel .
Response.Clear();
Response.AddHeader("content-disposition",
string.Format("attachment;filename={0}.xls", fileName));
Response.Charset = "";
Response.ContentType = "application/vnd.xls";
StringWriter stringWrite = new StringWriter();
HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
MISRepeater.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
请帮助我,如果我错了或提供任何其他解决方案,它在gridview中运行良好。
感谢你
mohd。 wasif
Please help me if i am wrong or provide any other solution it's running well in gridview.
thanking you
mohd. wasif
推荐答案
protected void Button1_Click(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=finance.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
// Your Repeater Name Mine is "Rep"
rep.RenderControl(htmlWrite);
Response.Write("<table>");
Response.Write(stringWrite.ToString());
Response.Write("</table>");
Response.End();
}
这篇关于如何在asp.net中将Repeater导出到Excel中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!