Close

February 19, 2008

Exporting a asp.net gridview to Excel

I was looking for a way to export a gridview of an asp.net site to an Excel-file (.xls). Most methods I found involved overriding a Page-method and/or disabling validation of the controls. The solution provided by Matt Berseth is safer and more elegant in that it uses a seperate class with a shared method (static for C# people). This way, you can access it from multiple pages without having to rewrite the code multiple times.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.