Excel export in Android

2019-08-20 05:59发布

问题:

I need to export excel from my android app. I use Apache-POI library and I get en exception when I run my app "NoClassDefFoundError". But the class is in "poi-ooxml-3.9-20121203.jar" and the jar is connected as external jar. I suppose that it is impossible to use that lib in android development. Any idea or library which can help me for these points:

  1. Create Excel file
  2. Read and add rows to it

回答1:

I have been trying to use Apache POI for my app too and my conclusion was that it has dependencies that conflict with Android. Atleast I was not able to make it work, even with a quite amount of effort.

If the excel documents you wish to export are rather simple, I would suggest using jxl instead. This library unfortunately only supports old excel formats though.

Lars Vogel has made a nice tutorial showing how this is done: http://www.vogella.com/articles/JavaExcel/article.html

Yet another argument for not using POI is the size of the library. It is rather big, hence leaving a huge impact on your app size.

If you really want to use POI, I suggest creating a simple web service for it, having your app call that to create the excel documents.



回答2:

you can use the latest poi 3.17 for excel xlsx format and run this on android ,provided you have eliminate all the duplicate classes bundle in the xmlbeans-2.6.0.jar, lot of duplicate classes are found under xml /streams and xml/utils, all you need to do is to use the normal zip manager such as 7 zip manager to open and delete off ,some of the examples are as below all those duplicate classes found in the xmlbeans jar .

unfortunately , you can not use any POI method associate with call to java awt library specifically use by POI to work on picture resize or row resize.

thanks

link