title: How can I write to an excel file continuously?
body: <p>I would like to create and write continuosly to an Excel file. I have to code below, but I want to add all the datas which I get continuously.</p>
  
  <p>CODE:</p>
  
  <pre><code>        Excel.Application xlApp ;
          Excel.Workbook xlWorkBook ;
          Excel.Worksheet xlWorkSheet ;
          object misValue = System.Reflection.Missing.Value;
  
          xlApp = new Excel.Application();
          xlWorkBook = xlApp.Workbooks.Add(misValue);
  
          xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
          xlWorkSheet.Cells[1, 1] = "http://csharp.net-informations.com";
  
          xlWorkBook.SaveAs("csharp-Excel.xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
          xlWorkBook.Close(true, misValue, misValue);
          //xlApp.Quit();
  
          releaseObject(xlWorkSheet);
          releaseObject(xlWorkBook);
          releaseObject(xlApp);
  
          MessageBox.Show("Excel file created , you can find the file c:\\csharp-Excel.xls");
      }
  
      private void releaseObject(object obj)
      {
          try
          {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
              obj = null;
          }
          catch (Exception ex)
          {
              obj = null;
              MessageBox.Show("Exception Occured while releasing object " +     ex.ToString());
          }
          finally
          {
              GC.Collect();
          }
      }
  </code></pre>
  
  <p>In this code, when start the application, it always says that do you wanna replace it and it always closes the application when the program gets the data.</p>
  
  <p>This is the functionality which I want to have: I want to append the file like here.</p>
  
  <pre><code>    StreamWriter fileWriter = new StreamWriter("test.txt", true);
      fileWriter.WriteLine(jointHead.Position.X);       
      fileWriter.Close();
  </code></pre>
  
  <p>What can be the solution for this kind of problem? 
  Thank you...</p>