老周的胡..

世事无绝对,另有新情趣。

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

 以下的代码是将WEB窗体中显示的内容导出到WORD文档
 
   Response.Clear();
      Response.Buffer= true;
      Response.Charset="utf-8"; 

      Response.AppendHeader("Content-    Disposition","attachment;filename=FileFlow.doc");
      Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8");  
      Response.ContentType = "application/ms-word";
      this.EnableViewState = false; 

      System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
      System.Web.UI.HtmlTextWriter oHtmlTextWriter = new   System.Web.UI.HtmlTextWriter(oStringWriter);  
     
      this.RenderControl(oHtmlTextWriter);   
      Response.Write(oStringWriter.ToString());
      Response.End(); 

posted on 2006-05-25 10:36  老周  阅读(568)  评论(0)    收藏  举报