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 Apps / How to Create an excel...
Power Apps
Answered

How to Create an excel file based on collection

(0) ShareShare
ReportReport
Posted on by 243

Hi all,

 

I've a collection I need to create an excel file when I click a button.

I need to send all Records in collection to a Power automate.

how to do that?

Categories:
  • eka24 Profile Picture
    20,925 on at

    If you want to send data from collection to data source using for all:

    ForAll(YourCollectionName,
    Patch(Datasource,
    Defaults(Datasource),
    {FieldA: fieldInCollection1,
    FieldB: fieldInCollection2} ) )

     

    Datasource is your excel, sharepointlist or SQL etc



    For futher understang watch:
    https://youtu.be/0xZ4fMJbLvk?t=399

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @SumanKoduri ,

     

    Expect for the ForAll function, if the Collection Column Names are the same as the Excel table Column Name, you can directly use Patch or Collect function to save the Collection to excel.

    Here is an example:

    The Collection has three Text columns, ID, Title, Name, the same as the Excel table column names.

    Snipaste_2020-02-27_11-34-09.pngSnipaste_2020-02-27_11-34-44.png

    Then try with Patch(Table1,MyCol) or Collect(Table1,MyCol) code, the collection can be saved to Excel table more efficiently.

    Snipaste_2020-02-27_11-39-56.png

    Note: ensure the column types consistent.

     

    To your second question, If you want to pass the Collection to Flow, please try with the Json function to format the collection in app.

    Then in flow, use Parse JSON Action to extract the collection data, please refer to this video to learn how to Send Collection to Flow.

    https://www.youtube.com/watch?time_continue=578&v=HLdOO4JPZ2I&feature=emb_title 

    Sik

  • SumanKoduri Profile Picture
    243 on at

    Thank you

     

    I have a collection from my table and I need to send that collection as an Excel and send that excel as attachment in Mail 

  • Verified answer
    v-siky-msft Profile Picture
    Microsoft Employee on at

     

    Hi  SumanKoduri,

     

    You can just use ForAll/Patch function to save Collection to Excel table, and send the excel as an attachment in Mail via Power Automate/Flow.

    1. Add "send that excel as attachment in Mail " action in flow, select the Excel file in OneDrive for business.

    2. Add "Send an email (V2)" action, set 'To', 'Subject' and 'Body' to 'Ask in PowerApps',

    3. Set 'Attachments Name' to 'Excel.xlsx', Set 'Attachments Content' to 'File content'

    4. In PowerApps, add flow run code after the ForAll/Patch function.

     

    'PowerApp->Getfilecontent,Sendanemail(V2)'.Run("Test@Domain.com","Test","Test")

     

    Then, when you click the button, first to save collection to Excel table, then send the Excel files as an attachment in the email.

    Sik

     

     

    Snipaste_2020-03-02_16-47-27.pngSnipaste_2020-03-02_16-55-21.png

  • Andres_Friss Profile Picture
    3 on at

    for me it only exports the first row of the table, sometimes it exports everything if I wait a long time to run the flow.

    any ideas so that after the forall runs it already sends the updated spreadsheet?

    help.png
  • PaulUK86 Profile Picture
    43 on at

    Is there a way that this can be a new excel file? Not an existing one?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 312

#3
Mohsin Ali Profile Picture

Mohsin Ali 252

Last 30 days Overall leaderboard