Interview Questions

Selenium WebDriver - Write the code for Reading and Writing to Excel through Selenium ?

Selenium WebDriver Interview question and Answers


(Continued from previous question...)

Selenium WebDriver - Write the code for Reading and Writing to Excel through Selenium ?

FileInputStream fis = new FileInputStream(“path of excel file”); Workbook wb = WorkbookFactory.create(fis); Sheet s = wb.getSheet("sheetName"); String value = s.getRow(rowNum).getCell(cellNum).getStringCellValue(); // read data s.getRow(rowNum).getCell(cellNum).setCellValue("value to be set"); //write data FileOutputStream fos = new FileOutputStream(“path of file”); wb.write(fos); //save file
FileInputStream fis = new FileInputStream(“path of excel file”);
Workbook wb = WorkbookFactory.create(fis);
Sheet s = wb.getSheet("sheetName");
String value = s.getRow(rowNum).getCell(cellNum).getStringCellValue(); // read data
s.getRow(rowNum).getCell(cellNum).setCellValue("value to be set"); //write data
FileOutputStream fos = new FileOutputStream(“path of file”);
wb.write(fos); //save file

(Continued on next question...)

Other Interview Questions