if your gridview is showing data from a existing ms access database then the below can export it to an excel file
Sub ExportToExcelFromAccess()
Dim AccessConn As System.Data.OleDb.OleDbConnection
Dim AccessCommand As OleDbCommand
Dim xl As Excel.Application
Try
xl = GetObject(, "Excel.Application")
Catch ex As Exception
xl = New Excel.Application
End Try
Dim filepath As String
AccessConn = New System.Data.OleDb.OleDbConnection(constr)
xl.Visible = False
xl.DisplayAlerts = False
filepath = "D:\myexcelfile.xls"
Dim myfile As New FileInfo(filepath)
If myfile.Exists Then
myfile.Delete()
End If
myfile = Nothing
Try
AccessCommand = New OleDbCommand("SELECT * INTO [Excel 8.0;DATABASE=" + filepath + ";HDR=NO;].[table1] from [DB_name]", AccessConn)
AccessConn.Open()
retval = AccessCommand.ExecuteNonQuery()
Catch ex As Exception
Label5.Text = ex.Message.ToString
Finally
xl.Visible = True
xl.DisplayAlerts = True
xl.Quit()
AccessConn.Close()
AccessConn = Nothing
End Try
Label5.Text = "
Click here to download"
end sub