title: Not able to write excel row column (apache poi) by multiple for loop
body: <p>I have a xlsx file which has multiple sheet i am using apache poi for writing excel, in sheet2 i have 2 columns 
  each column i want to populate by running a for loop , but i see that only last for loop get written previous one get blank in final written output file, i want to write both column by these for loop please help .</p>
  
  <pre><code>for(int  i=0;i&lt;fileNamesArray.length;i++)
      {
          XSSFRow row = worksheet1.createRow(i+1);
          cell = row.createCell(0);
  
          cell.setCellValue(fileNamesArray[i].toString());
  
      }//this dont get written 
  
  
  
      for(int i=0;i&lt;fileDatesArray.length;i++)
      {
          XSSFRow row = worksheet1.createRow(i+1);
          cell = row.createCell(1);
          cell.setCellValue(fileDatesArray[i].toString());
  
      }//only this get written
  </code></pre>
  
  <p>this is complete code </p>
  
  <pre><code>    public class DashBoard {
  
      public void writeDashBoard() throws IOException, SQLException
      {
          CODToolUtil codToolUtil = new CODToolUtil();
          // Read property file to initialize constants
          String templateDashBoardFile = codToolUtil.getPropValues("templateDashBoardFile");
          String outputDir = codToolUtil.getPropValues("outputDir");
          String dirSeprator = codToolUtil.getPropValues("dirSeprator");
          String fdate = CODToolUtil.getDate();
          CODDAO coddao=new CODDAO();
          LinkedHashSet&lt;String&gt; hs= new LinkedHashSet&lt;String&gt;();
          LinkedHashSet&lt;String&gt; hs1= new LinkedHashSet&lt;String&gt;();
          FileInputStream fsIP= new FileInputStream(new File(templateDashBoardFile)); //Template file
          XSSFWorkbook wb = new XSSFWorkbook(fsIP);
  
          XSSFSheet worksheet = wb.getSheetAt(0);
  
  
  
          Cell cell = null; 
  
          cell = worksheet.getRow(1).getCell(0);
          cell.setCellValue(CODToolUtil.getDate());//Date
          cell = worksheet.getRow(1).getCell(1);
          int allfiles=coddao.getAllfiles();
          cell.setCellValue(allfiles);//All Files
  
          cell = worksheet.getRow(1).getCell(2);
          int callfilesY=coddao.getAllProcessedfilesCallY();
          cell.setCellValue(callfilesY);//All Y Files
  
          cell = worksheet.getRow(1).getCell(3);
          int callfilesN=coddao.getAllProcessedfilesCallN();
          cell.setCellValue(callfilesN);//All N Files
  
          cell = worksheet.getRow(1).getCell(4);
          int allLTE=coddao.getAllProcessedfilesLTE();
          cell.setCellValue(allLTE);//All LTE Files
  
          cell = worksheet.getRow(1).getCell(5);
          int allWCDMA=coddao.getAllProcessedfilesWCDMA();
          cell.setCellValue(allWCDMA);//All WCDMA Files
          //Sheet 0 OverView Complete
          //Sheet 1 Successfull CT
          XSSFSheet worksheet1 = wb.getSheetAt(1);
  
          hs=coddao.getAllProcessedfilesNameY();
          hs1=coddao.getAllProcessedfilesDateY();
          Object[] fileNamesArray =  hs.toArray();
          Object[] fileDatesArray =  hs1.toArray();
  
  
  
  
  
          for(int  i=0;i&lt;fileNamesArray.length;i++)
          {
              XSSFRow row = worksheet1.createRow(i+1);
              cell = row.createCell(0);
  
              cell.setCellValue(fileNamesArray[i].toString());
  
          }//this dont get written 
  
  
  
          for(int i=0;i&lt;fileDatesArray.length;i++)
          {
              XSSFRow row = worksheet1.createRow(i+1);
              cell = row.createCell(1);
              cell.setCellValue(fileDatesArray[i].toString());
  
          }//only this get written
  
  
  
          fsIP.close();
          File saveDirectory = new File(outputDir);// Create OutPutDirectory
          saveDirectory.mkdir();
          String savefilePath = saveDirectory.getAbsolutePath();
          FileOutputStream output_file = newFileOutputStream(newFile(savefilePath+dirSeprator+fdate+"-"+templateDashBoardFile)); // save in output
          wb.write(output_file); // write changes save it.
          output_file.close(); // close the stream
  
  
  
  
      }
  
  public static void main(String[] args) throws IOException, SQLException {
      new DashBoard().writeDashBoard();
  }
  }
  </code></pre>