title: Apache Poi - createCell() Method doesn't accept index via for loop as parameter
body: <p>I want to create an Excel file with Apache Poi, based on the sheet of another Excel file. Only the first two columns and their corresponding rows should be applied to the new Excel sheet. </p>
  
  <p>First, I insert all cells of the first column, then I increment the columnIndex to insert the other cells.</p>
  
  <pre><code>private static void createNewWorkBook(XSSFSheet oldSheet) {
      XSSFWorkbook newWorkbook = new XSSFWorkbook();
  
      XSSFSheet newSheet = newWorkbook.createSheet("test-sheet");
      for (int columnIndex = 0; columnIndex &lt; 2; columnIndex++) {
          int rowIndex = 0;
          for (Row oldRow : oldSheet) {
              XSSFRow newRow = newSheet.createRow(rowIndex);
              XSSFCell newCell = newRow.createCell(columnIndex); 
              newCell.setCellValue("Hello"); // just for test purposes
  
              // newCell.setCellValue(oldSheet.getRow(rowIndex).getCell(columnIndex).getStringCellValue());
  
              rowIndex++;
          }
  
      }
  
      try {
          FileOutputStream fos = new FileOutputStream(new File("CreateExcelDemo.xlsx"));
          newWorkbook.write(fos);
          fos.close();
      } catch (
              IOException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>Unfortunatley it doesn't work. I only get the values of the second column in my newly generated excel-sheet. The  first column is just empty.</p>
  
  <p>BUT:
  If I replace the columnIndex with 0 or 1, it works! Where is my thinking problem? </p>