Peter Morlion logo


Exporting a gridview to Excel

I was looking for a way to export a gridview of an 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 *