How to export datatable to excel using c# in ASP.NET?

Posts
3
Registration date
Monday November 12, 2018
Last seen
November 15, 2018
- - Latest reply: ac3mark
Posts
11718
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
March 19, 2019
- Nov 15, 2018 at 05:15 PM
Hello,

I would like to know how can I easily export datatable to excel file using C#?
I am currently using GridView

Thanks
See more 

Your reply

1 reply

Best answer
Posts
11718
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
March 19, 2019
2319
1
Thank you
"easily"

Not going to happen, nor are we going to code a turn key solution for this. If you had code, we might help.

It really doesn't get any easier than IMPORT EXTERNAL DATA, and place your ODBC credentials from the live DB. NO coding needed!


Say "Thank you" 1

Glad we were able to help! Love us? Write us a review! Rate CCM

CCM 3446 users have said thank you to us this month

Vikram_27
Posts
3
Registration date
Monday November 12, 2018
Last seen
November 15, 2018
-
NO Coding needed?? how sir?
I need it in C#, so would need coding I think, I am not sure how it is possible, please explain?
ac3mark
Posts
11718
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
March 19, 2019
2319 -
Start a new sheet. Click on Data. Click on Get Data from From Database. Put in your credentials for the Data base.

See image below.


Do you know the difference between proprietary and a standard? Excel is proprietary.

DO you know how to properly format the data so EXCEl can read it?

I do, it is called a standard format, which would be (in this case) a CSV file.


IF you cannot code your own C# CSV file, then this is kind of like me playing chess with a pigeon.

The pigeon will crap all over the game board, and strut off like it won!

Get it?

No playing chess with a pigeon!
Respond to ac3mark