Skip to main content

Notifications

Community site session details

Community site session details

Session Id : Q3TXqT6RcQeVwCvJ/IAW65
Power Automate - Building Flows
Unanswered

Populate a Word Document Template with Data from Excel (multiple rows to one output docx file)

Like (0) ShareShare
ReportReport
Posted on 22 Jun 2023 15:35:08 by 4

Hi

I am trying to create a flow that takes data from a file saved in Sharepoint (I've tried both a spreadsheet and List in my many attempts) and then populates a word document - this is to generate invoices. 

 

The trigger is manual and the flow initiated by a task being completed in Teams. 

 

The data in the Excel is structured (represented in the below image which hopefully makes sense) in such a way that I need to return multiple rows from excel to populate a single table/generate a single document in word.

 

As noted in the colour key below:

  1.  Green  = my notes
  2. Orange = Column headers
  3. Blue = groupings (e.g. would expect four documents to be output based on this sample). I intentionally left out AC4 in the 'Account Code' column as this will be a weekly process and not all Account Codes will appear each week

cepaterson_0-1687447487011.png

In this scenario I would expect four word documents to be generated:

  1. AC1 with 6 rows in the table of the document
  2. AC2/AC3/AC5 all with three rows in their respective/independent documents

I have created a word template with the below fields (above is condensed for illustration purposes) and have highlighted the row and selected 'Repeating Section Content Control' in Developer mode.

cepaterson_1-1687447800286.png

 

Specific question in relation to the template - I'm assuming it is the entire row that should be marked as repeating? Not just the Account Code field?

 

Summary

After many failed attempts I'm wondering if anyone can help with this??

I have managed to build a flow that generates a document for each account code listed but only takes the first row of data (N.B. Some Account Codes may genuinely only have one row of data where some have multiple).

 

Any help at all would be greatly appreciated!

 

 

 

  • Community Power Platform Member Profile Picture
    on 12 Jan 2024 at 13:53:19
    Re: Populate a Word Document Template with Data from Excel (multiple rows to one output docx file)

    Can you please elaborate why you used two different initialize variable actions after the first apply to each section and what they are used for? What where the parameters for those? Thanks in advance! 

  • AlexEncodian Profile Picture
    4,409 Super User 2025 Season 1 on 23 Jun 2023 at 13:49:43
    Re: Populate a Word Document Template with Data from Excel (multiple rows to one output docx file)

    @cepaterson 

    I left the value blank when initialising the variables. They get populated later (array type is correct)

    I'm not sure which part of your flow is running into limits. Can you see in the run history?

    Apply to each should be able to handle 5,000 iterations. You may have to manually increase limits for the list rows in excel action which used to have a default limit of 256 rows

    Retrieve More Than The Default Number Of Rows Of Data From Excel Using Power Automate (c-sharpcorner.com)

    In your test run, how many rows did you have / how many unique accounts? Is the flow working with smaller test data?

  • cepaterson Profile Picture
    4 on 23 Jun 2023 at 13:40:15
    Re: Populate a Word Document Template with Data from Excel (multiple rows to one output docx file)

    Hi @AlexEncodian thank you so much for the above! I'll give it a try!

     

    Can I just check, in your second set of screenshots, where you have 'Initialize Variable' for Unique Accounts/Doc Data etc, are the paramaters for these steps:

     

    Initialize Variable

    Array

    Value - selecting the variable you've listed (e.g. Unique Accounts)?

     

    Through my test runs I have encountered errors stating that the flow time has run out/flow has stopped. With such a large data set, do you have any suggestions outwith Power Automate that would allow me to populate the word document from excel? Is it worth exploring Power Query also?

     

    Thanks again!

  • cepaterson Profile Picture
    4 on 23 Jun 2023 at 11:25:56
    Re: Populate a Word Document Template with Data from Excel (multiple rows to one output docx file)

    Hi @AlexEncodian 

    1. It is in a table format (flows referencing Table1)

    2. No preference as to whether it is excel or a list but thought excel in sharepoint might be better as the flow would be looking for the file name/path instead of having to delete and re-enter items on a list/append to the bottom of an existing list as it would become too large?

    3. Re volumes max could be around 2,000 rows with a few hundred Account Codes (e.g. groups)

     

     

  • AlexEncodian Profile Picture
    4,409 Super User 2025 Season 1 on 23 Jun 2023 at 10:52:16
    Re: Populate a Word Document Template with Data from Excel (multiple rows to one output docx file)

    @cepaterson 

    Hi, can I ask is the excel data contained within a table content control or is it just free form excel? Do you have a preference for whether its excel or a list? And is it always the same few account codes or could it the number of account codes expand / could there be a large number of them?

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,658 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard
Loading started