Closed SrHalf closed 4 years ago
Hi. I never tried FastODS on Android. There's a reasonable hope it works because there's no runtime dependency beyond the standard library. (Dependencies are for tests only.) If you try it, please let me know the outcome so that I can update the README.
Salut, êtes-vous français ? Je parle un peu ta langue ! Haha
So, I have implemented FastODS on my Android project and it worked pretty well. I didn't test it out on other devices because I don't have another one available right now, but I intend to do this. The ODS file generated is perfectly readable on Google Sheet for Android and Microsoft Excel for Android.
I'm using: OS: Ubuntu 18.04.4 LTS IDE: Android Studio 3.6.1 Device: Android 9 Pie
This is how I did it.
First of all, I put it on gradle.build:
implementation 'com.github.jferard:fastods:0.7.2'
And my method for exporting process is (in Kotlin, but there's no significant difference):
` fun exportToODS(tableName:String){
val folder = File(Environment.getExternalStorageDirectory(), "Exported")
if(!folder.exists())
folder.mkdir()
val odsFile = File(folder, "MyList.ods")
val writer = OdsFactory.create().createWriter(odsFile)
val document = writer.document()
val table = document.addTable(tableName)
//
val items = //Select all items of my list..
for(i in 0 until items.size){
val item = items[i]
val row = table.getRow(i)
//
row.getOrCreateCell(0).setStringValue(item.valueOne.toString())
row.getOrCreateCell(1).setStringValue(item.valueTwo.toString())
row.getOrCreateCell(2).setStringValue(item.valueThree.toString())
row.getOrCreateCell(3).setStringValue(item.valueFour.toString())
row.getOrCreateCell(4).setStringValue(item.valueFive.toString())
row.getOrCreateCell(5).setStringValue(item.valueSix.toString())
//
//More cell values..
}
//
writer.save()
writer.close()
} ` I didn't publish the update of my app yet, because I have a lot of work to do, but I wanted to post it that FastODS work fine on Android.
Great job!
Yeah I'm french - je suis français. Thanks for the feedback. I'll write a line in the README to say that FastODS works on Android.
Can I use FastODS to export my list of data on Android app? Currently I'm exporting only to CSV, but I wana export in more formats, and FastODS seems interesting. Any limitation? How can I use it properly?