以编程方式将 word docx 转换为 doc,而不使用 ole 自动化

发布于 2024-07-08 15:23:11 字数 185 浏览 6 评论 0原文

我正在寻找一种方法,以编程方式将 docx 格式的 Word 文档转换为 doc 格式,而不使用 ole 自动化。 我已经有一个 Windows 服务可以执行此操作,但这意味着在服务器上安装 Office,而且它有点不可靠且不受支持。 我知道 aspose.words 产品,我会尝试一下,但是有人对如何尽可能简单、可靠和便宜地做到这一点有任何建议吗?

i'm looking for a way to programatically convert word documents in docx format to doc format without using ole automation. i already have a windows service that does this but it means installing office on a server and it is a little unreliable and not supported. i am aware of the aspose.words product, and i will try it out, but has anyone any recommendations for how to do this as simply, reliably, and cheaply as possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

坐在坟头思考人生 2024-07-15 15:23:11

不使用 OLE 自动化的一种选择是包装兼容包附带的转换器 dll,以便在不自动化 Office 的情况下从 docx 转换为 doc。

只需在计算机上安装 Office 兼容包即可。

Office 转换器 dll 使用ForeignToRtf/RtfToForeign 接口从它们支持的文档格式转换为RTF 和/或从RTF 转换为其文档格式。 您可以根据需要将转换器从一种格式转换为另一种格式,例如进行 DOCX 转换 -> DOCX 转换。 RTF-> 文档。

您可以从 Microsoft 获取SDK,其中包括几个有关如何使用现有转换器的示例。 如果我没记错的话,已经包含了一个命令行包装器示例。 一切都是 C/C++ 的东西。

您可以通过查看以下注册表项找出哪些转换器 dll 负责 OpenXML 转换:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Text Converters\Import\Word12  

如果您需要更多详细信息,请告诉我。

One option without using OLE automation would be to wrap the converter dlls coming with compatibility pack in order to convert from docx to doc without automating Office.

This requires only that the Compatibility Pack of Office is installed on the machine.

The Office converter dlls convert from the document format that they support to RTF and/or from RTF to their document format using the interface ForeignToRtf/RtfToForeign. You can chain converters as you wish to convert from one format to another, e.g. to do a conversion DOCX -> RTF -> DOC.

You can get the SDK from Microsoft, which includes several samples on how to use existing converters. If I remember correctly there is already a command line wrapper sample included. Everything is C/C++ stuff.

You can find out which of the converter dlls are responsible for OpenXML conversion by looking at the following registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Text Converters\Import\Word12  

Let me know if you need further details on this.

兮子 2024-07-15 15:23:11

您可以使用 docx4j (或者实际上只是 poi)来读取 docx,并使用 poi 将其写为.doc

You could use docx4j (or indeed, just poi) to read the docx, and poi to write it out as a .doc

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文