可以参考以下语句: 都比较简单
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw);
int nCur = dgShow.CurrentPageIndex;
int nSize = dgShow.PageSize;
dgShow.AllowPaging = false;
BindData();
dgShow.Columns[7].Visible =false;
dgShow.RenderControl(hw);
dgShow.Columns[7].Visible =true;
//以下恢复分页
dgShow.AllowPaging = true;
dgShow.CurrentPageIndex = nCur;
dgShow.PageSize = nSize;
BindData();
Response.Write(sw.ToString());
Response.End();
温馨提示:答案为网友推荐,仅供参考