Exporting DataGridView data to Excel file in C#-Collection of common programming errors
I need to export data from DataGridView (in my WinForms application) to excel file. I googled some tutorials on the subject, but I’m having hard time getting any of the available solutions to work.
I started with this tutorial. But when I try to export datagridview to excel file i get Unhandled COMException in:
Microsoft.Office.Interop.Excel.ApplicationClass ExcelApp = new
Microsoft.Office.Interop.Excel.ApplicationClass();
I’ve also tried this tutorial, but with the same result.
Another of the articles I’ve found and read was this one. Couldn’t get code to work, probably because I can’t find Microsoft Excel 12.0 object library
in the COM tab
of Add Reference
dialog.
I’m using Visual Studio 2010 Ultimate.