Giter VIP home page Giter VIP logo

android5xlsx's Introduction

This repository is archived

Reading and Writing XLSX on Android 5

Reading and Writing XLSX and XLS on Android 5 with Apache POI

It was quite a challenging task to use Apache POI on android with Dalvik VM. It is much easier to use Apache POI on Android 5+ with ART VM and Build Tools 21+

Please refer to https://github.com/andruhon/AndroidReadXLSX if you need to read XLSX on Android 4 with Dalvik VM.

Contents

I've repacked poi-ooxml to contain all dependencies in order to read and write XLSX (XLS as well, obviously) All javax classes from the STAX library and calls to them are renamed to aavax, to avoid --core-library warning and conflicts.

  • poi-3.12-android-a.jar //Repacked POI with all dependencies
  • poi-ooxml-schemas-3.12-20150511-a.jar //original schemas jar

Copy these two jars into your project's libs directory and use gradle config similar to build.gradle from this repo.

It will also work if you use all original files from https://poi.apache.org/download.html, however you need to re-pack xmlbeans-2.6.0.jar because for some reason it contains duplicates and Android does not like it. See below for contents of jar and details of javax -> aavax hack.

Configuration

Please find gradle app configuration with comments in the build.gradle, the crucial thing is to enable multi-dex.

Auto-downloading dependencies

This might also be achieved by adding 'org.apache.poi:poi-ooxml:3.12' into dependencies, but it is not very straightforward because it is required to add some routine to re-pack xmlbeans and disable preDex. It will work. however the build process will be very slow, so it is easier just to prepare jars once and put them into libs directory (as described above)

Usage example

Please find usage example in example

Contents of poi-3.12 jar

  • poi-3.12-20150511.jar
  • poi-ooxml-3.12-20150511.jar
  • stax-1.2.0.jar
  • stax-api-1.0.1.jar
  • xmlbeans-2.6.0.jar //this one contained duplicates, Android does not like it

javax -> aavax hack

the following classes and calls to them were renamed (as HEX strings + renaming namespace dir javax to aavax):

  • javax/xml/namespace -> aavax/xml/namespace
  • javax.xml.namespace -> aavax.xml.namespace
  • javax/xml/stream -> aavax/xml/stream
  • javax.xml.stream -> aavax.xml.stream
  • javax/xml/XMLConstants -> aavax/xml/XMLConstant
  • javax.xml.XMLConstants -> aavax.xml.XMLConstants

Please note that you'd better not replace all javax to aavax, because there might be calls other classes from javax package which are available in android.

License

See LICENSE.md

android5xlsx's People

Contributors

andruhon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.