Foolproof Power Automate HTML Table Styling

Foolproof Power Automate HTML Table Styling

You can use Power Automate to an send email with a formatted and styled HTML table. With the help of the Create HTML Table action any set of SharePoint list items can be quickly converted into an HTML table. But that table will look pretty plain unless you apply some CSS to it. In this article I will show you my foolproof Power Automate method for HTML table styling.

Table of Contents
• Introduction: The Daily Cash Receipts ReportSetup The SharePoint ListCreate An HTML Table From SharePoint List ItemsDesign And Apply An HTML Table StyleSend An Email With An HTML Table StyleFormatting Dates And Numbers In An HTML Table




Introduction: The Daily Cash Receipts Report

Salespeople at a bus manufacturing company receives a daily cash receipts report from the accounting team. The email contains a formatted HTML table showing when payment was received, which customer paid and the amount.




Setup The SharePoint List

Create a new SharePoint list named Cash Receipts with the following columns:

  • Customer Name (text)
  • Received Date (date only)
  • Amount (number)



Populate the SharePoint list with the following data:

Customer NameReceived DateAmount
Burton Bus Lines1/12/2024462000
Texas Tours, LLC1/12/20242161000
Coach America1/12/20242851000
State Of New York1/12/2024955000
Polk County1/12/2024513000
Jefferson Bus Lines1/12/20241456000
California Coach1/12/2024525000
Las Vegas Touring Company1/12/20242914000



After setting up the SharePoint list it will look like this.




Create An HTML Table From SharePoint List Items

We want to get all of the items in the Cash Receipts SharePoint list and convert them into an HTML table. Open Power Automate and create a new flow with an instant trigger. Then add the SharePoint – Get Items action and select the Cash Receipts list.



The SharePoint list includes many columns that we do not want to appear in the email. We only want to show the Received Date, Customer Name and Amount. To show only the desired columns insert the Data Operations – Select action and configure it as shown below.



Then add a Data Operations – Create HTML table and use the output of the Select action in the from field. The flow now result in a plain HTML table with no styling applied.




Design And Apply An HTML Table Style

To create the HTML table style we will use the DivTable Table Styler online tool. Scroll down to the style editor and select the NO STYLE theme. Then setup the HTML table style exactly as shown below.



Below the Style Editor there is a WYSIWYG preview that shows a preview of what the table will look like. After the desired style has been achieved copy the copy in the CSS textbox to the clipboard.



Paste the code into Windows Notepad and remove the “.unstyledTable” CSS class from it entirely. Then add style tags to the start and end of the code.

<style>
	table {
          border-collapse: collapse;
	}
        table td, table th {
          border: 1px solid #AAAAAA;
          padding: 3px 10px;
        }
       table tr:nth-child(even) {
          background: #D9E1F2;
	}
	table thead {
	  background: #4472C4;
	}
	table thead th {
	  font-size: 15px;
          font-weight: bold;
          color: #FFFFFF;
          text-align: left;
	}
	table tfoot {
 	 font-weight: bold;
	}
</style>



Insert a Data Operations – Compose action into the flow and copy + paste the code from Windows Notepad into it. Add the output of the Create HTML table action at the bottom. When placed in the body of an email this Compose actions output will display a styled HTML table.




Send An Email With An HTML Table Style

Now we have everything needed to include in the email. Add an Office 365 Outlook – Send An Email (V2) action with “Daily Cash Receipts – January 12, 2024” as the subject. Switch the body to Code View and fill it with the Compose CSS action output.



Test run the flow.



When the email is received it will look like this.




Formatting Dates And Numbers In An HTML Table

The Received Date and Amount are shown using the default date & number formats respectively. We can change that with some additional updates to the flow.



Go to the Select action of the flow and change the Received Date value to this code. The date showing as 2024-01-12 will now appear as 1/12/2024.

formatDateTime(item()?['ReceivedDate'], 'M/d/yyyy')



Then update the Amount code to this instead. The number showing as 462000 will now appear as $462,000.00

formatNumber(item()?['Amount'], '$#,##0.00')



Perform another flow test run to see the dates and numbers in their desired formats.







Questions?

If you have any questions or feedback about Foolproof Power Automate HTML Table Styling please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Matthew Devaney

Subscribe
Notify of
guest

9 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Udula
Udula
1 month ago

I used a similar flow for an incident reporting task. we used it to inform staff when they have missed a deadline.

This is out of context, out of PowerApps and Power Automate, which one do you love the most?

Raghu
Raghu
1 month ago

Cool stuff Matt

Carl Williams
Carl Williams
1 month ago

Great article Matthew. I did this similar setup a couple of years ago, however, the issue I encountered was when you save to a PDF and the table is longer than a single page. Then pagination, footers, repeating headers seem not to be a reality for Microsoft. Not every table is very small and confined to email.

Thanks again.

Nuno Nogueira
1 month ago

This is really cool, thank you!
One thing we tried was to create a sub-flow with the styling only.
Then other flows call this one and the e-mail styling is consistent across flows.

Eric Brown
Eric Brown
23 days ago

Great stuff, Matt. Question: Would it be possible to make an cell in the HTML table a clickable href link? I’ve tried to put the <a href.. etc.> code in, but of course it renders as literal text, not as a link. Any idea?

Shaun Boot
Shaun Boot
16 days ago
Reply to  Eric Brown