发布网友
共3个回答
热心网友
打开word文档,单击菜单栏中的“文件”,找到“另存为” 或“另存为网页”,如图所示。
击另存为” 或“另存为网页”,弹出"另存为" 窗口, 如图所示。
在"另存为" 窗口的“保存类型”,下拉菜单中找到“网页”。
在“文件名”一栏中可以修改我们想要的文件名。
点“保存”,就把一篇word文档保存成网页格式了。
这时候在桌面就可以找到保存的网页,然后用浏览器会打开并显示网页的内容。
热心网友
//将Word转换为Htmlpublic string wordToHtml(System.Web.UI.HtmlControls.HtmlInputFile wordFilePath){Microsoft.Office.Interop.Word.ApplicationClass word = new Microsoft.Office.Interop.Word.ApplicationClass();Type wordType = word.GetType();Microsoft.Office.Interop.Word.Documents docs = word.Documents; // 打开文件Type docsType = docs.GetType(); //应当先把文件上传至服务器然后再解析文件为html//if (wordFilePath.PostedFile != null)//{ //变换前路径 改动1//string filePath = ViewState["sss"].ToString();//} string filePath = File1.PostedFile.FileName;object fileName = filePath; Microsoft.Office.Interop.Word.Document doc = (Microsoft.Office.Interop.Word.Document)docsType.InvokeMember("Open",System.Reflection.BindingFlags.InvokeMethod, null, docs, new Object[]{ fileName, true, true }); // 转换格式,另存为htmlType docType = doc.GetType();string filename = System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString() + System.DateTime.Now.Day.ToString() +System.DateTime.Now.Hour.ToString() + System.DateTime.Now.Minute.ToString() + System.DateTime.Now.Second.ToString(); //被转换的html文档保存的位置string ConfigPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "Uploadfiles \\wordTmp\\" + filename + ".html";object saveFileName = ConfigPath; docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod,null, doc, new object[]{ saveFileName, Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatFilteredHTML }); // 退出 WordwordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, word, null);//转到新生成的页面