Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Compose an Html table

(0) ShareShare
ReportReport
Posted on by

I am using the below code, to compose the html table, which is working fine but the alignments, Format of number table is not proper (like I want them to align right etc., total to have 30,500.00, All the number to be on the right aligned, all the text to be left, the date column to be center aligned.)

 

Please guide a html code to get the output as mentioned above.

 

 

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)">')

 

MIA27_0-1718602404593.png

 

  • Anil_g Profile Picture
    668 Super User 2025 Season 1 on at
    Re: Compose an Html table

    @MIA27 

     

    Dont use create html table..rather use apply for each and create the table as you need

     

    a Sample is here

     

    at start use initialize variable with - <Table border="1"><thead style="color:white;background-color:rgb(46,117,182)"><tr><th>Col1</th><th>Col2</th></thead>

    Then use apply for each and loop on table ..inside loop use append to string and select the variable and in expression use like this  - 

    concat('<tr><td style="text-align:center;">',items('Apply_to_each_2')?['Column1'],'</td><tdstyle="text-align:left;">',items('Apply_to_each_2')?['Column3'],'</td></tr>')

    then after apply for each use another append and append the end table tag <\table>

     

    Note: This is sample ..you can use same logic to create your own

     

    You change very styling as you need and compose

     

    Anil_g_0-1718622630654.png

     

    cheers

  • MIA27 Profile Picture
    on at
    Re: Compose an Html table

    Below are the outputs I took as below form run history:

     

    From:

    MIA27_0-1718617086815.pngMIA27_1-1718617118806.png

     

    {
    "body": "<table><thead><tr><th>Customer</th><th>Model</th><th>RecoNo</th><th>SerialNo</th><th>SvcDate</th><th>SvcExpense</th><th>SvcRemarks</th><th>SvcSMR</th></tr></thead><tbody><tr><td>AJLSL</td><td>HM400</td><td>7048</td><td>8651</td><td>26-02-2024</td><td>4500</td><td>18000 HRS SVC ADJUSTED JC. 2-25797 KN(OS01) MAIL DT. 26/02/2024</td><td></td></tr><tr><td>AJLSL</td><td>HM400</td><td>6932</td><td>8651</td><td>08-02-2024</td><td>2500</td><td>17500 HRS SVC ADJUSTED JC. 2-25607 KN(OS01) MAIL DT. 01/02/2024</td><td>17550</td></tr><tr><td>AJLSL</td><td>HM400</td><td>6771</td><td>8651</td><td>15-01-2024</td><td>3500</td><td>17000 HRS SVC ADJUSTED JC. 25486 KN(OS01) MAIL DT. 08/01/2024</td><td>17059</td></tr><tr><td>AJLSL</td><td>HM400</td><td>6603</td><td>8651</td><td>21-12-2023</td><td>2500</td><td>16500 HRS SVC ADJUSTED JC. 25451 KN(OS01) MAIL DT. 17/12/2023</td><td>16528</td></tr><tr><td>AJLSL</td><td>HM400</td><td>6316</td><td>8651</td><td>03-11-2023</td><td>4500</td><td>16000 HRS SVC ADJUSTED JC. 25307 KN(OS01) MAIL DT. 03/11/2023</td><td>16035</td></tr><tr><td>AJLSL</td><td>HM400</td><td>6126</td><td>8651</td><td>15-10-2023</td><td>2500</td><td>15500 HRS SVC ADJUSTED JC. 25236 KN(OS01) MAIL DT. 10/10/2023</td><td>15519</td></tr><tr><td>AJLSL</td><td>HM400</td><td>5938</td><td>8651</td><td>22-09-2023</td><td>3500</td><td>15000 HRS SVC ADJUSTED JC. 25197 KN(OS01) MAIL DT. 17/09/2023</td><td>15028</td></tr><tr><td>AJLSL</td><td>HM400</td><td>5753</td><td>8651</td><td>30-08-2023</td><td>2500</td><td>14500 HRS SVC ADJUSTED JC. 25137 KN(OS01) MAIL DT. 25/08/2023</td><td>14521</td></tr><tr><td>AJLSL</td><td>HM400</td><td>5607</td><td>8651</td><td>10-08-2023</td><td>4500</td><td>14000 HRS SVC ADJUSTED JC. 25019 KN(OS01) MAIL DT. 04/08/2023</td><td>14074</td></tr><tr><td></td><td>Total</td><td></td><td></td><td></td><td>30500</td><td></td><td></td></tr></tbody></table>"
    }

     

    ========================== 

    In the body under it , below code

    MIA27_2-1718617460976.png

     

    <table><thead><tr><th>Customer</th><th>Model</th><th>RecoNo</th><th>SerialNo</th><th>SvcDate</th><th>SvcExpense</th><th>SvcRemarks</th><th>SvcSMR</th></tr></thead><tbody><tr><td>AJLSL</td><td>HM400</td><td>7048</td><td>8651</td><td>26-02-2024</td><td>4500</td><td>18000 HRS SVC ADJUSTED JC. 2-25797 KN(OS01) MAIL DT. 26/02/2024</td><td></td></tr><tr><td>AJLSL</td><td>HM400</td><td>6932</td><td>8651</td><td>08-02-2024</td><td>2500</td><td>17500 HRS SVC ADJUSTED JC. 2-25607 KN(OS01) MAIL DT. 01/02/2024</td><td>17550</td></tr><tr><td>AJLSL</td><td>HM400</td><td>6771</td><td>8651</td><td>15-01-2024</td><td>3500</td><td>17000 HRS SVC ADJUSTED JC. 25486 KN(OS01) MAIL DT. 08/01/2024</td><td>17059</td></tr><tr><td>AJLSL</td><td>HM400</td><td>6603</td><td>8651</td><td>21-12-2023</td><td>2500</td><td>16500 HRS SVC ADJUSTED JC. 25451 KN(OS01) MAIL DT. 17/12/2023</td><td>16528</td></tr><tr><td>AJLSL</td><td>HM400</td><td>6316</td><td>8651</td><td>03-11-2023</td><td>4500</td><td>16000 HRS SVC ADJUSTED JC. 25307 KN(OS01) MAIL DT. 03/11/2023</td><td>16035</td></tr><tr><td>AJLSL</td><td>HM400</td><td>6126</td><td>8651</td><td>15-10-2023</td><td>2500</td><td>15500 HRS SVC ADJUSTED JC. 25236 KN(OS01) MAIL DT. 10/10/2023</td><td>15519</td></tr><tr><td>AJLSL</td><td>HM400</td><td>5938</td><td>8651</td><td>22-09-2023</td><td>3500</td><td>15000 HRS SVC ADJUSTED JC. 25197 KN(OS01) MAIL DT. 17/09/2023</td><td>15028</td></tr><tr><td>AJLSL</td><td>HM400</td><td>5753</td><td>8651</td><td>30-08-2023</td><td>2500</td><td>14500 HRS SVC ADJUSTED JC. 25137 KN(OS01) MAIL DT. 25/08/2023</td><td>14521</td></tr><tr><td>AJLSL</td><td>HM400</td><td>5607</td><td>8651</td><td>10-08-2023</td><td>4500</td><td>14000 HRS SVC ADJUSTED JC. 25019 KN(OS01) MAIL DT. 04/08/2023</td><td>14074</td></tr><tr><td></td><td>Total</td><td></td><td></td><td></td><td>30500</td><td></td><td></td></tr></tbody></table>

     

    ================================== 

     

    As mentioned my first post and with images, that In compose I am using the below:

    I wrote the below expression in the compose 

    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)">')

     

     

    MIA27_4-1718617670196.png

     

    Note: This is getting triggered from Power app application.

     

  • Anil_g Profile Picture
    668 Super User 2025 Season 1 on at
    Re: Compose an Html table

    @MIA27 

     

    Go to run history and copy the actual output of create html table..from that html code we can check where and what to replace for each alignment..as it is different for each column each td might need to be manipulated differently

     

    Also you might need to loop through the created table and perform replace inside the loop based on the column you are getting..direct replace in one function might not work for your case

     

    cheers

  • MIA27 Profile Picture
    on at
    Re: Compose an Html table

    I already mentioned above in my first post. Below is the only HTML code I am using to compose.

    which brings the result as shown earlier.

     

    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)">')

     

     

    Below is image of my complete flow.

    Kindly check and advise, how to improve the output as required

     

     

    MIA27_0-1718604072082.png

     

     

  • v-yetonggu-msft Profile Picture
    on at
    Re: Compose an Html table

    Hi @MIA27 ,

    Could you please copy the original html code for me?

    Thank you.

     

    Best Regards,

    Sunshine Gu

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492