title: Apache POI Focus on a particular cell in generated excel file
body: <p>Hi I am using apache poi to generate excel files. I am using XSSFWorkbook format. I am trying to make focus on the first cell of the generated excel file.</p>
  
  <p>I have tried the following code snippet.</p>
  
  <pre><code>        try {
                  Sheet sheet = workbook.getSheetAt(0);
                  workbook.setActiveSheet(0);
                  Cell cell = sheet.getRow(0).getCell(0);
                  cell.setAsActiveCell();
                  sheet.setActiveCell(cell.getAddress());
                  sheet.showInPane(0, 0);
              } catch (IllegalArgumentException e) {
                  LOGGER.error("Failed to set active sheet and cell.", e);
              }
  </code></pre>
  
  <p>I have looked at this <a href="https://stackoverflow.com/questions/5459852/apache-poi-set-selected-cell-after-xls-document-opens">SO question</a> as well. The solution doesn't seem to work for me. Can anyone please help me here?</p>
  
  <p>P.S: I am using apache poi version 3.15.</p>
  
  <p>Update 1:</p>
  
  <p>I also have a freeze pane with top left cell as C1. The freeze was not being shown properly.</p>
  
  <p>I have tried the following code</p>
  
  <pre><code>public void setActiveCell(Workbook workbook, int sheetIndex, int row, int column) {
          Sheet sheet = workbook.getSheetAt(sheetIndex);
          CellAddress cellAddress = new CellAddress(row, column);
  
          sheet.createFreezePane(2, 0);
          ((XSSFSheet) sheet).getCTWorksheet().getSheetViews().getSheetViewArray(0).getPane()
              .setTopLeftCell("C1");
          ((XSSFSheet) sheet).setActiveCell(cellAddress);
  
  //        ((XSSFSheet) sheet).getCTWorksheet().getSheetViews().getSheetViewArray(0)
  //            .setTopLeftCell(cellAddress.formatAsString());
  //        ((XSSFSheet) sheet).setActiveCell(cellAddress);
  }
  </code></pre>
  
  <p>I am calling the above code as <code>setActiveCell(workbook, 0, 0, 0);</code>. It is assured that the workbook is not null and contains atleast one sheet. The above code shows neither the C1 cell (the top left cell of the created pane) nor the A1 cell (the active cell set).</p>
  
  <p>Update 2:</p>
  
  <p>Based on the answer from @AlexRichter, the following code works for me:</p>
  
  <pre><code>public void setActiveCell(Workbook workbook, int sheetIndex, int row, int column) {
          Sheet sheet = workbook.getSheetAt(sheetIndex);
          CellAddress cellAddress = new CellAddress(row, column);
  
          sheet.createFreezePane(2, 0);
          ((XSSFSheet) sheet).getCTWorksheet().getSheetViews().getSheetViewArray(0).getPane()
              .setTopLeftCell("C1");
  
          ((XSSFSheet) sheet).getCTWorksheet().getSheetViews().getSheetViewArray(0)
              .setTopLeftCell(cellAddress.formatAsString());
  }
  </code></pre>