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:
This is just an example of IF condition that is always true (just testing). In Power Automate I filled the fields with some data.
Then I converted the word file to PDF, and I got this:
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:
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.
Solved! Go to Solution.
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)
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.
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)
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.
@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:
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.
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:
Your output should turn from this:
Into this:
User | Count |
---|---|
33 | |
32 | |
23 | |
22 | |
19 |
User | Count |
---|---|
58 | |
55 | |
41 | |
37 | |
28 |