title: Why the data write by poi in excel file was missing after I write this file again?
body: <p>I write a method "writeData" to write a column data from an existing excel file into a new excel file by apache poi. It works well. But when I try to call this method again, the previous data was missing. Why? Does anybody can help me?</p>
  
  <pre><code>public class ReadData {
  
      /**
       * @param args
       */
      Workbook wb, wb1;
      Sheet sheet, sheet1;
      Row row;
      Row row1;   
      static int cell;
      Cell cell1;
  
  
      static ArrayList&lt;Cell&gt; list1 = new ArrayList&lt;Cell&gt;();
      static ArrayList&lt;Cell&gt; list2 = new ArrayList&lt;Cell&gt;();
  
  
  
      public static ArrayList&lt;Cell&gt; readData(String filename, int cellNum, ArrayList array){
  
      try{        
  
          InputStream inp = new FileInputStream(filename);
          Workbook wb = WorkbookFactory.create(inp);
          Sheet sheet = wb.getSheetAt(0);
  
  
  
          for (int j=sheet.getLastRowNum(); j&gt;0; j--) {
  
              Row row = sheet.getRow(j);
              Cell cell = row.getCell(cellNum);
  
  
              array.add(cell);
  
  
  
              System.out.println(cell);
  
          }
  
  
      }catch(Exception e){
          System.out.println("Wrong!" + e.getMessage());
          e.getStackTrace();
          System.out.println(e.getStackTrace());
          }
      return array;
      }
  
  
      public static void writeData(int cellNo, ArrayList&lt;Cell&gt; array){
  
  
          Workbook wb1 = new HSSFWorkbook();
          FileOutputStream fos = null;
  
              try{
                  fos = new FileOutputStream("3.xls");
                  Sheet sheet1 = wb1.createSheet("Data");
  
  
  
                  for(int i = 0; i &lt; array.size(); i++){
                  Row row1 = sheet1.createRow(i);
                  Cell cell1 = row1.createCell(cellNo);
                  cell1.setCellValue(array.get(i).getNumericCellValue());
                  }
  
                  wb1.write(fos);
                  fos.close();
  
                  }catch (FileNotFoundException e) {
                          e.printStackTrace();
                      } catch (IOException e) {
                          e.printStackTrace();
                      }
                      }
  
  
  
      public static void main(String[] args) {
  
      readData("1.xls",0,list1);  
      writeData(0,list1);
      readData("2.xls",0,list2);  
      writeData(1,list2);
  }
  
  }
  </code></pre>