DataTable to HTML using Assign Activity


Here is the solution for converting DataTable variable into HTML table.
By this you can avoid adding new dependencies to your project or implementing long workflows to get data in HTML table format.

Create a String variable (HTMLBodyStr) and assign below expression to it. Replace TestDT variable with your Datatable Variable

HTMLBodyStr="<table border=2><tr><td>"+String.Join("</td><td>",TestDt.Columns.Cast(Of DataColumn).Select(Function (x) x.ColumnName).ToArray)+"</td></tr>"+
"<tr>"+String.Join("</tr><tr>",(From x In TestDt.AsEnumerable
Let cells="<td>"+String.Join("</td><td>",x.ItemArray)+"</td>"
Select cells).ToArray)+"</tr>"

You can find the same in this link


Hi @poorna_nayak07,

That is a cool little snippet requiring zero dependencies.

Quite useful for people looking to embed html tables in emails.
Thanks for sharing.

I will soon try it out on a TDD generator workflow.