我正在使用 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/