c# exporting data from datagridview into excel

i have a winforms application and i want to export data from the datagridview into excel. how would i do this? thank u for any help

i want the simplest approach.

maybe exporting to CSV is easier?

Answers


You have a number of options

  1. Write the data to a comma separated value (csv) file
  2. Use OleDB to write to create an Excel file and write the data to it
  3. Use the OOXML SDK to create an Excel file
  4. Write the data to an XML file that can be read by Excel
  5. Use the NPOI library to create and write to the Excel file

Those are a few options off the top of my head. Personally I would go with NPOI, I have used this in server based solutions and it is really easy to work with and quite fast. However it does not currenly support the xlsx file format, only standard xls. The library can be found here

I also found EPPlus, supports xlsx, but I cannot vouch for it since I have not personally used it.


Need Your Help

In SSMS how do you check how much space an index takes on disk

sql-server sql-server-2008 sql-server-2008-r2 ssms

I can't find any context sensitive menu options on the index itself that will show me current disk utilization.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.