试图端口的Apache POI到Android端口、Apache、Android、POI

2023-09-11 20:33:07 作者:青栀琉璃裙.

我在寻找一个轻量级版本POI-3.8.jar的使用它在Android(私人)的应用程序。 我似乎并不能够适合在APK整个1.7MB罐由于某种原因(这将是错误的所以无论如何做),并因为我只是在寻找文档 - > HTML和XLS - > HTML功能,我不太确定我需要整个jar文件。

I'm looking for a lightweight version of poi-3.8.jar to use it in an Android (private) app. I don't seem to be able to fit the whole 1.7Mb jar in the APK for some reason (and it would be wrong to do so anyway) and since I'm only looking for the doc -> html and xls -> html functionality, I'm not quite sure I need the whole jar file.

我已经花了几个小时,试图找出如何提取org.apache.poi.hwpf.converter.WordToHtmlExtracter.java在POI / HWPF /转换器,但它看起来像它使用了很多其他的东西。即使这并不能真正让我感到吃惊,我在想,也许这里有人会知道哪些软件包我可以摆脱使罐子更小。我很乐意花更多的时间就可以了,除非有人在这里告诉我这是在浪费时间,而且一切的根源是需要转换的DOC到HTML文件。

I've spent a couple hours trying to figure out how to extract org.apache.poi.hwpf.converter.WordToHtmlExtracter.java in poi/hwpf/converter but it looks like it's using a lot of other stuff. Even if this doesn't really surprise me, I was thinking that maybe someone here would know which packages I can get rid of to make the jar smaller. I'll be glad to spend more time on it, unless someone here tells me it's a waste of time and that EVERYTHING in the sources is needed to convert doc to html files.

我什么都不需要显示任何东西,我需要的只是简单的文档,以HTML(和XLS如果可能的HTML)的功能。我不需要任何有关PDF和PowerPoint,Outlook或什么的。

I don't need anything that displays anything, I just need the "simple" doc to html (and xls to html if possible) features. I don't need anything related to PDF, powerpoint, outlook or whatever.

我会很高兴分享不管我发现

I'll be glad to share whatever I find out

干杯

推荐答案

嗯,我能够做的大部分事情我问这里。这是进口的jar文件。我有至少2个类型的问题: - 没有足够的RAM基于Eclipse这使德兴我的班级崩溃的大部分时间(固定在的eclipse.ini调整XMX和XMS值) - 64k的方法限制每个DEX文件所做的事情复杂化。我不得不将所有必需的POI罐子分成几个DEX文件。 (我这样做,按照从Android博客教程:http://android-developers.blogspot.com/2011/07/custom-class-loading-in-dalvik.html )

Well I was able to do most of what I was asking for here. That is importing the jar files. I had at least 2 kinds of problems: - not enough RAM on Eclipse which made dexing my classes crash most of the time (fixed by adjusting the Xmx and xms values in Eclipse.ini) - the 64k method limit for each DEX file made things complicated. I had to split all the required POI jars into several DEX files. (I did that by following the tutorial from the Android blog: http://android-developers.blogspot.com/2011/07/custom-class-loading-in-dalvik.html )

真正的答案,我的问题是:是的,你需要的一切在罐子。我为基本的非开放式XML的文件。我的应用程序执行转换为HTML相当不错,它的速度不够快了。

The real answer to my question is: "yes you need everything in the jar". I made it work for the basic "non open xml" files. My app does the conversion to html quite well, and it's fast enough too.

在一个侧面说明,我也试图做同样的事情开放XML的文件,它的复杂得多。我的小项目没有做它应该做的,我已经初始化的XMLBeans类时得到了一些奇怪的例外。这里是我的跟踪(遗憾的丑恶):

On a side note, I was also trying to do the same thing with "open XML" files, and it's much more complicated. My little project doesn't do what it's supposed to do, I've got some weird exception when initializing the XMLBeans class. Here's my trace (sorry for the ugliness):

12-19 12:07:10.790: W/dalvikvm(13385): Exception
Ljava/lang/RuntimeException; thrown while initializing
Lorg/apache/xmlbeans/impl/regex/SchemaRegularExpression;
12-19 12:07:10.790: W/dalvikvm(13385): Exception
Ljava/lang/ExceptionInInitializerError; thrown while initializing
Lorg/apache/xmlbeans/impl/schema/BuiltinSchemaTypeSystem;
12-19 12:07:10.790: D/dalvikvm(13385): Method.invoke() on bad class
Lorg/apache/xmlbeans/impl/schema/BuiltinSchemaTypeSystem; failed
12-19 12:07:10.790: W/dalvikvm(13385): Exception
Ljava/lang/ExceptionInInitializerError; thrown while initializing
Lorg/apache/xmlbeans/XmlBeans;
12-19 12:07:10.790: W/System.err(13385):
java.lang.reflect.InvocationTargetException
12-19 12:07:10.790: W/System.err(13385):    at
java.lang.reflect.Method.invokeNative(Native Method)
12-19 12:07:10.790: W/System.err(13385):    at
java.lang.reflect.Method.invoke(Method.java:491)
12-19 12:07:10.790: W/System.err(13385):    at
t.fze.TestOfficeAndroidActivity.onCreate(TestOfficeAndroidActivity.java:55)
12-19 12:07:10.790: W/System.err(13385):    at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
12-19 12:07:10.790: W/System.err(13385):    at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
12-19 12:07:10.790: W/System.err(13385):    at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
12-19 12:07:10.790: W/System.err(13385):    at
android.app.ActivityThread.access$1500(ActivityThread.java:122)
12-19 12:07:10.790: W/System.err(13385):    at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
12-19 12:07:10.790: W/System.err(13385):    at
android.os.Handler.dispatchMessage(Handler.java:99)
12-19 12:07:10.790: W/System.err(13385):    at
android.os.Looper.loop(Looper.java:132)
12-19 12:07:10.790: W/System.err(13385):    at
android.app.ActivityThread.main(ActivityThread.java:4025)
12-19 12:07:10.790: W/System.err(13385):    at
java.lang.reflect.Method.invokeNative(Native Method)
12-19 12:07:10.790: W/System.err(13385):    at
java.lang.reflect.Method.invoke(Method.java:491)
12-19 12:07:10.790: W/System.err(13385):    at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
12-19 12:07:10.790: W/System.err(13385):    at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
12-19 12:07:10.790: W/System.err(13385):    at
dalvik.system.NativeStart.main(Native Method)
12-19 12:07:10.790: W/System.err(13385): Caused by:
org.apache.poi.POIXMLException:
java.lang.reflect.InvocationTargetException
12-19 12:07:10.790: W/System.err(13385):    at
org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
12-19 12:07:10.790: W/System.err(13385):    at
org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:414)
12-19 12:07:10.790: W/System.err(13385):    at
org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:155)
12-19 12:07:10.790: W/System.err(13385):    at
org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:174)
12-19 12:07:10.790: W/System.err(13385):    at
org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:63)
12-19 12:07:10.790: W/System.err(13385):    at
org.apache.poi.ss.examples.html.ToHtml.create(ToHtml.java:139)
12-19 12:07:10.790: W/System.err(13385):    at
org.apache.poi.ss.examples.html.ToHtml.create(ToHtml.java:123)
12-19 12:07:10.790: W/System.err(13385):    ... 16 more
12-19 12:07:10.790: W/System.err(13385): Caused by:
java.lang.reflect.InvocationTargetException
12-19 12:07:10.790: W/System.err(13385):    at
java.lang.reflect.Constructor.constructNative(Native Method)
12-19 12:07:10.790: W/System.err(13385):    at
java.lang.reflect.Constructor.newInstance(Constructor.java:416)
12-19 12:07:10.800: W/System.err(13385):    at
org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:60)
12-19 12:07:10.800: W/System.err(13385):    ... 22 more
12-19 12:07:10.800: W/System.err(13385): Caused by:
java.lang.ExceptionInInitializerError
12-19 12:07:10.800: W/System.err(13385):    at
org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument$Factory.parse(ThemeDocument.java:71)
12-19 12:07:10.800: W/System.err(13385):    at
org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:38)
12-19 12:07:10.800: W/System.err(13385):    ... 25 more
12-19 12:07:10.800: W/System.err(13385): Caused by:
java.lang.ExceptionInInitializerError
12-19 12:07:10.800: W/System.err(13385):    at
java.lang.reflect.Method.invokeNative(Native Method)
12-19 12:07:10.800: W/System.err(13385):    at
java.lang.reflect.Method.invoke(Method.java:491)
12-19 12:07:10.800: W/System.err(13385):    at
org.apache.xmlbeans.XmlBeans.getNoType(XmlBeans.java:856)
12-19 12:07:10.800: W/System.err(13385):    at
org.apache.xmlbeans.XmlBeans.<clinit>(XmlBeans.java:881)
12-19 12:07:10.800: W/System.err(13385):    ... 27 more
12-19 12:07:10.800: W/System.err(13385): Caused by:
java.lang.ExceptionInInitializerError
12-19 12:07:10.800: W/System.err(13385):    at
org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem.fillInType(BuiltinSchemaTypeSystem.java:1025)
12-19 12:07:10.800: W/System.err(13385):    at
org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem.<clinit>(BuiltinSchemaTypeSystem.java:223)
12-19 12:07:10.800: W/System.err(13385):    ... 31 more
12-19 12:07:10.800: W/System.err(13385): Caused by:
java.lang.RuntimeException: Installation Problem???  Couldn't load
messages: Can't find resource for bundle
'org.apache.xmlbeans.impl.regex.message_fr_FR', key ''
12-19 12:07:10.800: W/System.err(13385):    at
org.apache.xmlbeans.impl.regex.RegexParser.setLocale(RegexParser.java:88)
12-19 12:07:10.800: W/System.err(13385):    at
org.apache.xmlbeans.impl.regex.RegexParser.<init>(RegexParser.java:78)
12-19 12:07:10.800: W/System.err(13385):    at
org.apache.xmlbeans.impl.regex.ParserForXMLSchema.<init>(ParserForXMLSchema.java:28)
12-19 12:07:10.800: W/System.err(13385):    at
org.apache.xmlbeans.impl.regex.RegularExpression.setPattern(RegularExpression.java:2996)
12-19 12:07:10.800: W/System.err(13385):    at
org.apache.xmlbeans.impl.regex.RegularExpression.setPattern(RegularExpression.java:3009)
12-19 12:07:10.800: W/System.err(13385):    at
org.apache.xmlbeans.impl.regex.RegularExpression.<init>(RegularExpression.java:2975)
12-19 12:07:10.800: W/System.err(13385):    at
org.apache.xmlbeans.impl.regex.SchemaRegularExpression.<init>(SchemaRegularExpression.java:27)
12-19 12:07:10.800: W/System.err(13385):    at
org.apache.xmlbeans.impl.regex.SchemaRegularExpression.<init>(SchemaRegularExpression.java:23)
12-19 12:07:10.800: W/System.err(13385):    at
org.apache.xmlbeans.impl.regex.SchemaRegularExpression$1.<init>(SchemaRegularExpression.java:44)
12-19 12:07:10.800: W/System.err(13385):    at
org.apache.xmlbeans.impl.regex.SchemaRegularExpression.buildKnownPatternMap(SchemaRegularExpression.java:43)
12-19 12:07:10.800: W/System.err(13385):    at
org.apache.xmlbeans.impl.regex.SchemaRegularExpression.<clinit>(SchemaRegularExpression.java:38)
12-19 12:07:10.800: W/System.err(13385):    ... 33 more