Skip to content

Export Data from PowerApps Gallery to Excel

April 15, 2022
  1. First Create a excel template with column headers in SharePoint library/Shared drive.

For my requirement, following are the Column Headers:

Id, Log Types, Date Entered, Date of Effort, Effort Hours, Comments.

2. Create a Flow in Power automate as shown below:

3. In power apps application, add a button, then write below functions for OnClick property.

//Set a Header variable
Set(HeaderVar,”Id,Log Types,Date Entered,Date of Effort,Effort Hours,Comments”);
//Clear the collection

Clear(EffortLogColl);

//Collect the data for all records within the gallery
ForAll(BrowseGallery1.AllItems,Collect(EffortLogColl,{DofEffortColl:DofEffortGall.Text,ElogTypesColl:ELogTypesGall.Text,IntakeIDColl:IntakeIDGall.Text,DEnteredColl:DEnteredGall.Text,EffortHoursColl:EffortHoursGall.Text,ELCommentsColl:ELCommentsGall.Text}));

//Create a variable to store Header variable and collection data
Set(ExportCSVVar,””);
Set(ExportCSVVar,HeaderVar&Char(10)&Concat(EffortLogColl,IntakeIDColl&”,”&ElogTypesColl&”,”&DEnteredColl&”,”&DofEffortColl&”,”&EffortHoursColl&”,”&ELCommentsColl&Char(10)));


//Set(SuccessVar,ExportToExcel.Run(“EffortLog”,ExportCSVVar).Completed));
//ExportToExcel.Run(“CSVFile”,ExportCSVVar,Today());
//SaveToSP.Run(“CSVFile”,ExportCSVVar,ExportCSVVar)

//Run the flow and then get the link and save it to variable
Set(SuccessVar,SaveToSP.Run(“CSVFile”,ExportCSVVar,ExportCSVVar).completed);

//Use Launch to open the file in browser
If(SuccessVar,Launch(“https://test.sharepoint.com/:x:/r/sites/TestSite/Shared%20Documents/CSVFile.CSV?d=w4d3c75a0c1974b0f9f0339f4dd466b41&csf=1&web=1&e=2Pcwpc&Download=1”))

Advertisement
Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: