DataTable to readable text string

Question :

DataTable to readable text string,

Answer :

This might be a bit on the silly side of things but I need to send the contents of a DataTable (unknown columns, unknown contents) via a text e-mail. Basic idea is to loop over rows and columns and output all cell contents into a StringBuilder using .ToString().

Formatting is a big issue though. Any tips/ideas on how to make this look “readable” in a text format ?

I’m thinking on “padding” each cell with empty spaces, but I also need to split some cells into multiple lines, and this makes the StringBuilder approach a bit messy ( because the second line of text from the first column comes after the first line of text in the last column,etc.)

Read More  How can I unit test Flex applications from within the IDE or a build script?

,

Would converting the datatable to a HTML-table and sending HTML-mail be an alternative? That would make it much nicer on the receiving end if their client supports it.

That’s the answer DataTable to readable text string, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you

Read More  Is it possible to embed and use a portable executable in a .net DLL?