public void atualizar(Jogo jogo) { for (int i = 1; i <= planilha.getSheet("Jogos").getLastRowNum(); i++) { if (planilha.getSheet("Jogos").getRow(i).getCell(0).getNumericCellValue() == jogo.getID()) { HSSFRow novaRow = this.planilha.getSheet("Jogos").createRow(i); novaRow.createCell(1).setCellValue(jogo.getNome()); novaRow.createCell(2).setCellValue(jogo.getConsole()); novaRow.createCell(3).setCellValue(jogo.getPrecoCompra()); novaRow.createCell(4).setCellValue(jogo.getPrecoVenda()); novaRow.createCell(5).setCellValue(jogo.getQuantidade()); novaRow.createCell(6).setCellValue(jogo.getGenero()); FileOutputStream nFile = null; try { nFile = new FileOutputStream("Jogos.xls"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { this.planilha.write(nFile); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { nFile.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }