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
2,405 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
• 27,930 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,090 points
810 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,330 points
1,116 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 28, 2019 in Selenium by Shreya
775 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,090 points
917 views
0 votes
1 answer

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,510 points
3,167 views
0 votes
1 answer
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,890 points
2,378 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,890 points
2,531 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
• 27,930 points
10,983 views