Use Excel as Database in Android App

Use excel as db for android
Use excel as db for android

Yes, It is possible to read and write excel file from android app. (Excel as Database in Android) But this post only concentrates on how to read and display data of excel file in RecyclerView. Before actually starting the tutorials, I want to give you the limitations that I came across when I tried to read and display data of excel data in the android app. 

First, Most of the java library that lets you read or write the excel file is outdated and some of them are really hard to implement. For example, Apache POI seems a popular java library that has been used to read and write an excel file but I wasn’t able to make it work on my project. So I decided to use another library called jExcelApi and hence come with one limitation. That is, our app can’t read or write a modern excel file that has extension  “.xlsx” instead we need to convert that to “xls” file which is much older (2003 file format). 
 
But, you don’t need worry because xlsx can easily be converted to Xls using any online converter but you may lose some of the features of excel files and that may result in unexpected results, as far as our app is concerned we are just using simple excel files that contains only three columns for title, descriptions image URL.
 Let me show you the content of excel files that I am going to use here.
Sample Excel File

 

Create an Android App on Android Studio and Add jExcelApi dependencies on Build. Gradle We will also use android-async-http library to easily download the Excel file on our app. Finally, Picasso is used to downloading and displaying images. 

 

  • Add RecyclerView in activiy_main.xml File to Display our data from excel


We have also added Progressbar, which will be displayed to the user when the background process is running when the app is open.

  • Now, We need Custom_layout for recyclerview since we will be displaying multiple text view as well as image view on the recycler view

To use custom layout for recycler view we need to create an adapter that takes care of extracting the data from the list and binds data with custom view and displayed in RecyclerView. Here is the complete code for the Adapter.java class.

Finally, we will extract the excel file data using the JExcelApi library and Save the data in ArrayList<>(), here I have created three separate ArrayList for title, descriptions, and finally image_urls.
First using async HTTP, we need to download the Excel File form the server, following piece of code is used for that in mainactivity.java


For Full Step by Step Tutorials, Subscribe My Youtube Channel and Watch it Here: 

Get Full Source of Excel as Database in Android code Download Full Source Code

 

2 Comments

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.