Export DataGridView Data to Excel in C# – Programming, Pseudocode Example, C# Programming Example
Windows Form

Export DataGridView Data to Excel in C#

Firstly, we create a form as following.


And then Add a reference by right clicking to the “References”  in the Solution Explorer.  

Then we will see the Reference Manager in the panel. We have to add the  Microsoft Excel 16.0 Object Library into our project as a reference for exporting to the Excel.

After the adding is finished, let’s start the project.

Don’t forget to add those refereces to using.


Button1_Click event

All of the Codes:




1 Comment

  • I have getting an error Error 1 ‘System.Windows.Forms.DataGridViewTextBoxColumn’ does not contain a definition for ‘Missing’ and no extension method ‘Missing’ accepting a first argument of type ‘System.Windows.Forms.DataGridViewTextBoxColumn’ could be found (are you missing a using directive or an assembly reference?) C:\Users\admin\Desktop\sang solutions\sRoofMetals\sRoofMetals\FrmBank.cs 84 35 sRoofMetals

Leave a Comment

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