Saturday, 12 May 2018

Excel Codes for selenium - Draft


10) //Read Excel file             
File src = new File("C:\\Selenium\\Datasheet.xlsx");       
FileInputStream fis = new FileInputStream(src);       
XSSFWorkbook wb = new XSSFWorkbook(fis);       
XSSFSheet sh = wb.getSheetAt(0);       
int TotalRowCount = sh.getLastRowNum();

11)//Read Excel Cell Value       
String cellValueUsername = sh.getRow(1).getCell(0).getStringCellValue();       
System.out.println(cellValueUsername);

12) //Write Excel File         
FileOutputStream Fout = new FileOutputStream(new File( "C:\\Selenium\\Datasheet.xlsx"));
wb.write(Fout);       
Fout.close();

No comments:

Post a Comment