• How to export DataTable to Excel in C#

    by  • June 5, 2013 • Microsoft .NET C# (C-Sharp), Microsoft ASP.NET • 0 Comments

    A DataTable or DataSet can be easily exported to Excel spreadsheet using C# code. There are different solutions available to solve this problem but I will give you a very simple one in this article. You can also download complete code at the end.

    I have created a DataTable and populated this Datatable by creating columns and rows. You can get data from database and populate your DataTable. You have to give the content type and add header to response object to achieve this task. First I am writing column names and then each row of the DataTable using Response.Write() method.

     




    Namecheap.com
    Avatar of GetCodeSnippet.com

    About

    GetCodeSnippet.com provides you high quality Microsoft .NET development related articles, tutorials and sample code for ASP.NET, C#, VB.NET, AJAX, WCF, WPF, Web Services, Windows Services, SQL Server and other technologies.

    Leave a Reply