Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.supercilex:poi-android:'
}
dependencies {
implementation("com.github.supercilex:poi-android:")
}
<dependency>
<groupId>com.github.supercilex</groupId>
<artifactId>poi-android</artifactId>
<version></version>
</dependency>
libraryDependencies += "com.github.supercilex" % "poi-android" % ""
:dependencies [[com.github.supercilex/poi-android ""]]
POIA is a simple library enabling Apache POI usage on Android.
Add JitPack to your repositories
:
allprojects {
repositories {
// ...
maven { url 'https://jitpack.io' }
}
}
And the POIA dependency itself:
implementation "com.github.SUPERCILEX.poi-android:poi:$poiVersion"
If you're using proguard, also add:
implementation "com.github.SUPERCILEX.poi-android:proguard:$poiVersion"
If you want source code and documentation, add the real Apache POI dependency as compileOnly
:
compileOnly "org.apache.poi:poi-ooxml:$poiVersion"
If you need a newer version of Apache POI than is provided by this transpiler, updating is as simple as making a fork and changing a few lines of code:
SUPERCILEX
in the Gradle dependency with your own GitHub usernameXSSFWorkbook
(*.xlsx
) does not work on pre-L (API < 21) devices. A simple solution is to show
the user some error message and gracefully downgrade to HSSFWorkbook
(*.xls
):
val workbook = if (isUnsupportedDevice) {
showToast(getString(R.string.export_unsupported_device_rationale))
HSSFWorkbook()
} else {
XSSFWorkbook()
}
// Example unsupportedDevice property
val isUnsupportedDevice by lazy { VERSION.SDK_INT < VERSION_CODES.LOLLIPOP || isLowRamDevice }
Make sure to test your implementation thoroughly pre-L since HSSFWorkbook
only supports a subset
of the Workbook
's APIs and might throw a UOE. Wikipedia even goes so far as to call it the
"Horrible SpreadSheet Format" so consider yourself warned. 😁