title: Java Update Existing Excel File
body: <p>I'm trying to write a program that will update existing Excel file.The problem i am having is it had not append texts to the file.Here is the relevant code:</p>
  
  <pre><code>import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import org.apache.poi.hssf.usermodel.HSSFSheet;
  import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
  import org.apache.poi.ss.usermodel.*;
  
  public class LC_negotiation {
  
    public static void LC_negotiation(){
      try { 
        FileInputStream file = 
          new FileInputStream(new File("D:\\home.xls"));
        HSSFWorkbook workbook = new HSSFWorkbook(file);
        HSSFSheet sheet = workbook.getSheetAt(0);
        Cell cell = null;
        cell = sheet.getRow(1).getCell(2);
        cell.setCellValue("Name");
        cell = sheet.getRow(2).getCell(2);
        cell.setCellValue("Address");
        file.close();
        FileOutputStream outFile =
          new FileOutputStream(new File("D:\\home.xls"));
        workbook.write(outFile);
        outFile.close();
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
    }
  
    public static void main(String[] args) { 
      LC_negotiation lc_one = new LC_negotiation();
    }
  
  }
  </code></pre>