¿Cómo exportar msflexgrid en excel con vb 2010?

Necesito que los datos que yo registro dentro de un msflexgrid sean exportados a excel, ya programe un boton, pero solo me muestra un solo registro de la tabla en toda la hoja de excel, y no puedo corregir eso, quiero que se esxporten todos los datos del flexgrid; este es mi código:

Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click

If Exportar_Excel(Application.ExecutablePath & ".xls", Factura) Then
MsgBox(" Datos exportados en " & Application.ExecutablePath, vbInformation)
End If
End Sub

Public Function Exportar_Excel(sOutputPath As String, itGrid As Object) As Boolean

On Error GoTo Error_Handler

Dim o_Excel As Object
Dim o_Libro As Object
Dim o_Hoja As Object
Dim Fila As Long
Dim Columna As Long

' -- Crea el objeto Excel, el objeto workBook y el objeto sheet
o_Excel = CreateObject("Excel.Application")
o_Libro = o_Excel.Workbooks.Add
o_Hoja = o_Libro.Worksheets.add

' -- Bucle para Exportar los datos
With Factura
For Fila = 1 To .Rows - 1
For Columna = 0 To .Cols - 1
o_Hoja.Cells(Fila, Columna + 1) = Factura.Text
Next
For Columna = 0 To .Cols - 2
o_Hoja.Cells(Fila, Columna + 1) = Factura.Text
Next
For Columna = 0 To .Cols - 3
o_Hoja.Cells(Fila, Columna + 1) = Factura.Text
Next
Next
End With
o_Libro.Close(True, sOutputPath)
' -- Cerrar Excel
o_Excel.Quit()
' -- Terminar instancias
Call ReleaseObjects(o_Excel, o_Libro, o_Hoja)
Exportar_Excel = True
Exit Function

' -- Controlador de Errores
Error_Handler:
' -- Cierra la hoja y el la aplicación Excel
If Not o_Libro Is Nothing Then : o_Libro.Close(False)

End If
If Not o_Excel Is Nothing Then : o_Excel.Quit()

End If
Call ReleaseObjects(o_Excel, o_Libro, o_Hoja)
If Err.Number <> 1004 Then MsgBox(Err.Description, vbCritical)
End Function
' -------------------------------------------------------------------
' \ -- Eliminar objetos para liberar recursos
' -------------------------------------------------------------------
Private Sub ReleaseObjects(o_Excel As Object, o_Libro As Object, o_Hoja As Object)
If Not o_Excel Is Nothing Then o_Excel = Nothing
If Not o_Libro Is Nothing Then o_Libro = Nothing
If Not o_Hoja Is Nothing Then o_Hoja = Nothing
End Sub

Private Sub Establecer(p1 As Object)
Throw New NotImplementedException
End Sub

Private Sub DoEvents()
Throw New NotImplementedException
End Sub

Private Function App() As Object
Throw New NotImplementedException
End Function

Private Function xls() As Object
Throw New NotImplementedException
End Function

End Class

Añade tu respuesta

Haz clic para o