c# - 我可以使用 DOCX 库将 DOCX 文件另存为 HTML 吗?

标签 c# html docx file-conversion novacode-docx

我正在使用 DOCX 库来操作 *.docx 文件。

我想将 *docx 文件另存为 html 文件,但是这段代码:

using (DocX sourceDoc = DocX.Create(sourceFilename))
{
    sourceDoc.SaveAs(sourceHTMLFileName); 
}

...不起作用(sourceHTMLFileName 是“Bla.html”)。

这可能吗?如果是这样,怎么办?

最佳答案

DocX 的作者在 blog post 中指出他的图书馆还不支持这个功能。我从 codeplex page 得到了链接对于图书馆。)

引用链接:

I would love to add this functionality to DocX, however there is a problem.

[...]

The only easy way to do this conversion, is to use Microsoft’s Office interop libraries

[...]

Is there no way to do conversions without having Word.exe installed on my machine. I didn’t say that, I said there is no easy way. This looks very promising, now if I could only find the time.

他建议使用 Interop 的解决方法,但这可能行不通,具体取决于您的环境。

对以 .html 结尾的文件使用 SaveAs 只会保存扩展名为错误的 .docx 文件;没有完成任何转换。

关于c# - 我可以使用 DOCX 库将 DOCX 文件另存为 HTML 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21840400/

相关文章:

javascript - 如何从 HTML 中删除 angularjs 属性和类?

ASP.NET 单声道 : How to send SOAP instead of HTML?

c# - Null in String.Format args 抛出 NullReferenceException 即使 arg 不在结果字符串中

c# - 长类名会影响 XAP 文件的大小吗?

javascript - 在 UIWebView 中滚动

javascript - 如何使用 JavaScript 将 HTML 转换为 Docx 和 PDF

java - 如何使用 Apache poi 保存 word docx 文件。更改为 saxon9he 而不是 saxon9pe

python - 提取 DOCX 注释

c# - 在 Visual Studio 中,是否可以将 .NET 4.x CLR 作为 2.0 类库 API 的目标?

c# - 在系统启动时启动 WPF 应用程序时出错