How can I read numeric data from an Excel sheet using Selenium Webdriver

0 votes
How can I read numeric data from an Excel sheet using Selenium Webdriver?
Jul 17, 2019 in Selenium by Jignesh
8,228 views

1 answer to this question.

0 votes

Hey Jignesh, for reading numeric data from an excel sheet you need to use Apache POI. Apache POI provides getNumericCellValue() method which return the numeric value of excel sheet cells. Following example shows how to do that:

import java.io.File;

import java.io.FileInputStream;

import java.io.IOException;

import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import org.testng.annotations.Test;


public class ReadExcel 

{

@Test
public void testReadCellNumeric() throws Throwable, IOException
{
         String path=System.getProperty("user.dir"); 

         // load workbook
XSSFWorkbook wb=new XSSFWorkbook(new FileInputStream(new File(path+"/TestData/AppTestData.xlsx")));

        // read numeric data 
int data= (int)wb.getSheetAt(0).getRow(0).getCell(1).getNumericCellValue();

        // print on console
System.out.println("Data from Excel is >>> "+data);

}
}
answered Jul 17, 2019 by Abha
• 28,140 points

Related Questions In Selenium

0 votes
1 answer

How can I select an option from a dropdown using Ruby Selenium Webdriver?

Hey Swasti, you can try following lines ...READ MORE

answered Aug 26, 2019 in Selenium by Anvi
• 14,150 points
4,784 views
0 votes
1 answer

How can I download the *.jar file from http:// seleniumhq.org using selenium WebDriver?

For Selenium Standalone Server use this: profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/java-archive"); and ...READ MORE

answered Apr 9, 2018 in Selenium by Martin
• 4,320 points
3,574 views
0 votes
1 answer

How can I locate web elements from a web page using Selenium Webdriver?

Hey @Dushyant, Locating elements in WebDriver is ...READ MORE

answered May 29, 2019 in Selenium by Shreya
2,919 views
0 votes
1 answer

How can I store data into a cookie using Selenium Webdriver?

Hey Abhilasha, we can load a website ...READ MORE

answered Jun 19, 2019 in Selenium by Anvi
• 14,150 points
3,222 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,772 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,187 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,263 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,902 views
0 votes
1 answer

How can we read data from an excel sheet in Selenium webdriver?

Hi Tarun, to read data from an ...READ MORE

answered May 8, 2019 in Selenium by Abha
• 28,140 points
17,596 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP