Hi, @FlowFumbler, I have two suggestions:
- CSS - Add CSS to your flow actions using:
- A generator such as the codebeautify css table generator
- A Compose action with just the <style> code and the Create HTML table action code with a replace function to add the ID to the table tag
- Word --> HTML - Use an example word doc:
- Make the same table on its own in a separate word document now
- Open the docx file in something like notepad++
- Look at the table html
- Use logic to replicate in flow
I will give you some detail for the first of these below, but you can extrapolate enough (I'm sure) to work out the second.
There is one word of caution that I would use regarding all of this, and that is that Microsoft Outlook is the scourge of email clients across the world due to the word handler which 'shows you' the emails. It is why all emails are built out of tables, believe it or not.
Anyway, yes, it is somewhat picky when it comes to obeying CSS, so you might need to go an extra step and actually place 'style' attributes in the <table> and every <th> and <td> element. 😩 I am not going to go to that length for you, but I'm sure that you can figure it out.
CSS Method
Hopefully this is simple enough, and hopefully this works (! ) 😅:
- Open your chosen online generator and make the code.
- Copy only the code that is in the <style> tags and ensure you include the style tags
(see Example - Style Code below)
- Add a Compose action
- Paste in the style code
- Add a line break
- Add a replace function similar to the Example - replace() Expression below
Example - Style Code
In the below spoiler is some example HTML and CSS code which would style a simple HTML table relatively easily:
Spoiler (Highlight to read)
<style>
#demTable {
border:3px solid #ffffff;
border-collapse:collapse;
padding:3px;
}
#demTable th {
border:3px solid #ffffff;
padding:3px;
background: #9f009f;
color: #ffffff;
}
#demTable td {
border:3px solid #ffffff;
text-align:center;
padding:3px;
background: #fff0ff;
color: #313030;
}
</style>
Notice how the generator which I used from codebeautify let me choose to do this by 'ID'?
I chose this option because if I put an ID on the table it will make the table uniquely identifiable and not format other tables in the email the same!
<style>
#demTable {
border:3px solid #ffffff;
border-collapse:collapse;
padding:3px;
}
#demTable th {
border:3px solid #ffffff;
padding:3px;
background: #9f009f;
color: #ffffff;
}
#demTable td {
border:3px solid #ffffff;
text-align:center;
padding:3px;
background: #fff0ff;
color: #313030;
}
</style>
Notice how the generator which I used from codebeautify let me choose to do this by 'ID'?
I chose this option because if I put an ID on the table it will make the table uniquely identifiable and not format other tables in the email the same!
Example - replace() Expression
This example assumes that the HTML table action is named "Create HTML table" in your flow:
replace(body('Create_HTML_table'), '<table>', '<table id="demTable">')
This simply looks for '<table>' in the text from that action and replaces it with the '<table id="demTable">' text.
Hope that this can assist you a bit on your way to finding a fuller solution.
The Compose Action
This is an image of what the compose action might look like:
Style code and replace() function