下面是我的导出到excel代码,不导出前台中隐藏的列。
Gv_jh.AllowPaging = false;
BindGridView(sSearch);
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
Response.ContentEncoding = Encoding.UTF8;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = "application/ms-excel";
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
grid.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
Gv_jh.AllowPaging = true;
BindGridView(sSearch);