4

I know there's many same questions on stackoverflow, but it seems that I can't see any possible solution for reading the content of xlsx.

What I have try:

I have try to put the whole Apache POI library to an android application and try to read the xlsx file. However, the problem is that the Apache POI library is too heavy to put into an android application. An error message shows that the Dalvik VM cannot execute an app with more than 65536 methods.

It there any way to read the content of the xlsx file (could be the content only, other formatting such as color/width of the cell is not important) in an android app? Or it there any one tried to trim down the apache poi library so that Dalvik VM can execute it? As I saw that QuickOffice from Google Play are also using Apache POI, but I really don't know how to put the POI into an app. Thanks so much.

benleung
  • 871
  • 4
  • 12
  • 25
  • possible duplicate of [Trying to port Apache POI to Android](http://stackoverflow.com/questions/8493507/trying-to-port-apache-poi-to-android) – Moritz Petersen Jan 22 '14 at 09:25
  • http://stackoverflow.com/questions/18289765/running-into-warnings-and-errors-using-jspreadsheet –  Jan 24 '14 at 17:07

2 Answers2

1

Apache POI 3.5 have added support to all the OOXML (docx, xlsx, etc.)

See the XSSF sub project

Digvesh Patel
  • 6,503
  • 1
  • 20
  • 34
1

Just committed XSSF Android usage demo on github:

https://github.com/andruhon/AndroidReadXLSX

The core idea is just to remove from poi-ooxml and poi-ooxml-schemas all files which are seems to be not necessary to read XLSX. For example xslf and xwpf from poi-ooxml, schemas presentationml and wordrpocessingml from poi-ooxml-schemas and other stuff...

After that, build your project and try to read XLSX, read log after that fails and see which dependency caused this fail, copy missed file from original poi-ooxml-schemas jar. Do it again and again unless it is working.

UPD: no more need in --core-library option!
http://blog.kondratev.pro/2014/09/reading-xlsx-on-android-3.html

Demo mentioned above already contains reduced poi-ooxml and poi-ooxml-schemas.

  • The latest version of Apache POI (3.11 beta 2) has no stax dependency, and no dom4j dependency, so you might well be better off starting from that release as it'll be simpler – Gagravarr Aug 29 '14 at 12:21
  • It actually depends on stax in case with android and even more, because it depends on xml beans which uses some javax methods which are not implemented in android. ---- But copying stax won't help in this case because this beta attempts to use javax.xml.stream.XMLEventFactory and fails. – Andrew Kondratev Aug 30 '14 at 07:52
  • So, only 3.10-final for a moment. – Andrew Kondratev Aug 30 '14 at 07:55
  • UPD: no more need in --core-library option! – Andrew Kondratev Sep 06 '14 at 00:30
  • 1
    Hi Andrew i am using 3.10-final for read xlsx file but getting java.lang.reflect.InvocationTargetException also added dom4j-1.6.1 need urgent please suggest something to make it working for me. – user May 19 '15 at 21:33