title: Unable to Save Excel File Using C#
body: <p>I'm trying to modify and save data in Excel.  With the code below, I'm accessing the sheet, performing modifications, then saving the file.  I'm unable to save the file. Here is my code:</p>
  
  <pre><code>Application excel = new Application();
          excel.Visible=true;
          Workbook wb = (Workbook)excel.Workbooks.Open(@"C:\Users\dnyanesh.wagh\Desktop\BookExcel1.xlsx");
          Worksheet ws = (Worksheet)wb.Worksheets[1];
          ws.Cells[1, 1] = "sagar";
          ws.Cells[2, 1] = "sagar";
          ws.Cells[3, 1] = "sagar";
          wb.Save();
          wb.close();
  </code></pre>
  
  <p>I'm receiving this error:  "the file named 'BookExcel1.xlsx' already exists in this location.  Do you want to replace it?"</p>
  
  <p>So I changed the code to:</p>
  
  <pre><code>Workbook wb = (Workbook)excel.Workbooks.Open(@"C:\Users\dnyanesh.wagh\Desktop\BookExcel1.xlsx",0, false, 5, "", "",
              false, XlPlatform.xlWindows, "", true, false,
              0, true, false, false););
  </code></pre>
  
  <p>Then error is: "BookExcel1.xlsx is being modified by user_name.open as read only".  If I click the 'cancel' button, I receive the exception above with "Exception from HRESULT: 0x800A03EC"</p>
  
  <p>I have also tried:</p>
  
  <pre><code>wb.SaveAs(@"C:\Users\dnyanesh.wagh\Desktop\BookExcel1.xlsx");
  wb.Close(true,null,null);
  </code></pre>
  
  <p>From that I receive the same error, with the above file showing the modifications.</p>
  
  <p>Can anybody tell me how can I save the file with modifications?</p>