title: How can I write Test Result (Pass/Fail) in Excel file using TestNG Framework with Selenium WebDriver?
body: <p>How can I write result in Excel using Selenium WebDriver?</p>
  
  <pre><code>public static void writeData(String pathOfFile, String sheetName, int rowNum, int cellNum, String value) throws InvalidFormatException, IOException{
      FileInputStream fis = new FileInputStream("C:\\Users\\harini.b\\Desktop\\Copy of Login.xls");
      Workbook wb = WorkbookFactory.create(fis);
      wb.getSheet(sheetName).getRow(rowNum).createCell(cellNum).setCellValue(value);
      //wb.getSheet(sheetName).createRow(rowNum).createCell(cellNum).setCellValue(value); //use this if you are writing in new row.
      FileOutputStream fos = new FileOutputStream(pathOfFile);
      wb.write(fos);
  }
  </code></pre>