title: Unable to Save Changes to Excel File (C# /)
body: <p>I've been trying to modify an Excel file called "Hoja de Resultados" adding three different variables each time (Puntuacion = Score, Fecha = Date, Hora = Time) inside of Visual Studio (C#). The excel sheet is linked to a DataGridView window which updates everytime the values are changed. The problem is, when there are less than 3 rows on the excel sheet, the program stops modifying the XLSX and sometimes it throws a seemingly random exception on "Program.cs".</p>
  
  <pre><code>string Direccion = "G:\\Archivos\\Programación\\Visual Basic\\UVG\\Microcontroladores - Proyecto Final Comunicación Serial\\Hoja de Resultados.xlsx";
  Microsoft.Office.Interop.Excel.Application ExcelApp = new Microsoft.Office.Interop.Excel.Application();
  Microsoft.Office.Interop.Excel.Workbook Hoja = ExcelApp.Workbooks.Open(Direccion);
  Microsoft.Office.Interop.Excel.Worksheet HojaActiva = ExcelApp.ActiveSheet as Microsoft.Office.Interop.Excel.Worksheet;
  
  Excel.Range Rango = HojaActiva.UsedRange;
  int Posicion = Rango.Rows.Count;
  int NuevaPosicion = Posicion + 1;
  HojaActiva.Cells[NuevaPosicion, 1] = Puntuacion;
  HojaActiva.Cells[NuevaPosicion, 2] = Fecha;
  HojaActiva.Cells[NuevaPosicion, 3] = Hora;
  
  Hoja.Saved = true;
  ExcelApp.DisplayAlerts = false;
  ExcelApp.ScreenUpdating = false;
  ExcelApp.Visible = false;
  ExcelApp.UserControl = false;
  ExcelApp.Interactive = false;
  
  Hoja.Close(true, Type.Missing, Type.Missing);
  Marshal.ReleaseComObject(Hoja);
  Marshal.ReleaseComObject(HojaActiva);
  ExcelApp.Quit();
  </code></pre>
  
  <blockquote>
    <p>Sorry if it's partially in Spanish. But for some guidance: </p>
    
    <ul>
    <li>Hoja = Workbook</li>
    <li>HojaActiva = ActiveWorkbook</li>
    </ul>
  </blockquote>