In this Power Automate tutorial, we will learn how to create an HTML table in Power Automate. We will also cover the below topic with different examples.
- Create an HTML table in Power Automate from a SharePoint list
- How to Create HTML Table with Border in Power Automate
- Create a vertical html table in Power Automate
- How to create html table formatting in Power Automate
- Create an HTML table with custom columns in Power Automate
Recently, I got a requirement to send SharePoint list items in an HTML table format in an email using Flow. So, for that, I have used the below SharePoint Online list having the columns like:
- Customer Name – default title column
- Customer Email – Single line of text
- Contact Detail – Number type
- Address1, Address2 – Multiple lines of text
- State, Country– Choice type
- Zipcode – Number type
Once users click on a button, the flow will trigger and this will get all the items from the above SharePoint list. Then it will create an HTML table with a little formatting and finally will send an email to the user.
So, let us build from scratch.
How to Create HTML Table in Power Automate from a SharePoint list
Let us see how to create an Html table from a SharePoint list in Power Automate. For this, I am going to create a button flow that will trigger manually.
- Log in to Power Automate, then click on the Create option and select an instant cloud flow to trigger the flow manually.
- Click on the Next step and then select Get items action and configure the SharePoint Site address and List name. This will get all the items from the selected SharePoint list.
- Now click on the next step, to map the key-value pair using the ‘Select‘ data operation. Then in the ‘From box’ add the value from dynamic content. Next, we will dynamically map values by adding the key-value pair in the Map box.
- Based on the SharePoint list columns names, we will make like this. Enter the key name in the key text box and then in the value box add the dynamic content value, like below:
- Now in this next step, we will create an HTML table by selecting the ‘Create HTML table‘ action from the action triggers.
- Next in the From box, select the ‘output’ from the dynamic content for the select data operation action, and in the Columns box select Automatic.
Now we will add a compose action to apply the style for the generated HTML table, for that add the below CSS code.
<style>
table {
border: 1px solid #1C6EA4;
background-color: #EEEEEE;
width: 100%;
text-align: left;
border-collapse: collapse;
}
table td, table th {
border: 1px solid #AAAAAA;
padding: 3px 2px;
}
table tbody td {
font-size: 13px;
}
table thead {
background: #1C6EA4;
border-bottom: 2px solid #444444;
}
table thead th {
font-size: 15px;
font-weight: bold;
color: #FFFFFF;
border-left: 2px solid #D0E4F5;
}
table thead th:first-child {
border-left: none;
}
</style>
- To send an email, select Send an Email (V2) (outlook) action. In The To address pass the dynamic content user email address.
- Then in the body add outputs of the style-composed action and HTML action from dynamic content.
Save and test the flow manually by selecting the run flow option.
Once your Flow ran successfully, in the Outlook email we can see that the HTML table has been generated and displayed the Customer’s information.
In the below screenshot, we can see that the HTML table has been generated and displayed the Customer’s information using flow.
This is how to create an Html table from the SharePoint list in Power Automate.
Create an HTML table with custom columns in Power Automate
Let us see how to create an HTML table with custom columns in Power Automate.
Here we will use the same SharePoint list, but we will add 3 custom columns in the HTML table. We will use the Customer list and custom columns to display the customer name, customer email, and contact detail.
- Follow the above approach to create an instant cloud flow that will trigger manually. Click on the Next step, select Get items action, and configure the SharePoint Site address and List name. We use the Get items flow action to get all the items from a SharePoint Online list.
- Then select the ‘Create HTML table‘ action to create an HTML table. Next in the From box, pass the values of dynamic content, and in the Columns box select Custom.
- Add the column header for the customer name, customer email, and contact detail, and pass the dynamic value from the SharePoint list in the Values column.
To apply style for the created HTML table and add the below CSS code in the Compose action.
<style>
table {
border: 1px solid #1C6EA4;
background-color: #EEEEEE;
width: 100%;
text-align: left;
border-collapse: collapse;
}
table td, table th {
border: 1px solid #AAAAAA;
padding: 3px 2px;
}
table tbody td {
font-size: 13px;
}
table thead {
background: orange;
border-bottom: 2px solid #444444;
}
table thead th {
font-size: 15px;
font-weight: bold;
color: #FFFFFF;
border-left: 2px solid #D0E4F5;
}
table thead th:first-child {
border-left: none;
}
</style>
- Select Send an Email (V2) (outlook) action to send an email. Pass the dynamic content using the email address to the To address. Add Subject value in the Subject field.
- Then in the body add outputs of the style-composed action and HTML action from dynamic content.
Save and Test the flow and run the flow by selecting the run flow option. Once your Flow runs successfully like below:
In the Outlook email, we can see that the HTML table has been generated and displayed the Customer’s information based on the custom column that we have added.
This is how to create an HTML table with custom columns in Power Automate.
How to Create HTML Table with Border using Power Automate
Here we will see how to create an HTML table with Border using Power Automate.
In this example, we will use the below displayed SharePoint Task list consisting of Task name, Assigned to, Task Priority, and Task status.
- Task name – default title column
- Assigned To – Person or group column
- Task Priority and Task Status – Choice column
By default when we generate a table using create an HTML table action, it will create table values without borders like the below:
- Now we will create an instant flow to get the values from the SharePoint list and generate an HTML table along with the borders.
- Login to Power Automate, select the instant cloud flow to trigger the flow manually, and then Select Get items action to get items from the SharePoint list.
- Then configure the SharePoint site address and list the name as below:
Add a select action and pass the dynamic value in the from field. In the Map section map the table row and table data values.
Add another select action from the action trigger and switch it to the text mode and map the dynamic value of the select action.
To create an HTML table and a compose action and pass the below code to generate a table along with rows and data values. For that use the join expression to get data from the previous action.
<table>
<tr>
<th>TaskName</th>
<th>Assigned To</th>
<th>Task Priority</th>
<th>Task Status</th>
</tr>
@{join(body('Select_2'),'')}
</table>
To display the HTML table with a border, add a compose action and inject the below CSS code.
<style>
table, th, td {
border: 1px solid;
}
th {
background-color: #04AA6D;
color: white;
}
th, td {
padding: 15px;
text-align: left;
border-bottom: 1px solid #ddd;
}
</style>
- Select Send an Email (V2) (outlook) action to send an email. Pass the dynamic content using the email address to the To address. Add Subject value in the Subject field.
- Then in the body add outputs of the style-composed action and HTML action from dynamic content.
Save and test the flow by selecting the run flow option. Once the flow ran successfully like below:
In the email, we can see HTML table has been generated and displayed the table with a border.
This is how to create an HTML table with Border using Power Automate.
Create a vertical html table in Power Automate
Let us see how to create a vertical html table in power automate.
In this example, we will use the SharePoint TaskList, and we will generate the HTML vertical table with values.
- Login to Power Automate, select the instant cloud flow to trigger the flow manually, and then Select Get items action to get items from the SharePoint list.
- Then configure the SharePoint site address and list the name as below:
- Choose the select action from the action, to get the value for TaskName, Assigned To, TaskPriority, and TaskStatus.
- In the From section, pass the values from dynamic content.
- And For the TaskStatus value use the below expression to concat in the select action:
concat('<td>',item()?['Status/Value'],'</td>')
Now Add a compose action and generate an HTML table by adding the below code, use the join function to get the row values.
join(body('Row_4'),'')
<table>
<tr><td style='background-color: #d9c9c7;'>TaskName</td>@{join(body('Row_1'),'')}
</tr>
<tr> <td style='background-color: #d9c9c7;'>AssignedTo</td>@{join(body('Row_2'),'')}
</tr>
<tr> <td style='background-color: #d9c9c7;'>TaskPriority</td>@{join(body('Row_3'),'')}
</tr>
<tr> <td style='background-color: #d9c9c7;'>TaskStatus</td>@{join(body('Row_4'),'')}
</tr>
</table>
Add a compose action and inject the below CSS code to display the HTML with a border
<style>
table, th, td {
border: 1px solid;
}
th {
background-color: #04AA6D;
color: white;
}
th, td {
padding: 15px;
text-align: left;
border-bottom: 1px solid #ddd;
}
</style>
- Select Send an Email (V2) (outlook) action to send an email. Pass the dynamic content using the email address to the To address. Add Subject value in the Subject field.
- Then in the body add outputs of the style-composed action and HTML action from dynamic content.
Save and test the flow by selecting the run flow option. Once the flow ran successfully like below:
In the email, we can see HTML table has been generated and displays the table data value vertically.
This is how to create HTML Table vertical using Power Automate flow.
HTML Table Formatting in Power Automate
Let us see how to create an HTML table and do some formatting in Power Automate.
- Create an instant cloud flow to trigger the flow manually, and then Select the Get items action to get items from the SharePoint list and configure the SharePoint site address and list the name as below:
- Now click on the ‘Select‘ data operation. Then in the ‘From box’ add the values from dynamic content. Next, we will dynamically map values by adding the key-value pair in the Map box.
- Enter the key name in the key text box and then in the value box add the dynamic content values, like below:
- To apply formatting for the Task Status column use the below expression:
<p style="color:@{if(equals(item()?['Status/Value'],'Completed'),'green','red')};">@{item()?['Status/Value']}</p>
- Now we will create an HTML table by selecting the ‘Create HTML table‘ action from the action triggers. Next in the From box, select the ‘output’ from the dynamic content for the select data operation action.
Add a compose action and inject the below CSS code to apply the border for the generated HTML table.
<style> table, th, td {
border: 1px solid;
} </style>
Add another compose action to clean up the HTML of the create HTML action, use the below-mentioned expression.
replace(replace(replace(replace(replace(body('Create_HTML_table'), '<', '<'), '>', '>'), '&', '&'), ''', '"'), '"', '"')
- Select Send an Email (V2) (outlook) action to send an email. Pass the dynamic content using the email address to the To address. Add Subject value in the Subject field.
- Then in the body add outputs of the style-composed action and HTML action from dynamic content.
Save and test the flow by selecting the run flow option. Once the flow ran successfully like below:
In the email, we can see HTML table has been generated and displays the formatted table status value based on the condition applied.
This is how to create an HTML table and do some formatting in Power Automate.
Conclusion
Creating an HTML table in Power Automate and we saw it by doing examples on how to create an HTML table in Power Automate from a SharePoint list. We will also cover the below topic with different examples.
- Create an HTML table in power automate from the sharepoint list
- Create HTML table in Power Automate custom columns
- How to Create HTML Table with Border in Power Automate
- How to Create an HTML Table and Do Formatting in Power Automate
- Create a vertical html table in Power Automate
You may also like:
- Add Rows to Excel in Power Automate
- Expense Reimbursement and Approval using Power Automate
- Create Calendar Events from a SharePoint list using Power Automate
- Create SharePoint Group using Power Automate
- Create an HTML Table from an Array in Power Automate
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com