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

时间:2022-03-29 15:58:18

I am using Apache POI in my android application to read xlsx file stored in SDCARD. I am using following jar libs from Apache POI

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

  1. poi-ooxml-schemas-3.9-20121203.jar
  2. poi-ooxml-3.9-20121203.jar

But when I try to Run Android App I am getting below mentioned stacktrace.

但是当我尝试运行Android应用程序时,我得到了下面提到的堆栈跟踪。

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

Can anyone tell where am I missing?

谁能说出我错过的地方?

2 个解决方案

#1


1  

If you use too much code for any android app, the compilation will throw this error. The similar problem is stated and resolved here. You should split the app in parts as a plugin, in the form of a separate APK available for download. That APK would expose some component that the main app would use. There are various app on google play of such kind.

如果您为任何Android应用程序使用太多代码,编译将抛出此错误。这里陈述并解决了类似的问题。您应该将应用程序分成多个部分作为插件,以单独的APK形式下载。该APK将暴露主应用程序将使用的一些组件。这种谷歌游戏上有各种应用程序。

#2


1  

Please note that there are a number of problems when using Apache POI on Android. The one you are hitting can be solved by the so called "multiDex" feature in newer versions of Android.

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

There are currently two projects which try to solve most of the problems for you:

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

  1. https://github.com/andruhon/android5xlsx
  2. https://github.com/centic9/poi-on-android/ (mainted by me)
  3. https://github.com/centic9/poi-on-android/(由我主持)

The first one is currently based on POI 3.12, whereas the second can be re-compiled with newer versions of POI more easily.

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

#1


1  

If you use too much code for any android app, the compilation will throw this error. The similar problem is stated and resolved here. You should split the app in parts as a plugin, in the form of a separate APK available for download. That APK would expose some component that the main app would use. There are various app on google play of such kind.

如果您为任何Android应用程序使用太多代码,编译将抛出此错误。这里陈述并解决了类似的问题。您应该将应用程序分成多个部分作为插件,以单独的APK形式下载。该APK将暴露主应用程序将使用的一些组件。这种谷歌游戏上有各种应用程序。

#2


1  

Please note that there are a number of problems when using Apache POI on Android. The one you are hitting can be solved by the so called "multiDex" feature in newer versions of Android.

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

There are currently two projects which try to solve most of the problems for you:

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

  1. https://github.com/andruhon/android5xlsx
  2. https://github.com/centic9/poi-on-android/ (mainted by me)
  3. https://github.com/centic9/poi-on-android/(由我主持)

The first one is currently based on POI 3.12, whereas the second can be re-compiled with newer versions of POI more easily.

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