To create an HTML table in Power Automate, you can use the “Create HTML table” action available in the “Data Operations” category.
How to create HTML table in power automate?
Here are the steps to create an HTML table in Power Automate:
- Open the Power Automate designer and create a new flow.
- Add a “Data Operations – Create HTML table” action to your flow.
- In the “Rows” field, add an array of objects that represent the rows of your table. Each object should have properties that represent the columns of your table.
For example to create Html table:
[
{
"Name": "John Doe",
"Email": "johndoe@example.com",
"Phone": "555-1234"
},
{
"Name": "Jane Smith",
"Email": "janesmith@example.com",
"Phone": "555-5678"
}
]
- In the “Columns” field, add an array of objects that represent the columns of your table.
- Each object should have a “header” property that represents the column header. In addition, a “value” property that represents the name of the property in your row objects that contains the data for that column.
For example:
[
{
"header": "Name",
"value": "Name"
},
{
"header": "Email",
"value": "Email"
},
{
"header": "Phone",
"value": "Phone"
}
]
Set any other options you want for the table, such as the table style and whether to include the header row.
Use the output of the “Create HTML table” action in another action, such as sending an email.
This will create an HTML table based on the input you provided, which you can use in your Power Automate flow.
Power Automate HTML table formatting | Style HTML table
Here’s an example of how you can format the HTML table created by the “Create HTML table” action in Power Automate:
- After the “Create HTML table” action, add a “Compose” action to your flow.
- In the “Inputs” section of the “Compose” action, enter the following expression to format the table:
'<table style="border-collapse: collapse; width: 100%;">'
+ '<thead style="background-color: #eee;"><tr>'
+ concat(outputs('Create_HTML_table')?['body/Colums'], '<th style="padding: 10px; border: 1px solid #ddd;">', 'header', '</th>')
+ '</tr></thead>'
+ '<tbody>'
+ concat(outputs('Create_HTML_table')?['body/Rows'], '<tr>', concat(item()?['body'], '<td style="padding: 10px; border: 1px solid #ddd;">', item()?['value'], '</td>'), '</tr>')
+ '</tbody>'
+ '</table>'
- This expression formats the table with a collapsed border, 100% width, and a light gray background for the header row. Each cell has 10 pixels of padding and a 1-pixel solid border.
border-collapse: collapse
– Collapses the borders between cellswidth: 100%
– Sets the table width to 100% of its containertext-align: center
– Centers the text in cellsfont-family: Arial, sans-serif
– Sets the font family to Arial or a sans-serif fallbackThis expression formats the table with the following styles:
- The header row has a light gray background color (
background-color: #eee
) and each cell has 10 pixels of padding and a 1-pixel solid border (padding: 10px; border: 1px solid #ddd
). - Save and run the flow. The output of the “Compose” action should be the formatted HTML table.
This is just one example of how you can format an HTML table in Power Automate.
You can customize the CSS styles to fit your specific needs. Keep in mind that the table structure and style must be included in a single string in the “Inputs” section of the “Compose” action.
You might want to explore our HTML homework help service at Online coding help.