Introduction

Everyday tons of millions data is manipulated in Excel/CSV across the world daily. I have manipulated data with Excel and CSV in ASP.Net (C#). Normally when we are showing data in Gridview, end user demand from development agency to manipulate data in Excel and CSV. To fulfill this requirement, I have provided best example how can we export data from Gridview to Excel and CSV. I have provide all steps to pull data into Excel/CSV as follows:



Step 1: First bind your Gridview through C# programming, I have shown in snapshot which shows data is showing in Gridview and bottom of Gridview showing two multi talented Button “Export To Excel “ and “Export To CSV”.

Export To Excel


Step 2: This step shows Export to CSV Code view, how can we programmatically manipulate data into CSV then it will be able to download.

Export to CSV Code View


Step 3: This step shows how can we programmatically through C# programming manipulate data then downloaded into Excel format. Here is code view



Export to Excel Code View


Step 4: This step shows, how data is showing into excel sheet view.

Export to Excel View


Step 5: Here  you can see that exported data into CSV is showing.

Export to CSV View

Above steps shows how can we Export Gridview to Excel/CSV.

Download Sample with source file

https://www.dropbox.com/s/oyye3a5lioemw4k/TestExport.zip

Relevant Reading