Exporting gridview contents to excel is one of the most common requirements in many asp.net applications.
I found a helper class in the following link to be very useful-
One limitation of the class is that it doesn't work if you have grid paging turned on - it only exports the rows that are visible on the page, not the whole grid. To workaround this call the disable Gridview paging as the first line of the Export() Sub and re-enable paging as the last line of the Export() Sub.
Also to have this working with a Master Page you need to override a method called VerifyRenderingInServerForm as follows