TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Praveen Kumar
284
6.6k
2.3m
What is the best approach to Convert DataTable into .CSV
Sep 21 2019 3:57 AM
I have written the following two approach to Convert DataTable into .csv File
First Approach
Step 1:
By iteratiing over DataTable put all Coulmns then after each rows column's data with comma (,) separated into a StringBuilder object
Step 2:
Now create a new File1.csv file with StringBuilder object which contains csv file data.
Second Approach
Step 1:
Now create a new File1.csv file with empty string data.
Step 2:
Now use the file path of File1.csv to create a StreamWriter object (ie. sw) and use sw.Write() method into loop to of DataTable Rows.
Using StringBuilder or StreamWriter, which one is best.
If any other may be a best approach, kindly share.
Reply
Answers (
2
)
How to generate string json formate to this case ?
How to avoid form close on Alt and F4 button