Hi @all,
I need to place the table in mail body. For that I have used create html content activity. I have used add data values option and added the datatable into that. The alignment in the table which is displayed is left. But I want that to be in centre. Can anyone help me, how to do that.
Thanks.
You can either go with the External CSS approach where you will be specifying the table orientation in a separate .css file & incorporate the properties in the code or you could just utilise the Inline CSS as below:
<html>
<head>
<style>
table {
margin: 0 auto;
text-align: center;
}
</style>
</head>
<body>
<table>
<!-- Your table content here -->
</table>
</body>
</html>
Hope this helps.
Hi @RPA_Geek1 ,
You may refer and consume the following code and tweak based on your requirement.
Pass your datatable directly as In argument to this Invoke code
Finally your Out argument dt_HTML can be directly passed in the Email body.
Code
string html = "<table>";
html+="<table style='border: 1px solid black; border-collapse: collapse;width:50%;white-space: nowrap;overflow: hidden'>";
html+="</style>";
//add header row
html+="<b>";
html+="<tr>";
for(int i=0;i<in_dtReport.Columns.Count;i++)
html+="<th style='border:1px solid black; background-color:YellowGreen;width:50%;padding-left: 40px;padding-right: 40px;white-space: nowrap;font-family:Times;font-size:110%'>"+in_dtReport.Columns[i].ColumnName+"</th>";
html+="</tr>";
html+="</b>";
//add rows
for(int i=0;i<in_dtReport.Rows.Count;i++)
{
html+="<tr>";
for(int j=0;j<in_dtReport.Columns.Count;j++)
{
html+="<td style='border:1px solid black;border-collapse: collapse;text-align: center'>"+in_dtReport.Rows[i][j].ToString()+"</td>";
}
html+="</tr>";
}
html+="</table>";
out_HTML=html;
Thanks,
Christopher