How to read xlsx file in an android application?

半城伤御伤魂 提交于 2019-12-23 18:28:13

问题


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.


回答1:


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

See the XSSF sub project




回答2:


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.



来源:https://stackoverflow.com/questions/21278813/how-to-read-xlsx-file-in-an-android-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!