Read Excel File in Android App and Display Data in RecyclerView | Android Studio Tutorials

Yes, It is possible to Read and write excel file from android app. But this post only concentrate 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 android app. 





First, Most of the java library that lets you read or write the excel file are outdated and some of them are really hard to implement. For example , Apache POI seems popular java library that has been used to read and write 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 modern excel file that have 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 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 a 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 and 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 download and display the images. 


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

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


  • Now, We need Custom_layout for recyclerview since we will be displaying multiple textview as well as imageview on the recyclerview
To use custom layout for recylerview we need to create adapter that take care of extracting the data from the list and bind 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 JExcelApi library and Save the data in ArrayList<>(), here i have created three seperate ArrayList for title,descriptions and finally image_urls. First using asyncHTTP , 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

1 comment:

  1. i have a file in excel which have some mobile number and one message..
    i have to send that message to all that mobile number on button click..
    how to do that?

    ReplyDelete

Powered by Blogger.