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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Can't figure out the L...
Power Automate
Unanswered

Can't figure out the Loop in populating Excel Template

(0) ShareShare
ReportReport
Posted on by 21

Hi! I was able to create a simple flow that populates excel file using an excel template. I need help in creating a loop where it will populate the data on my template based on the Name written above.  

lo_ori_0-1714920317221.png

 

Here's my Template: 

Scenario: One name can have multiple transaction IDs and fees, these details should reflect below the highlighted rows. My source is well plotted (meaning name is organized synchronically and names of the same values are listed together and the different transaction ID are listed beside each names) 

 

lo_ori_1-1714920473611.png

 

Please help me figure out the sequence so I can create this automation

 

 

Categories:
I have the same question (0)
  • UsamaBadrik Profile Picture
    19 Microsoft Employee on at

    I am also having the same scenario to check the headers and sheet name in particular format if user upload it by checking it with the template, do you have any ideas about the run script please do share the flow in details. Thank you!

     

  • lo_ori Profile Picture
    21 on at

    Hi! My flow is very straightforward. I created a simple java script code, you can check it below:

    function main(workbook:
    
     ExcelScript.Workbook,
     MDName: string,
     Period: string,
     Trans: Trans[]
    ) {
    
     let sheet = workbook.getFirstWorksheet();
    
     //Update Payee Details
     sheet.getRange("D11").setValue(Name)
     sheet.getRange("D12").setValue(Period);
    
     const transOffset = 17 //start of row to be filled
    
     // i = 1 because this starts on the 2rd row on the inputed file
    
     for (let i = 0; i < Trans.length; i++) {
     const currentTrans = Trans[i];
     const formattedTrans = [[currentTrans.transDate, currentTrans.transID, currentTrans.profFee, currentTrans.medCertFee, currentTrans.platformFee, currentTrans.vcscDiscount, currentTrans.whtrate, currentTrans.wht, currentTrans.totalDisbursement]];
    
     const saleCell = `C${transOffset + i}:K${transOffset + i}`;
     sheet.getRange(saleCell).setValues(formattedTrans);
     }
     
     
    }
    
    interface Trans {
     transDate: number,
     transID: string,
     profFee: number,
     medCertFee: number,
     platformFee: number,
     vcscDiscount: number,
     whtrate: number,
     wht: number,
     totalDisbursement: number,
    }

     Run-script flow is here: 

    lo_ori_0-1714922083525.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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 873

#2
Valantis Profile Picture

Valantis 813

#3
Haque Profile Picture

Haque 526

Last 30 days Overall leaderboard