title: How to append to an existing Excel file without overwriting it using C#?
body: <pre><code>private void newsubmit_Click(object sender, EventArgs e)
  {
      int y;
      string[] range;
      range = new string[999];
  
      if ( newid.Text != null)
      {
          Excel.Application xlApp;
          Excel.Workbook xlWorkBook;
          Excel.Worksheet xlWorkSheet;
  
          xlApp = new Excel.Application();
          xlWorkBook = xlApp.Workbooks.Open(@"C:\Users\Administrator\Desktop\coach ceazar\CLIENTS", 0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", true, false, 0, true, 1, 0);
          xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
  
          object misValue = System.Reflection.Missing.Value;
  
          for (y = 1; y &lt; xlWorkSheet.UsedRange.Columns.Count; y++)
          {
              xlWorkSheet.Cells[y][newid.Text].copy();
              range[y] = Clipboard.GetText();
          }
  
          xlApp.UserControl = false;
          xlWorkBook.Close(false);
  
          xlWorkBook =  xlApp.Workbooks.Open(@"C:\Users\Administrator\Desktop\coach ceazar\classes\" + classes[classnumber-1].Text+".xls", 0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", true, false, 0, true, 1, 0);
          xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
  
          for (int w = 1; w &lt; y; w++)
          {
              xlWorkSheet.Cells[w][xlWorkSheet.UsedRange.Rows.Count+1]=range[w];
          }
  
          xlApp.UserControl = false;
          xlWorkBook.Save();
          xlApp.Visible = true; 
      }
      else MessageBox.Show("please enter the id to be enrolled!");
  }
  </code></pre>
  
  <p>I am trying to copy an entire row from one Excel file to another using C#. This is my current code, but each time the code runs, it is overwriting what was already in the Excel file. It has really frustrated me - can anyone please help?</p>