我想把显示的WEB页面上面的DATGRIDE以及几个LABEL控件的值通过导出EXCEL打印出来,用了以下代码,测试可以通过!可是导出的EXCEL 中有button 控件,还有不想打的textbox控件,也留在EXCEL中了,请问怎么修改下面的代码呢???请帮帮忙!private void Button1_Click(object sender, System.EventArgs e)
{
this.Button1 .Dispose ();
Response.ContentType = "application/vnd.ms-excel";

Response.Charset = ""; //关闭 ViewState
EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();//将信息写入字符串
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);//在WEB窗体页上写出一系列连续的HTML特定字符和文本。
//此类提供ASP.NET服务器控件在将HTML内容呈现给客户端时所使用的格式化功能
//获取control的HTML
this.DataGrid1.RenderControl (hw);//将DATAGRID中的内容输出到HtmlTextWriter对象中
// 把HTML写回浏览器

Response.Write(tw.ToString());
Response.End();
}