title: Reading/Writing with Apache POI
body: <p>I just recently began using Apache POI to do some excel reading and writing and I am having a bit of an issue. I have a submit button reading form text fields and printing it to an excel file:</p>
  <pre><code>            HSSFWorkbook workbook = new HSSFWorkbook();
      HSSFSheet sheet = workbook.createSheet(&quot;Reservations&quot;);
          
          Map&lt;String, Object[]&gt; data = new TreeMap&lt;String, Object[]&gt;();
          
          data.put(&quot;1&quot;, new Object[] {&quot;Reservation ID&quot;, &quot;NAME&quot;, &quot;ARRIVAL DATE&quot;, &quot;LENGTH OF STAY&quot;,&quot;HOME ADDRESS&quot;, &quot;EMAIL&quot;, &quot;PHONE NUMBER&quot; ,&quot;RESERVATION TYPE&quot;});
          data.put(&quot;2&quot;, new Object[] {1, advanceLastField.getText(), arrivalDateForm.getText(), stayNum.getText(),advanceAddressForm.getText(), advanceEmailForm.getText(),advancePhoneForm.getText(),&quot;D&quot;});
                                                          
          Set&lt;String&gt; keyset = data.keySet();
          int rownum = 0;
          for (String key : keyset){
              Row row = sheet.createRow(rownum++);
              Object [] objArr = data.get(key);
              int cellnum = 0;
              for (Object obj : objArr){
                  Cell cell = row.createCell(cellnum++);
                  if(obj instanceof String)
                      cell.setCellValue((String)obj);
                  else if(obj instanceof Integer)
                      cell.setCellValue((Integer)obj);
              }
              
          }
          try{
              FileOutputStream out = new FileOutputStream(new File(&quot;testSheet.xls&quot;),true);
              workbook.write(out);
              out.close();
              System.out.println(&quot;Advance Reservation succesfully written&quot;);
          }catch (Exception e){
              e.printStackTrace();
          }
      }
      }
      }catch(NumberFormatException e){
          parsable1=false;
      }
  </code></pre>
  <p>This is functioning correctly, but my issue is trying to UPDATE the excel sheet afterwards. This is my update code:</p>
  <pre><code>FileInputStream inp = new FileInputStream(new File(&quot;testSheet.xls&quot;));
  HSSFWorkbook wb = new HSSFWorkbook(inp);
  HSSFSheet sheet = wb.getSheetAt(0);
  if (idLookup.getText() == &quot;1&quot;) {
      if (updateNameForm.getText() != null) {
          Row row = sheet.getRow(1);
          Cell cell = row.getCell(1);
          cell.setCellType(CellType.STRING);
          cell.setCellValue(updateNameForm.getText());
      }
  }
  FileOutputStream fileOut = new FileOutputStream(&quot;testSheet.xls&quot;, true);
  wb.write(fileOut);
  fileOut.close();
  </code></pre>
  <p>Can anyone give me a bit of insight or guidance?</p>