现在有一个word文档.doc,怎样用asp.net(c#)将其转换为.htm或者.html网页文档格式(包括图片等)?请大家帮忙!谢谢啊!!

解决方案 »

  1.   

    需要这个Microsoft.HtmlTrans.Interface.dll组件所以需下载htmlview (MS的)
    你就这样搜一下就有了
    若找不到,我可以找一个给你
    最近做了一个转成mht的
      

  2.   

    直接调用WordApplication打开该DOC文档,再另存为html格式
      

  3.   

    //打开Word文档再存为html
    using WordApp = Microsoft.Office.Interop.Word;
    private void tranhtml()
            {
                object missingValue = Type.Missing;
                WordApp._Application wapp = new WordApp.Application();
                object openfile = "E:\\documents\\first_love.doc";
                WordApp._Document doc = wapp.Documents.Open(ref openfile, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue);
                
                //doc.Path = "E:\\documents\\first_love.doc";
                object fn = "c:\\1.htm";
                object st = WordApp.WdSaveFormat.wdFormatHTML;
                
                doc.SaveAs(ref fn, ref st, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue);
                doc.Close(ref missingValue, ref missingValue, ref missingValue);
                wapp.Quit(ref missingValue, ref missingValue, ref missingValue);
            }
      

  4.   

    呵呵, liujiayu10,不知道了吧,:-》 主要是批量转换,要是只转换几个,建议用word手工转换
      

  5.   

    存为html后会不会产生苦干的垃圾代码?
      

  6.   

    using WordApp = Microsoft.Office.Interop.Word; 这个是什么?不能引用,是否需要下载?
      

  7.   

    siugwan(开怀)的程序调试不成功哦~~
      

  8.   

    你要添加com引用啊,把Microsoft Word 11.0 Object Library引用进去啊
    (我用的是Word 2003)
      

  9.   

    错误为:"重载"OPEN方法为获取16参数"",错误行:wapp.Documents.Open(ref openfile, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue);
      

  10.   

    具体代码:using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using WordApp = Microsoft.Office.Interop.Word;namespace bjj.ProjectTest
    {
    /// <summary>
    /// DocToHtml 的摘要说明。
    /// </summary>
    public class DocToHtml : System.Web.UI.Page
    {
    private void Page_Load(object sender, System.EventArgs e)
    {
    tranhtml();
    // 在此处放置用户代码以初始化页面
    } #region Web 窗体设计器生成的代码
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion
    private void tranhtml()
         {
    object missingValue = Type.Missing;
    WordApp._Application wapp = new WordApp.ApplicationClass();;
    object openfile = "E:\\mytest.doc";
    WordApp._Document doc = wapp.Documents.Open(ref openfile, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue);
                
    //doc.Path = "E:\\documents\\first_love.doc";
    object fn = "c:\\1.htm";
    object st = WordApp.WdSaveFormat.wdFormatHTML;
                
    doc.SaveAs(ref fn, ref st, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue);
    doc.Close(ref missingValue, ref missingValue, ref missingValue);
    wapp.Quit(ref missingValue, ref missingValue, ref missingValue);
    } //打开Word文档再存为html
    }}
      

  11.   

    你的是不是Word 2003 啊?
    不同版本的OFFICE调用的函数是有些区别的.