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 – raghav.qna@gmail.com
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 –

———— MOBILE TESTING ————
Appium –
Mobile Playlist –

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

————-VIRTUALISATION————-
Virtualization on windows –
———— VERSION CONTROL SYSTEM ————
Git & GitHub –
GitLab –

———— PERFORMANCE TESTING ————
JMeter Beginner –
JMeter Intermediate –
JMeter Advanced –
JMeter Tips & Tricks –
Performance Testing –

———— PROGRAMMING ————
Java Beginners –
Java Tips & Tricks –
GROOVY –
JAVASCRIPT –
PYTHON –

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

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

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

Ask Raghav –
Interviews –
All Playlists –

Keep Learning,
Raghav

———– 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.

Nguồn: https://baggersoriginals.com/

Xem thêm bài viết khác: https://baggersoriginals.com/cong-nghe/

Article Categories:
Công Nghệ

Comments

  • 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] ————————————————————-

    [ERROR] COMPILATION ERROR :

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

    [ERROR] /e:/a/1/s/ExceleRATE/src/main/java/com/qa/ExceleRATE/util/ReadExcelData.java:[8,35] package org.apache.poi.ss.usermodel does not exist

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

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

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

    symbol: class XSSFWorkbook

    location: class com.qa.ExceleRATE.util.ReadExcelData

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

    symbol: class XSSFSheet

    location: class com.qa.ExceleRATE.util.ReadExcelData

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

    symbol: class XSSFWorkbook

    location: class com.qa.ExceleRATE.util.ReadExcelData

    [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)) {

    driver.findElement(OrgName).clear();

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

    break;

    }

    }

    }

    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 .
    Sensational.

    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 *