7

Hey friends i need to export records of datagridview of winform to MSExcel. I want to do it without using any DLL i.e., with the buid in properties of C#. So is there any good solution for my problem?

2
  • How can i make CSV file? and another problem is when click event for Export fires then automatically MS Excel should open with the records in the datagrid view.I will be very grateful if anyone provide some sample code Commented Apr 17, 2011 at 8:18
  • Thankx for all i was able to do it with the simple code: Commented Apr 20, 2011 at 7:15

4 Answers 4

3

Export the data as CSV file. Excel can read those fine.

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

Comments

0

A common way to do this would be through MSOffice PIAs. Is that what you'd like to avoid?

1 Comment

PIA = Primary Interop Assembly. Allows you to create an Excel process and manipulate it.
0

You can read the values from data grid using reflection or you can take your data model which is bound to the data grid and create a csv file. The csv file can be read by MS Excel.

Comments

0

I followed this video tutorial, in 10min you can do it, you must use the System.Data.SqlClient reference, make a method, and override, the code for the button, and put the gridview in a form tag, here is the link export from datagridview to excel

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.