-I get this error when opening the datagrid export to excel, will a library be necessary to correct this error?
I need to export a datagrid that brings me a Select query with 251 rows to Excel, I have a code to do it but it happens that when there are many rows, the program stops:
Public Function GridAExcel(ByVal ElGrid As DataGridView) As Boolean
''Creamos las variables
Dim exApp As New Microsoft.Office.Interop.Excel.Application
Dim exLibro As Microsoft.Office.Interop.Excel.Workbook
Dim exHoja As Microsoft.Office.Interop.Excel.Worksheet
Try
''Añadimos el Libro al programa, y la hoja al libro
exLibro = exApp.Workbooks.Add
exHoja = exLibro.Worksheets.Add
'' ¿Cuantas columnas y cuantas filas?
Dim NCol As Integer = ElGrid.ColumnCount
Dim NRow As Integer = ElGrid.RowCount
''Aqui recorremos todas las filas, y por cada fila todas las columnas y vamos escribiendo.
For i As Integer = 1 To NCol
exHoja.Cells.Item(1, i) = ElGrid.Columns(i - 1).Name.ToString
End Function
This is the error that comes to me, I do not know what the truth may be, I already import the library in the form and in the class.