Power Apps / Automate – Export Collection To Excel (CSV)
8 steps
Introduction:
This is the blueprint on how to export a collection from Power App into a CSV file opened in Excel. This requires the help of Power Automate.
Step 1:
From a blank Canvas Power App, create a blank flow and entitle it Export To Excel
Step 2:
In the PowerApps (V2) trigger. Add the following inputs:
Content
Step 3:
Add the action below:
Create CSV table
From (place the code below in the Expression tab)
json(triggerBody()['text'])
Note: click Show Advanced Options. If the order of the columns is not important, make the Columns property into Automatic. Otherwise, pick Custom and follow the table below:
Header | Value |
FirstName | item()?[' FirstName' ] |
LastName | item()?[' LastName' ] |
Age | item()?[' Age' ] |
Note: The code under the Value column cannot be seen in Dynamic content. You should type the code in the Expression tab.
Step 4:
Add the action below:
Create file
Folder Path /
File Name Sample Excel.csv
File Content
Step 5:
Go to settings of Create file. Turn Allow Chunking to Off so that the file will overwrite existing ones.
Step 6:
Add the action below:
Create share link
File
Link Type Edit
Link scope Organization
Step 7:
Add the action below:
Respond to a Power App or flow
link =
Checking:
Save the flow and exit. You should return from the Power App studio.
The flow named Export To Excel should be in your Power Automate pane.
Step 8:
On the canvas of your Power app, insert a button named Button1. Change the following properties:
Text property
"Export To Excel"
OnSelect property
//Create the collection
ClearCollect(collContent,
{FirstName:"Colton",LastName:"Baldwin",Age:18},
{FirstName:"Junny",LastName:"Harris",Age:22},
{FirstName:"Jacquelyn",LastName:"Ceballos",Age:32},
{FirstName:"Grady",LastName:"Burgener",Age:42},
{FirstName:"Emmie",LastName:"Winsor",Age:5}
);
//Convert into JSON text
Set(varJSON,JSON(collContent,JSONFormat.Compact));
//Run the flow then open the csv
Launch(ExportToExcel.Run(varJSON).link);
Conclusion:
To test on play mode, click the Export To Excel button. After it loads, it will open a new tab that opens an Excel file saved in your OneDrive that shows the data in your collection formatted as a CSV table.
Did this article help? Let us know how we can improve. Send us a message by clicking the “Contact Us” button below.
Article last updated on Apr 28, 2024
Need expert guidance on Power Apps?