输出当前页面到word 
要求:输出时将页面上的控件用本身的值替换 
如: <div style="width: 100%; height: 380px; overflow: auto"> 
                                <p align="center"> 
                                    <b>关于 <input type='text' style='width: 100px; border: none; border-bottom: solid 1px'>党(总)支部增补委员的请示 </b> </p> 
                                <p> 
                                  <select width=90> <option>公司党委 </option> <option>机关党总支 </option> </select>: 
                                </p> 
                                <p> 
                                    &nbsp;&nbsp; &nbsp;&nbsp; 鉴于  <select width=90> <option>工作需要 </option> <option>本届委员会任期届满 </option> </select> 
                                        ,进行增补委员的时机已经成熟,根据《中国共产党章程》的有关规定和  <select width=90> <option>公司党委文件精神 </option> <option>机关党总支意见 </option> </select>,决定增补——————等——同志为党(总)支部委员: </p> 
                              
                                <p align="left"> 
                              简历介绍如下: </p> 
</div> 将input控件和select控件替换掉。。只显示他们的输入值或选择项的text文本

解决方案 »

  1.   

    大概就是是要手动去除HTML中WORD无法识别的标签,然后以文件流的方式输出到WORD文档……当然具体代码我不知道如何写……
      

  2.   

     StreamReader my = new StreamReader(Server.MapPath("Default.aspx"));        string name = my.ReadToEnd();
            my.Close();
            StreamWriter myw = new StreamWriter(Server.MapPath("myw.doc"));
            
            myw.Write(name);
            myw.Close();LZ要自己解决编码的问题。
      

  3.   

    文件的读取写入都是数据流的形式,只有对.doc中文件替换了吧?
      

  4.   

    Request.Form[""];   怎么做。。能说的具体一点吗?
    word我已经导出来了
    要保证格式不变
      

  5.   

    Response.Clear(); 
          Response.Buffer= true; 
          Response.Charset="utf-8";       Response.AppendHeader("Content-    Disposition","attachment;filename=1.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(); 
    通过正则替换相关元素
      

  6.   

    string html = "<div>xxx</div>"
    html = Regex.Replace(html, "<[^>]+>", "");
    可以替换掉html标签
      

  7.   


    wuyq11 :
    Response.Clear(); 
          Response.Buffer= true; 
          Response.Charset="utf-8";        Response.AppendHeader("Content-    Disposition","attachment;filename=1.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();  
    通过正则替换相关元素我也是这种方式输出的。但是有个问题。正则如何替换。。能不能重写Control输出事件实现替换。。能做到吗?