Hi All,
I have excel file which has a dataTable and i wnat to convert it to html and then send it as a body through mail.
for that i got vb.net code from google, but it has some error it seems, i am pasting the vb.net code for your refrence.
But on line 6 and 19 , it says HTTPUtility is not the member of System.Web
How to resolve it? since i have no idea to fix it and also let me if there is another way of doing that.
Thanks in Advance
Hi @RAKESH_KUMAR_Tiwari
You can use this snippet to convert datatable to HTML.
DataTable_To_HTML.xaml (9.8 KB)
Hope this might help you.
Hi @RAKESH_KUMAR_Tiwari ,
For the conversion of Datatable to HTML Table, You could also refer to the below post :
Hi @JavRR ,
Glad to know that it is useful to you
You could try below expression to get what you wanted to.
HTMLBodyStr="<table border=2><b><tr><td>"+String.Join("</td><td>",TestDt.Columns.Cast(Of DataColumn).Select(Function (x) x.ColumnName).ToArray)+"</td></tr></b>"+
"<tr>"+String.Join("</tr><tr>",(From x In TestDt.AsEnumerable
Let cells="<td>"+String.Join("</td><td>",x.ItemArray)+"</td>"
Select cells).ToArray)+"</tr>"
Thanks,
Hi @supermanPunch ,
i just copied the code from above, but it has one activity error.
RAKESH_KUMAR_Tiwari:
@RAKESH_KUMAR_Tiwari ,
Just copy the part after equals (=), The variable before (=) should be in the L.H.S of the Assign
Activity and the value after (=) should be in the R.H.S
yes, it’s very nice.
so it will convert any number of columns of Datatable?
and also if possible , since tags are bit confusing ,not able to understand what is happening actually, can you pls explain?
@RAKESH_KUMAR_Tiwari ,
Yes
RAKESH_KUMAR_Tiwari:
and also if possible , since tags are bit confusing ,not able to understand what is happening actually, can you pls explain?
For details on the What is HTML Table and what are the tags in it, you could check the below link :
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
Now, In the Expression the First Part is below :
"<table border=2><b><tr><td>"+String.Join("</td><td>",TestDt.Columns.Cast(Of DataColumn).Select(Function (x) x.ColumnName).ToArray)+"</td></tr></b>"+
"<tr>"
This is used to create the Headers/Column Names in the HTML table. It fetches the Column Names from the datatable and formats it in the required format as needed to convert to HTML Table columns.
The Next part, we are performing the same as that of the above Expression, but here we are fetching the data/values present in the Datatable and formatting it as required for the HTML Table Structure.
String.Join("</tr><tr>",(From x In TestDt.AsEnumerable
Let cells="<td>"+String.Join("</td><td>",x.ItemArray)+"</td>"
Select cells).ToArray)+"</tr>"
The w3Schools link should help you on the info related to tags.
1 Like
system
(system)
Closed
March 24, 2023, 5:26pm
8
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.