Data retriving and Data writing using Jxl jar file in selenium

Test Automation 0 Comment 45

 Jxl is available as jar file. It  is the most widely used API for executing Selenium data-driven tests, which allows users to read, write, create, and modify sheets in an Excel(.xls) workbook at runtime. It is useful to access .xls file only.


  • Reads data from Excel 95, 97, 2000, XP, and 2003 workbooks
  • Reads and writes formulas (Excel 97 and later only)
  • Generates spreadsheets in Excel 2000 format
  • Supports font, number and date formatting
  • Supports shading, bordering, and coloring of cells
  • Modifies existing worksheets
  • Is internationalized, enabling processing in almost any locale, country, language, or character encoding (formulas are currently only supported in English, French, Spanish, and German, but more can be added if translated)
  • Supports copying of charts
  • Supports insertion and copying of images into spreadsheets
  • Supports logging with Jakarta Commons Logging, log4j, JDK 1.4 Logger, etc


How to download and configure  Jxl jar file with eclipse IDE

Download jxl Zip file from click here (57KB)).

Extract files from zip file and save in a folder.

Now launch Eclipse IDE and go to the project.

Right click on project—>go to properties—>java buildpath—>libraries—>add external  libraries–>browse jxl jar file.


.xls sheet

0th row Input 1 Input 2  Output
1st row XX  XX
2nd row XX  XX
3rd row XX  XX
4th row XX  XX
5th row XX  XX
6th row XX  XX

Output= Input 1+Input 2

From above table we have to read data (Input 1,2) and write the output in the same sheet with the help of jxl in selenium.


public class Jxl {

public static void main (String[] args) throws JXLException, IOException

File f =new File(“E:\\Yamini\\xl\\xx.xls”);

Workbook rwb = Workbook.getWorkbook(f);
Sheet rsh = rwb.getSheet(0);
int nor = rsh.getRows();
WritableWorkbook wwb = Workbook.createWorkbook(f, rwb);
WritableSheet wsh = wwb.getSheet(0);
for (int i=1;i<nor;i++)
int x = Integer.parseInt(rsh.getCell(0 ,i).getContents());
int y= Integer.parseInt(rsh.getCell(1, i).getContents());
int z=x+y;
Number n =new Number (2,i,z);



Leave a comment

You must be logged in to post a comment.

© 2016 4frienz. Powered By Flowers

Back to Top