Skip to main content

Notifications

Community site session details

Community site session details

Session Id :

Power Apps Export to Excel Component

aprildunnam Profile Picture Posted by aprildunnam 704

In this Template Tuesday video I highlight a PCF Component created by Yash Agarwal that lets you export data from Power Apps directly to Excel! I'll show how to download, install and set up the component so you cant start exporting your Power Apps data to Excel

 

Download Yash's Component here: https://github.com/yashag2255/exportToExcel

Follow Yash on Twitter: https://twitter.com/yashagarwal1651

Check out Yash's blog: https://www.bythedevs.com/blog

Categories:

General PowerApps

Comments

  • dsoden Profile Picture dsoden 73
    Posted at
    Power Apps Export to Excel Component

    @aprildunnam having the code example from your video would have been such a blessing. 

    I see folks also like me had issues - I am good with JSON but dealing with it in this way is a nightmare

    Validating each of my disastrous steps with https://jsonformatter.curiousconcept.com speed up the trouble shooting and I also set a debug var and output my JSON to a label to run by the validator. little gotchas as every turn.

     

    For everyone else, here is my code sample. I had a blank dataverse contact table and added several records to the table, then connected it to the Gallery1

     

     

    Substitute(
     Concatenate("[",
     Concat(Gallery1.AllItems,
     "{" & Char(34) & "Last Name" & Char(34) & ":" & Char(34) & 'Last Name' & Char(34) & ","
     //copy row below to add a new column of data
     & Char(34) & "First Name" & Char(34) & ":" & Char(34) & 'First Name' & Char(34) & ","
     //copy row above to add a new column of data
     & Char(34) & "Full Name" & Char(34) & ":" & Char(34) & 'Full Name' & Char(34) & "},"
     ),
     "]"
     )
    ,",]","]"
    )

     

     

    *** NOTE BLANK VALUES WILL BREAK THE PLUGIIN - so if you think this may be the case in your data, best to handel it with something like...

     

     

    If(IsBlank('Last Name'),"-",'Last Name')

     

     

    in code this change looks like this

     

     

    Substitute(
     Concatenate("[",
     Concat(Gallery1.AllItems,
     "{" & Char(34) & "Last Name" & Char(34) & ":" & Char(34) & If(IsBlank('Last Name'),"-",'Last Name') & Char(34) & ","
     //copy row below to add a new column of data
     & Char(34) & "First Name" & Char(34) & ":" & Char(34) & 'First Name' & Char(34) & ","
     //copy row above to add a new column of data
     & Char(34) & "Full Name" & Char(34) & ":" & Char(34) & 'Full Name' & Char(34) & "},"
     ),
     "]"
     )
    ,",]","]"
    )

     

     

    The final way and the most easiest way in 2024 is to use the JSON function to save some sanity. Here I only have one text input gallery filter control (assuming you have some) add some code like this (note you will need to make sure you include code for ALL filter controls similar to what you have set on your ITEMS property for the Gallery control)

     

     

    dataToExport = JSON(ShowColumns(Gallery1.AllItems,"fullname","firstname","lastname"))

     

     

    Here I am using the new JSON function against the gallery and listing only the columns I want in the download. "JSON(ShowColumns(Gallery1.AllItems,"fullname","firstname","lastname"))" becomes the code to place in the dataToExport property on the Export 2 Excel PCF control. See this Video

     
  • tuoiconan93 Profile Picture tuoiconan93
    Posted at
    Power Apps Export to Excel Component

    I followed the instructions, but after clicking export to excel, it doesn't pop up to save the file
    But I found one thing, that if data is empty, it will pop up, gallery has data, it won't work

  • kevtun1982 Profile Picture kevtun1982 136
    Posted at
    Power Apps Export to Excel Component

    Hi @aprildunnam 

    I am really struggling to implement this in my powerapp. Where you added the formula for the dataToExport... I am not sure what I need to enter into this. Can you help? Or Can anyone help?