• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Tachytelic.net

  • Sco Openserver
    • Sco Unix Support
    • SCO Openserver Installation ISOs
    • SCO Openserver Binaries
    • Add a Hard Drive to an Openserver 5 Virtual Machine
    • Install SCO Vision SQL-Retriever ODBC Driver on Windows 10
    • License Expired on Virtual SCO Openserver Installation
    • How to reset the root password on SCO Openserver 5
  • Scripting
    • PowerShell
      • Add leading zeros
      • Check if a File Exists
      • Grep with Powershell
      • Create Environment Variables
      • Test for open Ports
      • Append to a Text File
    • VBScript
      • Check if a File Exists
      • lpad and rpad functions
      • Windows Update E-Mail Notification
  • Office 365
    • Connect to Office 365 with PowerShell
    • Add or remove an email alias using Powershell
    • Change Primary email address of Active Directory user
    • How to hide an AD user from the Global Address List
    • How to hide mail contacts from the Global Address List
    • Change the primary email address for an account with PowerShell
    • Change Primary email address of an AD User
    • Grant a single user access to access to all calendars
    • Forward email to an external address using Powershell
    • Convert shared mailbox to user mailbox with Powershell
  • Get in Touch
  • About Me
    • Privacy Policy

Power Automate HTML Table Styling and Formatting

November 9, 2020 by Paulie 6 Comments

The Create HTML Table action in Power Automate is a useful tool, but lacks any formatting or styling options. In this post I am going to explain how to format the HTML table produced by Power Automate. Here is an example of the default output:

Image of the default unformatted output of the Create HTML Table action in Microsoft Power Automate

In my opinion:

  • The table is just ugly.
  • There are no column alignment options.
  • If you are using custom columns, it does not allow you to put spaces in the column headers.

The good news is that the Create HTML Table action produces basic HTML that can be easily modified or styled. The HTML source of the table generated above by Power Automate above is:

<table>
   <thead>
      <tr>
         <th>FirstName</th>
         <th>LastName</th>
         <th>JobDescription</th>
         <th>Furloughed</th>
         <th>FurlougedDate</th>
      </tr>
   </thead>
   <tbody>
      <tr>
         <td>Paul</td>
         <td>Murana</td>
         <td>Power Automate Developer</td>
         <td>No</td>
         <td></td>
      </tr>
      <tr>
         <td>Micheal</td>
         <td>Knight</td>
         <td>Lone Ranger</td>
         <td>Yes</td>
         <td>1986-04-04</td>
      </tr>
      <tr>
         <td>Peter</td>
         <td>Venkman</td>
         <td>Ghost Hunter</td>
         <td>No</td>
         <td></td>
      </tr>
      <tr>
         <td>John</td>
         <td>Rambo</td>
         <td>Mercenary</td>
         <td>No</td>
         <td></td>
      </tr>
   </tbody>
</table>

Use CSS to create a much more attractive table

By adding some CSS, you can make the table much more attractive very quickly:

Image of an HTML Table from Flow which has had styling applied.

The simple CSS I applied to the above is:

<style>
Table {
  font-family: Arial, Helvetica, sans-serif;
  background-color: #EEEEEE;
  border-collapse: collapse;
  width: 100%;
}

Table td, Table th {
  border: 1px solid #ddd;
  padding: 3px 3px;
}

Table th {
  font-size: 15px;
  font-weight: bold;
  padding-top: 12px;
  padding-bottom: 12px;
  text-align: left;
  background-color: #1C6EA4;
  color: white;
}
</style>

If you aren’t a CSS wizard you can use https://divtable.com/table-styler/ to get you started.

So now you have got the CSS, here is how to add it to the table:

  • Create a compose step called CSS Table Style.
  • Paste your CSS into that compose action.
  • In your Send an email action paste the CSS and then the HTML Table:
    Image showing how to insert CSS Into a HTML Table generated by Power Automate

You can put anything else you need in the body, but I would suggest that you put the CSS before anything else.

Add spaces to the column headings

In my example, I used custom columns and I was unable to add spaces to the column headings. So here is my workaround:

  • Use a carat ^ symbol wherever you want a space in the column header.
  • Create a compose action to replace the carat with a space.
  • Select the output of the compose in your email instead of your HTML Table output:
Image showing how to add spaces to column headers in the Power Automate Create HTML Table action.

The compose expression is:

replace(body('Create_HTML_table'), '^', ' ')

You could of course use any symbol, but make sure to use one that isn’t going to be in use elsewhere in the table. The carats are replaced with spaces:

Image of a HTML Table produced by Power Automate with CSS style applied.

You can take this much further by not using the Create HTML Table action at all, and constructing your own table directly in Power Automate and looping through an array of records. This is something I do sometimes, but it is a lot more work and I wanted to quickly cover how to improve the look of the standard action.

Related

Filed Under: Power Platform Tagged With: Power Automate

Reader Interactions

Comments

  1. Alek says

    November 30, 2020 at 9:59 pm

    This is great! However, it removes all the line breaks where there are multiple paragraphs in a field. Any solution to that?

  2. Paulie says

    December 1, 2020 at 12:10 am

    Hi Alek,
    Yes, this is quite normal. Newline characters are not automatically converted to HTML line breaks. But you could add a compose step to do this for you, something like:

    replace(body('Create_HTML_table'), decodeUriComponent('%0A'), '<br>')

    Will replace newlines with a HTML break.

  3. Alek says

    December 1, 2020 at 9:09 pm

    Thank you Paulie! For anyone reading this in the future, if you want to both replace the line breaks with html breaks AND the carrots with spaces, use:

    replace(replace(body(‘Create_HTML_table’), decodeUriComponent(‘%0A’), ”),’^’, ‘ ‘)

  4. Paulie says

    December 1, 2020 at 10:46 pm

    Thanks Alek, I am going to put these extras in the main blog post I think. I am going to make a video of it also I think.

  5. Paul says

    December 19, 2020 at 4:22 am

    This was very helpful. Thank you.
    I have nice formatted tables now but they only work for my outlook recipients. Gmail strips css blocks from incoming emails. It seems that making this would would require inline css. IE styles inside the table’s etc.

    Have you found a way around this?

  6. Inuyasha says

    January 3, 2021 at 10:09 am

    Thanks, It worked!

Leave a Reply Cancel reply

Primary Sidebar

Power Automate Support Image
Link to my LinkedIn Profile
Go to mobile version