gridview导出到excel
导出按钮事件
代码
Response.Clear(); Response.Buffer=true; Response.Charset="GB2312"; Response.AppendHeader("Content-Disposition","attachment;filename=FileName.xls"); Response.ContentEncoding=System.Text.Encoding.UTF7; Response.ContentType="application/ms-excel"; System.IO.StringWriter oStringWriter=new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter oHtmlTextWriter=new System.Web.UI.HtmlTextWriter(oStringWriter); this.控件名.AllowPaging=false; 控间名.AutoGenerateEditButton=false; 控件名.AutoGenerateDeleteButton=false; this.控件名.RenderControl(oHtmlTextWriter); Response.Output.Write(oStringWriter.ToString()); Response.Flush(); Response.End();
posted on 2012-09-07 11:03 wenzhao168 阅读(106) 评论(0) 编辑 收藏 举报