-1

How can one read sql server data and write it to excel file in C#? Do I need to use an external .Net library, or is it just OK using Visual Studio itself?

Any example and link will be well appreciated..

Note: Please send examples for Winforms, not asp.net

2

5 Answers 5

2

I would use some kind of OR-Mapper to read data from SQL such as

  • NHibernate
  • Entity Framework
  • Linq 2 SQL

For writing data to Excel you could bind hardly to any Excel Version by referencing the Excel Assemblies. The cleaner and more beautiful way is to use Open XML SDK for Office http://www.microsoft.com/download/en/details.aspx?id=5124

Sign up to request clarification or add additional context in comments.

Comments

1

Follow the below article, this even provide the facility to export the data into many formats.

Export data to Excel and other formats using C#

Comments

1

see:
http://www.c-sharpcorner.com/UploadFile/DipalChoksi/exportxl_asp2_dc11032006003657AM/exportxl_asp2_dc.aspx
http://geekswithblogs.net/VROD/archive/2008/04/20/121433.aspx

Comments

1

You could find helpful information how to achieve that goal in the following blog posts: 1. http://msmvps.com/blogs/deborahk/archive/2009/07/23/writing-data-from-a-datatable-to-excel.aspx 2. http://tim.mackey.ie/HowtoExportADatasetToExcelCAspnet.aspx

Comments

1

See : http://www.dotnetfunda.com/forums/thread548-export-data-to-excel-file-from-a-table-in-sql-server-using-csharp.aspx

It also has a nice example on the link inside the page.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.