如何使用电动工具 xml 将单词转换为 html

How to convert word to html using power tool xml

我使用 PowerToolXml.dll 作为参考,将单词转换为 HTML 这是我的代码

using OpenXmlPowerTools;
using DocumentFormat.OpenXml.Wordprocessing;

byte[] byteArray = File.ReadAllBytes(DocxFilePath);
using (MemoryStream memoryStream = new MemoryStream())
{
    memoryStream.Write(byteArray, 0, byteArray.Length);
    using (WordprocessingDocument doc = WordprocessingDocument.Open(memoryStream, true))
    {
        HtmlConverterSettings settings = new HtmlConverterSettings()
        {
            PageTitle = "My Page Title"
        };
        XElement html = HtmlConverter.ConvertToHtml(doc, settings);

        File.WriteAllText(HTMLFilePath, html.ToStringNewLineOnAttributes());
    }
}

但在 WordprocessingDocument 处产生错误 this is not referred(即它产生 not reference 错误)如何解决这个问题?

The sample code uses the classes and enumerations that are in the DocumentFormat.OpenXml.dll assembly that is installed with the Open XML SDK 2.0 for Microsoft Office. To add the reference to the assembly in the following steps or to build the sample code that accompanies this visual how-to, you must first download and install the Open XML SDK 2.0 for Microsoft Office so that the assembly is available

您会在下面的文章中找到 link,但为了您的方便,我将其总结如下:

必须在您的 Visual Studio 项目中进行引用。在解决方案资源管理器中,找到您的项目;然后展开它;查找 参考资料;扩大它;并确保 PowerToolXml 出现在那里;如果不是,请右键单击 ReferencesAdd Reference 到程序集

告诉我更多