title: Unable to write to an excel (Selenium WebDriver) - Apache POI
body: <p>I am new to Selenium Web automation please be soft on me.</p>
  
  <p>I have created a method to write an array content to an excel sheet.
  I get no exception or error and I don't see data being written to excel sheet.</p>
  
  <p>Name of excel sheet-mysheet.xlsx
  Name of sheet within excel workbook:"FirstLevelMenu"</p>
  
  <pre><code>public class WriteExcelData {
      XSSFWorkbook wb;
      XSSFSheet sheet;
  
      public void writeData(String path, String sheetName, String[] data) {
  
          try {
              File src = new File(path);
              FileInputStream fis = new FileInputStream(src);
              wb = new XSSFWorkbook(fis);
              sheet = wb.getSheet(sheetName);
              int rowCount = sheet.getLastRowNum() - sheet.getFirstRowNum();
              Row row = sheet.getRow(0);
              Row newRow = sheet.createRow(rowCount + 1);
              for (int j = 0; j &lt; row.getLastCellNum(); j++) {
                  Cell col = newRow.createCell(j);
                  col.setCellValue(data[j]);
              }
              fis.close();
              FileOutputStream fout = new FileOutputStream(src);
              wb.write(fout);
              fout.close();
          } catch (Exception e) {
              e.getMessage();
          }
      }
  
      public static void main(String[] args) {
          WriteExcelData test=new WriteExcelData();
          String[] data=new String[2];
          data[0]="cat";
          data[1]="cat";
  
          test.writeData("C:\\mysheet.xlsx", "FirstLevelMenu", data);
      }
  }
  </code></pre>
  
  <p></p>