Hi Team,
I have data exported from my dashboard into a CSV sheet and there is no format and I need to send this table through the Body email but I need to formatted in good shape so any idea?
Hi Team,
I have data exported from my dashboard into a CSV sheet and there is no format and I need to send this table through the Body email but I need to formatted in good shape so any idea?
Hello @omar_ismail, Try this:
Hi @omar_ismail
htmlTable = "<table>"
For Each row In dataTable.Rows
htmlTable = htmlTable + "<tr>"
For Each col In dataTable.Columns
htmlTable = htmlTable + "<td>" + row(col).ToString + "</td>"
Next
htmlTable = htmlTable + "</tr>"
Next
htmlTable = htmlTable + "</table>"
Insert the HTML table into the email body by assigning the htmlTable
variable to the body property of the email activity.
Hope it works!!
Here buddy, theres an activity which do this automatically
Hi @omar_ismail
To format the data from a CSV file and send it in a well-formatted table through the body of an email using UiPath, you can follow these steps:
Read the CSV file: Use the “Read CSV” activity to read the data from the CSV file and store it in a DataTable variable. Specify the file path of the CSV file in the activity’s properties.
Format the DataTable: Depending on your desired table format, you can perform various operations on the DataTable to format it accordingly. For example, you can rename columns, rearrange the order of columns, apply formatting to specific columns, or perform calculations if needed.
Convert DataTable to HTML table: To convert the formatted DataTable into an HTML table, you can use the following custom code in an “Assign” activity:
htmlTable = "<table border='1'>"
htmlTable += "<tr>"
For Each col As DataColumn In dataTable.Columns
htmlTable += "<th>" + col.ColumnName + "</th>"
Next
htmlTable += "</tr>"
For Each row As DataRow In dataTable.Rows
htmlTable += "<tr>"
For Each col As DataColumn In dataTable.Columns
htmlTable += "<td>" + row(col).ToString() + "</td>"
Next
htmlTable += "</tr>"
Next
htmlTable += "</table>"
Make sure to replace dataTable
with the name of your DataTable variable.
htmlTable
variable containing the HTML-formatted table.This way, the data from the CSV file will be formatted into an HTML table and sent as the body of the email.
Hope it helps!!
Hi @omar_ismail ,
Could you check the below post :
We should be able to convert the Datatable to HTML Table with Simple formatting the Linq Expression provides. We can then alter as needed the expression for adding more styles or font changes.
Let us know if you were able to implement the above method.
i can’t get number 2 and 3 if you can elaborate