title: Creates a new excel file while inserting other time in excel file in c# windows form.
body: <p>I have this below function which inserts value to particualr cell in excel file. When i call this function second time it opens a new excel file and both time the value is entered into differnt excel file. How to have open single excel file and both of my value are entered into same excel file.</p>
  
  <pre><code>   private bool insertIntoExcel(string pathname , string sheetname ,int excelRow, int excelColumn,string value) 
              {
                  try
                  {
  
                      Microsoft.Office.Interop.Excel._Application oXL = new Microsoft.Office.Interop.Excel.Application();
  
                      oXL.Visible = true;
  
                      oXL.DisplayAlerts = false;
  
                      Microsoft.Office.Interop.Excel.Workbook mWorkBook = oXL.Workbooks.Open(pathname, 0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
  
                      //Get all the sheets in the workbook
  
                      Microsoft.Office.Interop.Excel.Sheets mWorkSheets = mWorkBook.Worksheets;
  
                      //Get the allready exists sheet
  
                      Microsoft.Office.Interop.Excel._Worksheet mWSheet1 = (Microsoft.Office.Interop.Excel.Worksheet)mWorkSheets.get_Item(sheetname);
  
                      Microsoft.Office.Interop.Excel.Range range = mWSheet1.UsedRange;
  
  
                      mWSheet1.Cells[excelRow, excelColumn] = value;                      
  
                  }catch
                  {
                      return false;
                  }
                  return true;
  
              }
  </code></pre>