【问题标题】:Reading MS Excel 2010 files in android using Apache POI使用 Apache POI 在 android 中读取 MS Excel 2010 文件
【发布时间】:2013-11-26 17:34:48
【问题描述】:

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

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

但是当我尝试运行 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

谁能告诉我我错过了哪里?

【问题讨论】:

  • 能否请您参考@stackoverflow.com/questions/15200286。跟踪问题可能很有用。
  • 我已经看过了。但是由于他们没有提到如何使用proguard或自定义ant库,所以无法解决问题。
  • 有人在某个时候写道,更改类路径中导入的顺序会有所帮助。但是我前段时间尝试时遇到了同样的问题,最终将 excel 导出为 CSV 并改为读取。
  • 我尝试了导入顺序,但没有成功。我无法导出到 csv,这是我的应用程序限制,谁能建议该怎么做?

标签: android excel apache-poi


【解决方案1】:

如果您对任何 android 应用程序使用过多代码,编译将抛出此错误。类似的问题已在here 中说明并解决。您应该将应用程序拆分为插件,以可供下载的单独 APK 的形式。该 APK 将公开一些主应用程序将使用的组件。 google play上有各种各样的应用程序。

【讨论】:

    【解决方案2】:

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

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

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

    第一个当前基于 POI 3.12,而第二个可以更轻松地使用更新版本的 POI 重新编译。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-05
      相关资源
      最近更新 更多