导出GridView到Excel
来源:互联网 发布:netstumbler同类软件 编辑:程序博客网 时间:2024/05/18 01:08
导出GridView到Excel中的关键之处
用法: ToExcel(GVStaff, TextBox1.Text);
public static void ToExcel(System.Web.UI.Control ctl,string FileName)
{
HttpContext.Current.Response.Charset ="UTF-8";
HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType ="application/ms-excel";
HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename="+""+FileName+".xls");
ctl.Page.EnableViewState =false;
System.IO.StringWriter tw = new System.IO.StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}
必须有下面这句!否则不会通过!
public override void VerifyRenderingInServerForm(Control control)
{
// Confirms that an HtmlForm control is rendered for
}
用法: ToExcel(GVStaff, TextBox1.Text);
public static void ToExcel(System.Web.UI.Control ctl,string FileName)
{
HttpContext.Current.Response.Charset ="UTF-8";
HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType ="application/ms-excel";
HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename="+""+FileName+".xls");
ctl.Page.EnableViewState =false;
System.IO.StringWriter tw = new System.IO.StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}
必须有下面这句!否则不会通过!
public override void VerifyRenderingInServerForm(Control control)
{
// Confirms that an HtmlForm control is rendered for
}
- GridView导出到Excel
- GridView导出到Excel
- GridView导出到Excel
- GridView导出到Excel
- gridview 导出到excel
- 导出GridView到Excel
- 导出GridView到Excel
- GridView导出到Excel
- GridView导出到Excel
- GridView 导出到EXCEL
- GridView导出到Excel
- GridView 导出到 Excel
- Gridview导出到excel
- GridView 导出到excel
- 导出Gridview到excel
- GridView导出到Excel
- GridView导出到Excel
- GridView导出到excel
- 亲历裁员1-感恩节不感恩
- 网易就是评论最好看
- 常用WebService服务汇总
- 年底了,小偷猖狂,请注意安全!
- OMG组织发布SOA语言SoaML
- 导出GridView到Excel
- 长风联盟SOA套件发布与应用大会即将召开
- ASP.NET2.0中Gridview中数据操作技巧
- 关于 windows2008 资源管理器打开文件夹缓慢的问题
- java桌面 第二章继承和多态
- Benefits of Agile Adoption - from a manager
- java桌面 第三章包 接口 抽象类
- 工业企业最基本的生产经营活动
- 引入敏捷但不行之过甚