点滴积累,融会贯通

-----喜欢一切有兴趣的东西

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  {
   Response.Clear();
   Response.Buffer= true;
   
   Response.AppendHeader("Content-Disposition","attachment;filename=Borrow.xls");
   Response.ContentEncoding=System.Text.Encoding.GetEncoding("gb2312");

   Response.ContentType = "application/ms-excel";
   this.EnableViewState = false;
   
   System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",true);
   System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
   System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); 
   
   Table3.RenderControl(oHtmlTextWriter);

   Response.Charset="gb2312";
   Response.Write(oStringWriter.ToString());
   Response.End();
  }

红色为导出文件名和要导出页面中的table

posted on 2006-02-06 15:20  小寒  阅读(617)  评论(2编辑  收藏  举报