Read Data From Excel Using Column Number

Published: 17 December 2016
on channel: Krishna Sakinala
16,763
120

Please use the following link to install the Katalon Studio:

https://katalon.com/sign-up?getr=kris... Check Tubebuddy Features Here:
https://www.tubebuddy.com/krishnasaki... Facebook :   / automationtesting2016  
Linkedin :   / krishnasakinala  
Google+ : https://plus.google.com/1052863009260...
Twitter : https://www.linkedin.com/feed/?trk=hb...
http://automationtesting.in/read-data...

Read data from excel using column number will discuss about how we can read test data from the excel sheet while automating any application using selenium webdriver. We might get doubt that why we need to put the test data in excel and why to read data from that. If an application need so much of data to be feed to test; then we will manage those data using external sources like text file, xml file and excel file etc… . Among these; Excel is very user friendly that we can organize the data very easily and we can read the data how we want. So, we mostly use excel to maintain the test data. In order to create a data driven framework then it is easy with using excel.
[Blog related Video]
So, if you want to read data from excel; we need to use some third party API which are available. In those one of the famous is Apache POI. In this blog we will use Apache POI to read the data from the excel sheet. To interact with the excel, Apache POI given so many classes to interact with the excel and get the data. To read excel data we will use Java and Apache POI classes.

Below are the classes will use to read the data:

FileInputStream – A FileInputStream is an inputstream for reading data from a File.
XSSFWorkbook
XSSFSheet
XSSFRow
XSSFCell






Below are the methods will use to read the data which are available in the above classes:

getSheet(“sheetName”) – Get sheet with the given name
getLastCellNum() – Get the index of the last cell contained in the row Plus one as index starts from ZERO
getStringCellValue() – Get the value of the cell as a String
getRow(int) – Returns the row.
getCell(int) – Get the cell representing a given column
getNumericCellValue() – Get the value of the cell as a number.
getDateCellValue() – Get the value of the cell as a date.
getBooleanCellValue() – Get the value of the cell as a boolean.