Read data from excel file using Selenium Webdriver

package com.zedo.Testing;

import java.io.File;
import java.io.IOException;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import org.testng.annotations.Test;

public class TestRead {

@Test
public void TestReadData(){

File src=new File("D:\\Scripts\\myexceldata.xls");

try {

Workbook wb=Workbook.getWorkbook(src);

Sheet sh= wb.getSheet(0);

Cell c=sh.getCell(0,0);

String data=c.getContents();

System.out.println("Data contains: --- "+data);

} catch (BiffException e) {

e.printStackTrace();

} 
catch (IOException e)
{ 
e.printStackTrace();
}
}
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *