使用Apache POI在Android中读取MS Excel 2010文件

我在我的android应用程序中使用Apache POI来读取存储在SDCARD中的xlsx文件。 我正在使用Apache POI的以下jar库

  1. POI-OOXML-架构 – 3.9-20121203.jar
  2. POI-OOXML-3.9-20121203.jar

但是当我尝试运行Android应用程序时,我正在下面提到的stacktrace。

trouble writing output: Too many methods: 66024; max is 65536. By package: 13 java.lang 1 java.lang.reflect 5 java.util 1 javax.xml.namespace 66 org.apache.xmlbeans 19 org.apache.xmlbeans.impl.values 1 org.apache.xmlbeans.impl.xb.xmlschema 2500 org.openxmlformats.schemas.drawingml.x2006.chart 1430 org.openxmlformats.schemas.drawingml.x2006.chart.impl 8767 org.openxmlformats.schemas.drawingml.x2006.main 5258 org.openxmlformats.schemas.drawingml.x2006.main.impl 86 org.openxmlformats.schemas.drawingml.x2006.picture 33 org.openxmlformats.schemas.drawingml.x2006.picture.impl 745 org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing 417 org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.impl 230 org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing 164 org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.impl 298 org.openxmlformats.schemas.officeDocument.x2006.customProperties 256 org.openxmlformats.schemas.officeDocument.x2006.customProperties.impl 617 org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes 596 org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes.impl 285 org.openxmlformats.schemas.officeDocument.x2006.extendedProperties 196 org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.impl 23 org.openxmlformats.schemas.officeDocument.x2006.math 24 org.openxmlformats.schemas.officeDocument.x2006.relationships 2 org.openxmlformats.schemas.officeDocument.x2006.relationships.impl 2076 org.openxmlformats.schemas.presentationml.x2006.main 1224 org.openxmlformats.schemas.presentationml.x2006.main.impl 1 org.openxmlformats.schemas.schemaLibrary.x2006.main 7271 org.openxmlformats.schemas.spreadsheetml.x2006.main 4556 org.openxmlformats.schemas.spreadsheetml.x2006.main.impl 11448 org.openxmlformats.schemas.wordprocessingml.x2006.main 9217 org.openxmlformats.schemas.wordprocessingml.x2006.main.impl 4 schemaorg_apache_xmlbeans.system.sE130CAA0A01A7CDE5A2B4FEB8B311707 1170 schemasMicrosoftComOfficeExcel 1223 schemasMicrosoftComOfficeExcel.impl 285 schemasMicrosoftComOfficeOffice 124 schemasMicrosoftComOfficeOffice.impl 2 schemasMicrosoftComOfficePowerpoint 3 schemasMicrosoftComOfficeWord 2858 schemasMicrosoftComVml 2529 schemasMicrosoftComVml.impl [2013-11-25 21:20:32 - CRD] Conversion to Dalvik format failed with error 2 

任何人都可以告诉我错过了什么?

如果你使用任何Android应用程序的代码太多,编译将引发这个错误。 类似的问题在这里陈述和解决。 您应该将应用分成几部分作为插件,以单独的APKforms提供下载。 该APK会暴露主应用程序将使用的一些组件。 有这样的谷歌播放有各种应用程序。

请注意,在Android上使用Apache POI时有许多问题。 您正在触摸的那个可以通过Android的新版本中所谓的“multiDex”function来解决。

目前有两个项目试图为您解决大部分问题:

  1. https://github.com/andruhon/android5xlsx
  2. https://github.com/centic9/poi-on-android/ (由我维持)

第一个是基于POI 3.12,而第二个可以更容易地重新编译更新版本的POI。