0

Could someone please help me how to append data to excel sheet. I have tried with using jxl.jar file .

But every time it creates new sheet. I want to use the existing excel sheet and need to append my data every time my test runs.

Here is the code I'm using, that creates a new sheet everytime:

   Workbook aWorkBook = Workbook.getWorkbook(new File("C:/Automation/Testdata.xls"));
   WritableWorkbook aCopy = Workbook.createWorkbook(new File("C:/Automation/TestResult.xls"), aWorkBook);
   WritableSheet aCopySheet = aCopy.getSheet(0);//index of the needed sheet
   jxl.write.Label anotherWritableCell =  new jxl.write.Label(row+36, col ,"Pass");
   aCopySheet.addCell(anotherWritableCell);
   aCopy.write();
   aCopy.close();
Seanny123
  • 8,776
  • 13
  • 68
  • 124

1 Answers1

0

The problem is unrelated to Selenium. Your issue is with correctly appending data to an Excel sheet. The problem has been discussed before and solved here: https://stackoverflow.com/a/9389397/170781.

Community
  • 1
  • 1
Eric Tobias
  • 3,225
  • 4
  • 32
  • 50