如何在 Jython 中使用 win32com 模块

发布于 2024-12-19 13:14:52 字数 767 浏览 3 评论 0原文

我有一些将word文件转换为html文件的python代码,它使用win32com模块,像这样

from win32com import client as wc

我希望在java代码中调用python程序,所以我使用了Jython。 但是Jython不识别win32com模块,抛出这样的异常

ImportError: No module named win32com

我在互联网上搜索了一些信息,有人说 “问题在于 win32api 模块是用 C 实现的,因此 Jython 无法提供它。” 另请参阅 http://permalink.gmane.org/gmane.comp.lang .jython.user/1371

您能告诉我如何在 Jython 中使用 win32com 模块吗?


我尝试使用 Apache POI 将包含数学公式的 Word 文件转换为 HTML, 但总是效果不佳。 所以我必须使用 python 和 win32com 模块, 因为它可以像 Microsoft Office Word 一样将数学公式转换为图像。 有人对使用 POI 在 Word filse 中转换数学公式有任何建议吗?

感谢您的帮助!

I have some codes of python that convers word file to html file, it uses win32com module, like this

from win32com import client as wc

I hoped to invoke python program in java codes, so I used Jython.
But Jython don't recognition win32com module, throws exception like this

ImportError: No module named win32com

I searched some information in internet, someone says
"The problem is that the win32api module is implemented in C so it is not available from Jython."
see also http://permalink.gmane.org/gmane.comp.lang.jython.user/1371

Will you please tell me how to use win32com module in Jython?


I tried to convert Word files that include math formula to HTML with Apache POI,
but always doesn't work well.
So I have to use python and win32com module,
because it can convert math formulas to images like Microsoft Office Word does.
Does anyone have any suggestions about converting math formulas in Word filse with POI?

Thanks for help!

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

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

发布评论

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

评论(1

我要还你自由 2024-12-26 13:14:52

您能告诉我如何在 Jython 中使用 win32com 模块吗?

不能,而且你自己也说了原因。 Win32com 模块是用 C 编写的。Jython 包含最初用 Python 编写的所有模块,但(Java 翻译)只有少数最初用本机代码编写的 CPython 模块。不包括 Win32com 模块。

我认为Jython的想法是纯Java,与微软COM模块的互操作不能用纯Java来完成。原则上可以使用 JNI 来实现,并且需要做大量工作,但尚未完成。

如果您的目标是使用 Java 将 Word 文件转换为 HTML,请查看 Apache POI

Will you please tell me how to use win32com module in Jython?

You can't and you stated the reason yourself. Win32com module is written in C. Jython contains all the modules that are originally written in Python, but (Java translations of) only few of the CPython modules that are originally written in native code. Win32com module is not included.

I think Jython's idea is to be pure Java, and interoperation with Microsoft COM modules can't be done in pure Java. It could in principle be implemented using JNI and lots of work, but hasn't been done.

If your goal is to convert Word files to HTML, using Java, have a look at Apache POI.

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