How to read excel in Java

FREE Tutorials –
Hi, I am Raghav and today we will learn –
How to add excel libraries in the project
How to create functions to get data
How to call functions from different class
How to work with .xlsx and .xls formats

Step 1 : Create a java maven project

Step 2 : Add apache poi maven dependencies in pom.xml

Step 3 : Create a package and create class

Step 4 : Create a excel file and add some data

Step 5 : Create a function to get row count

Step 6 : Create a function to get cell data

Step 7 : Create a constructor and get excelPath and sheetName as arguments

Step 8 : Create a new class and call the ExcelUtils functions

Step 9 : How to work with .xls format

________ ONLINE COURSES TO LEARN ________

Udemy Discounts –
GitHub –
Udemy –
Training by Raghav at your venue –
Training schedule –

———— UI TESTING ————
Selenium Beginners –
Selenium Java Framework from Scratch –
Selenium Python –
Selenium Tips –
Selenium Builder –
Katalon Studio –
Robot Framework with RIDE-
Robot Framework with Eclipse –
Protractor –
TestProject –

———— API TESTING ————
Web Services (API) –
SoapUI –
Postman –
General –
Katalon Studio API Testing –

Appium –
Mobile Playlist –

———— CI | CD | DEVOPS ————
Jenkins Beginner –
Jenkins Tips & Trick –
Docker –
Kubernetes –

Virtualization on windows –
Git & GitHub –
GitLab –

JMeter Beginner –
JMeter Intermediate –
JMeter Advanced –
JMeter Tips & Tricks –
Performance Testing –

Java Beginners –
Java Tips & Tricks –

———— IDE ————
Visual Studio Code –

———— BUILD TOOLS ————
Maven –
Gradle –

———— OTHERS ————
Misc –
Tools & Tips –
QnA Friday-
Sunday Special –

Ask Raghav –
Interviews –
All Playlists –

Keep Learning,

———– Connect with Raghav ————
Website –
LifeCharger –
Udemy Courses –
Facebook –
Twitter –
Youtube –

Like, Subscribe & Share
You can support my mission for education by sharing this knowledge and helping as many people as you can

If my work has helped you, consider helping or any animal welfare group near you.


Xem thêm bài viết khác:

Article Categories:
Công Nghệ


  • As I run on local I have no issues but when I upload to Azure DevOps and run remotely, build failed with below errors. I was wondering why Azure DevOps failing to download the packages? Any suggestion please!

    [INFO] Compiling 32 source files to d:a1sExceleRATEtargetclasses

    [INFO] ————————————————————-


    [INFO] ————————————————————-

    [ERROR] /e:/a/1/s/ExceleRATE/src/main/java/com/qa/ExceleRATE/util/[8,35] package does not exist

    [ERROR] /e:/a/1/s/ExceleRATE/src/main/java/com/qa/ExceleRATE/util/[9,37] package org.apache.poi.xssf.usermodel does not exist

    [ERROR] /e:/a/1/s/ExceleRATE/src/main/java/com/qa/ExceleRATE/util/[10,37] package org.apache.poi.xssf.usermodel does not exist

    [ERROR] /e:/a/1/s/ExceleRATE/src/main/java/com/qa/ExceleRATE/util/[18,9] cannot find symbol

    symbol: class XSSFWorkbook

    location: class

    [ERROR] /e:/a/1/s/ExceleRATE/src/main/java/com/qa/ExceleRATE/util/[20,9] cannot find symbol

    symbol: class XSSFSheet

    location: class

    [ERROR] /e:/a/1/s/ExceleRATE/src/main/java/com/qa/ExceleRATE/util/[31,34] cannot find symbol

    symbol: class XSSFWorkbook

    location: class

    [INFO] 6 errors

    Sai Niranjan July 2, 2020 6:39 pm Reply
  • Hello Raghav, I am trying to do validation. My execution inputs first statement and enters 'for' loop and 'if' loop but does not perform any action. What am I missing ? Any suggestion please

    public void getOrganizationName() throws Exception {
    elementActions.doSendKeysUsingByLocator(OrganizationName, readExcelData.getCellDataString("Sheet1", 0, 0));

    for (int i = 0; i <= 13; i++) {

    if (elementActions.elementIsDisplayed(OrgAlreadyExists)) {


    elementActions.doSendKeysUsingByLocator(OrganizationName, readExcelData.getCellDataString("Sheet1", 0, i));





    Sai Niranjan July 2, 2020 6:39 pm Reply
  • @16.40 I tried the same thing and it works with the try-catch method. But as soon as I try to remove the try-catch block, I am getting an IO exception error on the line:
    XSSFWorkbook workbook = new XSSFWorkbook(excelpath);

    Any ideas why this could be happening

    Devang Savla July 2, 2020 6:39 pm Reply
  • hi Raghav …ur videos are so helpfull as its turning me from non tech to tech …. Upon trying to create in Excel in Java ..I am having a prob …Please can you help me…. My Question is when I m adding dependencies poi-ooxml is coming in Red underline …. not sure Y …I ignored it and moved ahead but when I am entering 'XSSFW' and pressing Ctrl+Spacebar …. I am not able to see drop down list …its showing me "NO default Proposal" …. Please can you help me.

    Sai Darekar July 2, 2020 6:39 pm Reply
  • Thank you raghav for making is so simple.
    However, looks weird but I did exactly the same as you did , got error
    NoClassDefFoundError: org/apache/commons/compress/archivers/zip/ZipFile
    After a lot of search , I found it was due to common-compress jar 1.19 which comes along with ooxml 4.1.2 jar.
    I had to add another dependency for common-compress 1.20 and then it fixed the issue.
    Not sure how come it worked for you with only ooxml 4.12.

    avishek behera July 2, 2020 6:39 pm Reply
  • Better channel about automation testing.
    Congratulations .

    mike tyson Schwarzenegger Pradella July 2, 2020 6:39 pm Reply
  • Please do ETL Testing videos Raghav

    Rajesh Amrutham July 2, 2020 6:39 pm Reply
  • thank you <3
    do you think automation testing will die in the next 10 years as dev they are start to do testing now
    should i continue learning how to become tester or switch to dev ?

    mario brick July 2, 2020 6:39 pm Reply
  • What about Google sheets?

    323BBR July 2, 2020 6:39 pm Reply
  • Bro upload Java videos only from now onwards please

    Ravikumar Pottabattula July 2, 2020 6:39 pm Reply
  • What is meaning by artifactory why used and that benifites

    SERIOUS THINKIG ULTIMATE RESULT July 2, 2020 6:39 pm Reply
  • Very good explanation. Thank you….

    MD HOSSAIN July 2, 2020 6:39 pm Reply
  • Great

    usman karim July 2, 2020 6:39 pm Reply

Leave a Reply

Your email address will not be published. Required fields are marked *