当前位置: 代码迷 >> ASP.NET >> 怎么将html里的内容写入word
  详细解决方案

怎么将html里的内容写入word

热度:8632   发布时间:2013-02-25 00:00:00.0
如何将html里的内容写入word?
如何将html里的内容写入word?请高手给点思路
------最佳解决方案--------------------------------------------------------
参考

http://blog.csdn.net/educast/article/details/4420111 
里面的SaveOrOutData方法

------其他解决方案--------------------------------------------------------
//重写此事件,防止从gridview导出到excel时报错。
     public override void VerifyRenderingInServerForm(Control control)
     {
         //base.VerifyRenderingInServerForm(control);
     }
     public void Export(string FileType, string FileName)
     {
         Response.Clear();
         Response.Charset = "GB2312";
         Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
         Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8).ToString()); 
         Response.ContentType = FileType;
         this.EnableViewState = false;
         System.IO.StringWriter sw = new System.IO.StringWriter();
         HtmlTextWriter hw = new HtmlTextWriter(sw);
         Repeater1.RenderControl(hw);
         string str = hw.InnerWriter.ToString();
         Response.Write(sw.ToString());
         Response.End();
     }



调用:
 Export("application/ms-word", "word.doc");
------其他解决方案--------------------------------------------------------
最简单的方法改后缀名,word打开时会自动转换的
  相关解决方案