Reading from Excel using POI API

In the previous post, we have learnt how to create and write to Excel Files using Apache POI APIs. We have used XSSF API to write data which is used for xlsx formats.In this post, we will see how to read the data from Excel file.

Let’s understand this step by step.

We will read the same excel sheet data, which we have created in the previous post.

Excel writing poi


Step#1 Create File object and pass the file path as an argument. This file object will be passed to FileInputStream object as given below.

Step#2 Pass this FileInputStream object to the XSSFWorkbook  objects to get the instance of Excel workbook. Need to access the desired sheet by using method ‘getSheet’.

Step#3 Count the total rows and columns present in the excel sheet.

Step#4 Get the access of Row and Column by using the below statements.

Step#5 The data in the Excel sheet can be in different form like String, Numeric,boolean etc. We need to verify which kind of data it is and on that basis we can print the data.

Step#6 Close the File.

Full code to Read the data from Excel Files using POI API:

Here is the full code you can use. You just need to replace the File path ,rest it will take care.

Ask Question
Have any question or suggestion for us?Please feel free to post in Q&A Forum


Writing to Excel File using POI API
Useful Operations in Excel Using POI API
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

You may also like...