有没有能把repeater中的数据直接生成excel的方法,不用再对数据库进行查询操作,就把当前页面已呈现的数据用excel导出来
解决方案 »
- asp.net接收消息??
- 请问 .NET Framework 3.5 SP1 和 .NET Framework 3.5 SP1(Full Package) 有啥区别?
- 关于CSS样式冲突的问题(表头和列固定的问题)
- 当点击删除按钮,confirm点取消还是会删除记录
- 后台管理广告
- C# 读取数据库棒定CheckBoxList中的问题
- 服务器被黑,查看服务器日志,发现如下问题
- vs2005下设置背景图片的奇怪问题!!!!
- 用C#生成的word document对象,怎么设定文件->页面设置->方向
- 应用程序webconfig冲突问题 在线等啊
- 关于Repeater里控件后台事件问题
- 一个简单问题
//导出到Excel用
public override void VerifyRenderingInServerForm(Control control)
{
}
/// <summary>
/// 导出数据到Excel
/// </summary>
public static void Export(Page pg, Repeater rep, string FileName)
{
pg.Response.Clear();
pg.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
pg.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
pg.Response.ContentEncoding = System.Text.Encoding.UTF8;
pg.Response.ContentType = "application/vnd.ms-excel";//设置输出文件类型为excel文件。
pg.Response.Charset = "";
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
rep.RenderControl(oHtmlTextWriter);
pg.Response.Output.Write(oStringWriter.ToString());
pg.Response.End();
}
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw);
this.Repeater1.RenderControl(hw); Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
Page.EnableViewState = false;
Response.AppendHeader("Content-Disposition", "attachment;filename=A.xls");
Response.Write("<html><head><meta http-equiv=Content-Type content=\"text/html; charset=GB2312\"><title></title></head><body><center>");
Response.Write(sw.ToString());
Response.Write("</center></body></html>");
Response.End();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw);
this.Repeater1.RenderControl(hw); Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
Page.EnableViewState = false;
Response.AppendHeader("Content-Disposition", "attachment;filename=A.xls");
Response.Write("<html><head><meta http-equiv=Content-Type content=\"text/html; charset=GB2312\"><title></title></head><body><center>");
Response.Write(sw.ToString());
Response.Write("</center></body></html>");
Response.End();