Exportar a excel en vb.net
Bueno, lo que realizaremos a continuacion es exportar un DataGridView a excel, les explico. Primero se crea un proceso para realizar esta accion, el cual leera toda la informacion contenida en el Grid, y lo cuadara en una tabla: Dim drow As DataRow Dim col As Integer Dim r As String Dim dtable, dtable2 As New DataTable Dim fila As Integer dtable.Clear() dtable.Columns.Clear() 'Se crea un ciclo para los encabezados For col = 0 To dgw.Columns.Count - 1 If dgw.Columns(col).Visible = True Then r = dgw.Columns(col).HeaderText.ToString dtable.Columns.Add(New DataColumn(r, GetType(String))) End If Next drow = Nothing col = 0 'Llenamos los registrod del table For fila = 0 To dgw.Rows.Count - 1 drow = dtable.NewRow() For col = 0 To dgw.Columns.Count - 1 If dgw.Columns(col).Visible = True Then drow(dgw.Columns(col).HeaderText.ToString) = CStr(dgw.Item(col, fila).Value) End If Next dtable.Rows.Add(drow) Next Try Dim iExp As New Funciones iExp.TablaExcel(dtable) Catch ex As Exception MsgBo...