Write testcase result into Excel: The below code writes the result of the test case in the 8th column of the excel sheet by creating a new excel file test_results.xls
public void excelwrite(int row) throws BiffException,
IOException,
RowsExceededException,
WriteException {
Workbook
existingWorkbook = Workbook.getWorkbook(new File(
"D:\\Test
cases.xls"));
WritableWorkbook
workbookCopy = Workbook.createWorkbook(new File(
"D:\\Test_Results.xls"),
existingWorkbook);
WritableSheet
sheetToEdit = workbookCopy.getSheet("Sheetname");
WritableCell cell;
Label l = new Label(8, row, "Pass");
cell = (WritableCell) l;
sheetToEdit.addCell(cell);
workbookCopy.write();
workbookCopy.close();
existingWorkbook.close();
File firstFile = new File(
"D:\\Test
cases.xls");
firstFile.delete();
File oldFile = new File("D:\\Test_Results.xls");
oldFile.renameTo(new File(
"D:\\Test
cases.xls"));
} Contribute by Ch.Suma