Apache POI、Excel 2007+ XML 和 OSGI [英] Apache POI, Excel 2007+ XML, and OSGI
问题描述
对于一个项目,我正在尝试使用 Apache POI 获得 Excel XML 功能以与 OSGI 一起使用.
For a project I'm trying to get Excel XML functionality using Apache POI to work with OSGI.
我已经尝试过 POI ServiceMix 包,但是缺少 ooxml-schemas jar.将 jar 添加到捆绑包并将其包含在清单中似乎不起作用.
I've tried the POI ServiceMix bundle, but this was missing the ooxml-schemas jar. Adding the jar to the bundle and including it in the manifest didn't seem to work.
然后我尝试为 POI 3.10 创建包装器包,但也无济于事.同样的错误.
Then I tried to creating wrapper bundles for POI 3.10, but also to no avail. Same error.
Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl not found by org.apache.poi [8]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
... 105 more
后续调用导致以下结果:
Subsequent calls lead to the following:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument
at org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument$Factory.parse(Unknown Source)
at org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:44)
... 93 more
XMLBeans 可作为一个包导出其所有包,我已经尝试了 ServiceMix 包以及从 POI 3.10 附带的 jar 中制作一个包.
XMLBeans is available as a bundle exporting all of its packages, and I've tried the ServiceMix bundle as well as making one out of the jar included with POI 3.10.
有人可以指导我完成创建可以处理 Excel 2007+ XML 文档的工作 OSGI 包的过程吗?非常感谢帮助.
Could someone guide me through the process of creating a working OSGI bundle that can handle Excel 2007+ XML documents? Help much appreciated.
推荐答案
问题是 org.apache.poi.ooxml-schemas
中的类调用 Class.forName("org.apache.xmlbeans.impl.schema")
,因此您需要在 ooxml-schemas 包的清单中导入此包.
The problem is that the classes from org.apache.poi.ooxml-schemas
call Class.forName("org.apache.xmlbeans.impl.schema")
, so you need an import of this package in the manifest of your ooxml-schemas bundle.
我通过在构建ooxml时在maven-bundle-plugin
的配置中添加
解决了这个问题-模式包.
I solved it by adding <DynamicImport-Package>*</DynamicImport-Package>
to the configuration of the maven-bundle-plugin
when building the ooxml-schemas bundle.
这篇关于Apache POI、Excel 2007+ XML 和 OSGI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!