mardi 20 décembre 2016

How to read a cell value randomly using random function from an excel file in Java?

I have an excel sheet having 10 entries , 0-9 rows & 0 columns. I want to read a random value from the cell of (5,0) ex (row, column) using random function ? Below is the code i tried !

FileInputStream fis = new FileInputStream("C://Users//logasaravanan.g//Desktop//seleniumtest.xls");
HSSFWorkbook wb = new HSSFWorkbook(fis);
HSSFSheet sheet = wb.getSheet("xxxx");
Random rand = new Random();
int a= rand(sheet.getLastRowNum());
HSSFRow row = sheet.getRow(a);
System.out.println("Running test case " + row.getCell(0).toString());




Aucun commentaire:

Enregistrer un commentaire