Asp.net 中将 Word 文件转换成 HTML 的方法
本文所述为一个 Asp.net 实现将 Word 转换为 HTML 的功
能,其关键代码如下:
//存放 word 文件的完整路径
string wordPath =
Server.MapPath("/word/test.doc");
//存放 html 文件的完整路径
string htmlPath =
Server.MapPath("/html/test.html");
//上传 word 文件, 由于只是做示例,在这里不多做文
件类型、大小、格式以及是否存在的判断
FileUpload1.SaveAs(wordPath);
#region 文件格式转换
//请引用 Microsoft.Office.Interop.Word
ApplicationClass word = new ApplicationClass();
Type wordType = word.GetType();
Documents docs = word.Documents;
//打开文件
Type docsType = docs.GetType();