Private Sub Buttonexport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonexport.Click
Dim xlapp As New excel.Application
Dim xlappCo As New excel.ApplicationCode
Dim ra As excel.Range
On Error Resume Next
xlapp = CType(GetObject(, "Excel.Application"), excel.Application)
xlappCo = CType(GetObject(, "Excel.Application"), excel.Application)
If Err.Number <> 0 Then
xlapp = New excel.Application
End If
xlapp.Visible = True
xlapp.Workbooks.Add()
ra = xlapp.ActiveCell
With DGVTest
For i As Integer = 0 To .RowCount - 1
For j As Integer = 0 To .ColumnCount - 1
ra.Offset(i + 1, j).Value = .Rows(i).Cells(j).Value
Next
Next
End With
End Sub