当前位置:首页经验技巧Word经验word办公

如何将word装换HTML

2026-01-19 10:43:37

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);//转到新生成的页面


免责声明:本站信息来自网络收集及网友投稿,仅供参考,如果有错误请反馈给我们更正,对文中内容的真实性和完整性本站不提供任何保证,不承但任何责任,谢谢您的合作。
版权所有:五学知识网 Copyright © 2015-2026 www.z8000w.com. All Rights Reserved .