title: Apache POI insert amount in the next blank line
body: <p><strong>Update</strong>
  The response of CENIC worked but now the spreadsheet is writing the data several times when I press the save button and not just one, follows updated code.</p>
  
  <pre><code>//Read the spreadsheet that needs to be updated
          FileInputStream input_document = new FileInputStream(new File("sdcard/AperamApps/DBQ/DBQmestre/historico/historico.xls"));
          //Access the workbook
          HSSFWorkbook my_xls_workbook = new HSSFWorkbook(input_document); 
          //Access the worksheet, so that we can update / modify it.
          HSSFSheet my_worksheet = my_xls_workbook.getSheetAt(0); 
  
  
  
          {
  
  
         Row newRow = my_worksheet.createRow(my_worksheet.getLastRowNum() + 1);
         newRow.createCell(0).setCellValue("Unidade Metálica");
         newRow.createCell(1).setCellValue("Local");
         newRow.createCell(2).setCellValue("Posição");
         newRow.createCell(3).setCellValue("Empilhamento");
         newRow.createCell(4).setCellValue("Hora Recebida");        
         newRow.createCell(5).setCellValue("Hora Realizado");
  
         Row header = my_worksheet.createRow(my_worksheet.getLastRowNum() + 1);
         header.createCell(0).setCellValue(item1);
         header.createCell(1).setCellValue(local1);
         header.createCell(2).setCellValue(posicao1);
         header.createCell(3).setCellValue(emp1);
         header.createCell(4).setCellValue(hr);
         header.createCell(5).setCellValue(timeStamp); 
          }
  
  
          input_document.close();
  
          //Open FileOutputStream to write updates
          FileOutputStream output_file =new FileOutputStream(new File("sdcard/AperamApps/DBQ/DBQmestre/historico/historico.xls"));
          //write changes
          my_xls_workbook.write(output_file);
          //close the stream
          output_file.close();
  </code></pre>
  
  <p><strong>Print</strong>
  <a href="http://i.stack.imgur.com/Dhvzq.png" rel="nofollow">https://uploaddeimagens.com.br/images/000/537/859/full/Sem_t%C3%ADtulo.png?1446470667</a></p>
  
  <p>I am developing an application that writes data into an excel spreadsheet to save a historic , but I'm not getting in any way cause the data to be inserted into the blank next line , follows the code where you desire to accomplish this feat .</p>
  
  <pre><code>public void salvar1acao (View view) throws IOException, BiffException, WriteException {
  
      String item1 = ((String) txtcoluna1.getText().toString());
      String local1 = ((String) txtlocal1.getText().toString());
      String posicao1 = ((String) txtposicao1.getText().toString());
      String emp1 = ((String) txtemp1.getText().toString());
  
      Workbook workbook = Workbook.getWorkbook(new File("sdcard/AperamApps/DBQ/DBQmestre/p-comando.xls"));
      WritableWorkbook copy = Workbook.createWorkbook(new File("sdcard/AperamApps/DBQ/DBQmestre/p-comando.xls"), workbook);
  
      //Trabalhando com a API POI para escrever de forma mais eficiênte no histórico
      String timeStamp = new SimpleDateFormat("dd/MM/yyyy_HH:mm:ss",
              Locale.getDefault()).format(new Date());
  
      HSSFWorkbook historico = new HSSFWorkbook();
      HSSFSheet sheet = historico.createSheet("Histórico");
  
      @SuppressWarnings("unused")
      boolean linha = historico.getSheet(null) != null;
  
  
  
     Row dataRow = sheet.createRow(0);
     dataRow.createCell(0).setCellValue("Unidade Metálica");
     dataRow.createCell(1).setCellValue("Local");
     dataRow.createCell(2).setCellValue("Posição");
     dataRow.createCell(3).setCellValue("Empilhamento");
     dataRow.createCell(4).setCellValue("Hora Recebida");        
     dataRow.createCell(5).setCellValue("Hora Realizado");
  
      Row header = sheet.createRow(1);
      header.createCell(0).setCellValue(item1);
      header.createCell(1).setCellValue(local1);
      header.createCell(2).setCellValue(posicao1);
      header.createCell(3).setCellValue(emp1);
      header.createCell(5).setCellValue(timeStamp);
  
  
  
      try {
          FileOutputStream out = 
                  new FileOutputStream(new File("sdcard/AperamApps/DBQ/DBQmestre/historico/historico.xls"));
          historico.write(out);
          out.close();
          System.out.println("Gravado com sucesso..");
  
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>The basic rationale is as follows , if the row has any value , write in row 2, row 2 is writing any value in row 3 and so on. Sorry for my English automatic translation.</p>