
Try
Dim xlApp
As New Excel.Application
Dim xlBook
As Excel.Workbook

xlBook = xlApp.Workbooks.Add(
True)
Dim rowIndex
As Integer = 1
Dim colIndex
As Integer = 0
For colIndex = 0
To DataGridView1.Columns.Count - 1

xlApp.Cells(1, colIndex + 1) = DataGridView1.Columns(colIndex).HeaderCell.Value
Next
For rowIndex = 1
To DataGridView1.Rows.Count - 1
For colIndex = 0
To DataGridView1.Columns.Count - 1

xlApp.Cells(rowIndex + 1, colIndex + 1) = DataGridView1.Rows(rowIndex - 1).Cells(colIndex).Value.ToString
Next
Next

xlApp.Visible =
True

xlBook =
Nothing

xlApp =
Nothing

Catch ex
As Exceptio