web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / tfoot html tag code no...
Power Automate
Unanswered

tfoot html tag code not working while formatting html table - what can be alternative

(1) ShareShare
ReportReport
Posted on by 2

I am trying to use the below code, in which I am using tfoot tag for the last row to change the back ground color.

All is working fine (header row is fine, body all row is fine) BUT it has no impact on the last row. No error of the flow.

It remain as it is.

 

Please advise what changes to do in the below code to get my requirement..

 

replace(replace(replace(body('Create_HTML_table'),'<table>','<table border="3" style="font-style:normal;font-family:calibri;color:black;background-color: rgb(255,255,255);font-size:14px">') ,'<th>','<th style="color:white;background-color:rgb(46,117,182)">') ,'<tfoot>','<tfoot style="color:white;background-color:rgb(46,117,182)">')

 

MIA27_0-1721070208895.png

 

Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,315 Super User 2025 Season 2 on at

    Hi @MIA27 

     

    Please save my old man eye balls and use the Code Snippet </> no just pasting it in 🙂

     

    Please don't say I am trying to do this code. Explain it please 🙂 i dont want to figure it out 🙂 Happy to help but please help me help you hehe

     

  • MIA27 Profile Picture
    2 on at

    Good morning Mr. Mike,

     

    Was following you and was waiting for one of post where you mentioned that you are to busy and will advise.

    https://powerusers.microsoft.com/t5/Building-Flows/How-to-use-If-criteria-for-Select-Data-operation/m-p/2844422#M319428 

    Still awaiting for your advise, May be others see that SuperUser is involved so It will be solved, therefore no body else look more to it and till date no advise from no one. 

     

    Hope that you will reply to this post and will help me to solve the requirement. Now let me explain you the reason of what you mentioned : 

     

    Code Snipped pasting: 

    My experience on this platform of question posting is that if you use the code snippet windows section, it will not get forward and keeping pop up red box with error till you post the proper coding. Which means the code should be ok by the coding way lines even if it is not working. Therefore, after several times, if I am not sure about the correct coding, I paste direct.

     

    Your Quote " Please don't say I am trying to do this code. Explain it please "

    I could not understand what more to be explained in this coding. As I mentioned that the code used is this, it has no error but have no impact on the last row.  Therefore, I also tried to explain it by image marking on it. 

    Was asking that the same code works for the html direct coding where I saw many MVP advising and people confirming that solved. 

    But I wanted the <tfoot> to be use with Replace() function.

     

    Kindly advise is it possible to combine Tfoot with repace Or my method is wrong. 

     

     

     

     

     

     

  • Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at

    Hi @MIA27 

    @FLMike is talking about how the format of your function is provided in the forum.

    If you expect help, you should make it more convinient to your potential supporters.

    Even your future self will be grateful for a more readable expression in the flow 😉

     

    E.g. write it like this:

     

    replace(
    	replace(
    		replace(
    			body('Create_HTML_table'),
    			'<table>',
    			'<table border="3" style="font-style:normal;font-family:calibri;color:black;background-color: rgb(255,255,255);font-size:14px">'
    		) ,
    		'<th>',
    		'<th style="color:white;background-color:rgb(46,117,182)">'
    	) ,
    	'<tfoot>',
    	'<tfoot style="color:white;background-color:rgb(46,117,182)">'
    )

     

     

    From here, your expression is easy to understand and I notice that in the output of "Create HTML Table" there is no HTML <tfoot> element to replace.

  • MIA27 Profile Picture
    2 on at

    Dear Chriddle,

     

    Thank you for your reply. 

    Noted your and Mr. Mike advise.

     

    Just put its replacement string at the end of the replacement string for <table>

    Your advise, I have not understood. How to apply in the code.

     

    Requirement  was to change the color of the last row. Instead of <tfoot>, I tried the below line

    '<tr>','<tr:last-child style="color:white;background-color:rgb(46,117,182)">')

     

    Also It does not work.

     

    Can you please advise, to achieve the requirement, what changes to be done in the code.

     

     

     

     

  • Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at

    :last-child is a CSS pseudo-class and therfore of no use outside a CSS style.

    Additionally it dies not work in some email clients like Outlook.

     

    I prefer a style tag over the inline setting of CSS.

     

    Instead of replacement in the HTML string you can do this:

    Chriddle_0-1721127301188.png

     

    JsonTable

    Convert the HTML table via xml() to a JSON object

     

     

    json(xml(body('Create_HTML_table')))

     

     

     

    JsonTableEnhanced

    Manipulate the table object as needed.

    Here: add a classname to table and to the last row in tbody

    (Creating the “tr” array looks a bit wild, but you can also do this by initializing an array variable and appending to it in case you’re ready to add more boxes to the flow. 😉)

     

     

    {
     "table": {
     "@@class": "table1",
     "thead": @{outputs('JsonTable')['table/thead']},
     "tbody": {
     "tr": @{json(
    	concat(
    		'[',
    		slice(
    			string(take(outputs('JsonTable')['table/tbody/tr'], sub(length(outputs('JsonTable')['table/tbody/tr']), 1))),
    			1,
    			-1
    		),
    		',',
    		string(
    			addProperty(
    				last(outputs('JsonTable')['table/tbody/tr']),
    				'@class',
    				'lastrow'
    			)
    		),
    		']'
    	)
    )}
     }
     }
    }

     

     

     

    HtmlTable

    Add some styles and convert the object back to XML (HTML)

     

     

    <style>
    	.table1 tr td {color: green;}
    	.table1 tr.lastrow td {color: red;}
    </style>
    
    @{xml(outputs('JsonTableEnhanced'))}

     

     

     

    The table will look like this:

    Chriddle_0-1721128095483.png

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard