Selenium and Java

Wednesday, 24 June 2015

Selenium - Excel creation using APACHE POI in selenium Webdriver framework

Code to create Excel sheet at run time using APACHE POI..


String filepath = "D:\\Mohit1.xls";

FileOutputStream fileout = new FileOutputStream(filepath);

Workbook workbook = new HSSFWorkbook();
Sheet sheet = workbook.createSheet();

Row row;
Cell cell;
for (int i=0 ; i< 4 ; i++){

row = sheet.createRow(i);
for (int j =0 ; j<3 ;j++){

cell = row.createCell(j);
cell.setCellValue("data"+ i + j);
}
}

workbook.write(fileout);

No comments:

Post a Comment