cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
joao123
Frequent Visitor

Populate a Microsoft Word template - Hide blank table / Nested tables / HTML inside Word

Hello,

 

I am trying to create a PDF file with data from Sharepoint. That PDF will be converted from a Word file with the help of PowerAutomate. The problem is that the table that I am trying to make is a little complex. So, with this I have 3 questions:

 

First Question:
It is possible to hide a table that does not have any data?

I want to fill a table with data from sharepoint, but if there is no data I want to hide that table. I already tried an IF condition in word:

 

Capturar.PNG

This is just an example of IF condition that is always true (just testing). In Power Automate I filled the fields with some data.

Capturar1.PNGCapturar5.PNG

Then I converted the word file to PDF, and I got this:

Capturar3.PNG
Clearly my idea did not work 😕

Anyway, is there any way that I can do this? If there is data, then fill the table, if there is no data, hide/delete table.

 

The second question is related is nested tables. (If there is a solution for my first question, I don't need this step)

I want to do a repeating table, but inside a cell I want to do another repeating table, like this:

Capturar7.PNG

In this example I have 2 "Repeating Section Content Control" . One has all the columns, and the second one has only the last three columns. The problem is that in Power Automate, when I try to populate a word template only the first repeating section content control appears. Is there any way that I can do this? 

 

Third Question:

It is possible to add a HTML table inside a Word file? I'm asking this because I can make the table that I want easily in HTML with the help of PowerApps. If there is any way to put that table inside the word document, it would be perfect. 

Btw I could use the HTML code directly to create the PDF file, but the problem is, that the table could be big, and I need page number and total page number and I don't know how to do that in HTML. That is why I want to use the Word template.

 

Thank you in advance for your help. 

1 ACCEPTED SOLUTION

Accepted Solutions
v-litu-msft
Community Support
Community Support

Hi @joao123,

 

First Answer:

It is impossible to hide a table whatever it whether it has data. Currently, the operation about template doc has some limitations. We could append data into a table, but we couldn't do anything about the table itself.

 

Second Answer:

Just like I said in first answer, we couldn't do operation on table itself, we couldn't delete it, modified it, or create it. So we couldn't repeat Table Test1 and Test2.

 

Third Answer:

Unfortunately and sadly to say, currently, Populate a Word template does not support insert a rich text, it also means the HTML table couldn't be inserted.

 

If you could use the HTML code directly to create the PDF file, why just do it directly? If your problem is don't know how many pages will be created, you just needs to get number of all rows, and number of one page could hold, then div them, for example:

In my test, one PDF could hold 47 rows, include header, and the number of total rows is 100, so the page is (100/47)+1 = 3.

The expression in Flow will be:

add(div(number of total rows, per page rows),1)

eg.

add(div(100,47),1)

Annotation 2020-04-29 111835.png

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-litu-msft
Community Support
Community Support

Hi @joao123,

 

First Answer:

It is impossible to hide a table whatever it whether it has data. Currently, the operation about template doc has some limitations. We could append data into a table, but we couldn't do anything about the table itself.

 

Second Answer:

Just like I said in first answer, we couldn't do operation on table itself, we couldn't delete it, modified it, or create it. So we couldn't repeat Table Test1 and Test2.

 

Third Answer:

Unfortunately and sadly to say, currently, Populate a Word template does not support insert a rich text, it also means the HTML table couldn't be inserted.

 

If you could use the HTML code directly to create the PDF file, why just do it directly? If your problem is don't know how many pages will be created, you just needs to get number of all rows, and number of one page could hold, then div them, for example:

In my test, one PDF could hold 47 rows, include header, and the number of total rows is 100, so the page is (100/47)+1 = 3.

The expression in Flow will be:

add(div(number of total rows, per page rows),1)

eg.

add(div(100,47),1)

Annotation 2020-04-29 111835.png

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

@v-litu-msft  Thank you for you help.

 

I think I will try your sugestion.

 

The thing is, I already made the HTML document, which the data I gathered from sharepoint and added to a table with the help of PowerApps as shown in this video: https://www.youtube.com/watch?v=bfXV_GXc_JM&t=1325s
Now, what I don't know how to do is the repeating header and footer with page number. If anyone could give me some advice it would be wonderful. And btw, should I use powerautomate to convert HTML to PDF or another converter like jspdf? 

 

Thank you in advance

Hi @joao123,

 

About repeat header and footer, I have no idea.

 

About convert the HTML table into PDF, you could refer to these steps:

Annotation 2020-05-01 181302.png

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

JFDIJoely
New Member

Have you tried surrounding the header of the table with a Repeating Section? Then in Flow you can pass in a pair of empty arrays [] - one to the header section and one to the data section.

 

Step by step guide here:

 

https://joelblogs.co.uk/2021/06/28/microsoft-flow-tip-1-word-templates-and-hiding-empty-repeating-se...

 

Your output should turn from this:

JFDIJoely_0-1624906175535.png

Into this:

JFDIJoely_1-1624906190327.png

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (2,464)