how to store the datagrid values into excel sheet in wiondows application using C# RRS feed

  • Question


    i am using .net 2.0 in windows application c# coding


    i want store the values with datagridview into the excelsheet


    Thank u


    Thursday, February 7, 2008 7:26 AM

All replies


    There is not built-in functionality to export data into Excel from the grid, but there are several ways to export data into Excel using your own code:


    1. Use Jet OLEDB provider. You would need to execute INSERT SQL statements and insert data row-by -row. Jet provides pretty good performance if you do not need to export large volumes of data in one shot, but Jet does not allow to format data.  Here are some samples how to work with Excel using Jet



    2. Use Microsoft Visual Studio Tools for Office (VSTO). This library of classes is COM-based and accessible through COM Interop, but provides access to full functionality of Excel. Performance is not the best, but you could format data as you wish. Here are samples using VSTO



    3. You could export data into XML format supported by Excel starting version 2002. Here is sample how to do this



    4. You could try third-party components. I have developed my own and you could try it from my Web site. It provides really good performance, especially in big chunks of data, but formatting capabilities are limited.




    Thursday, February 7, 2008 11:30 AM