- ·上一篇:word中如何不显示,显示
- ·下一篇:word文档如何显示黑色,黑色,文档,显示
如何将word装换HTML
1.怎么把Word转换为网页html格式
可以office word(或wps文字)通过“另存为”飞方式来转化格式。
比如现在有一个word格式,我在wps里打开。
然后依次从上到下点击下面的按钮。
最后,下拉格式框,选择要保存的格式,比如html格式,即可。
office word软件操作同样如此。
2.如何迅速将Word转换为Html
//将Word转换为Html
public 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 }); // 转换格式,另存为html
Type 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 }); // 退出 Word
wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, word, null);//转到新生成的页面
