cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lexicron
Resolver II
Resolver II

How to save Gallery1.AllItems selective fields to a custom Excel template file?

I have an Excel template file with logos, header, footer, tables and all that. This was designed and provided by consumers of data.

 

However, as a producer of data, instead of doing data entry into that Excel template, I have a Powerapps Canvas mobile app to do the data entry into, which affords a simpler and timelier process. However, the people who are consuming these data still require that Excel template.

 

I would like to be able to "export" the data in my Canvas app, of a particular Screen, of AllItems in a particular Gallery, of only 10 fields (out of many more), into certain cell ranges of that Excel template.

 

Mapping/template rules:

  • the field "Expense date" to populate vertically down cell range A8:A27; the field "Amount" to populate vertically down cell range F8:F27.
  • the images of the field "AttachedImage" to somehow be in the Excel file as well, but I'm not sure how that would work without completely ruining the look of the Excel table where each row has the same height. Perhaps the images can go separately into an Attachments tab in the Excel file? It can just be a image dump.
  • the PDF attachment of the field "AttachedFile" to be an embedded file insert inside the Excel, with an icon small enough to fit within the row height.
  • extra rows in the Excel table to be automatically inserted if there are more records in the gallery that fits in to the template's default row 8 to row 28.
  • the "Owner" of the first gallery item (because Owner is the same for all items) to go into cell A2.
  • the filename of the resulting Excel file will be taken from a label in the Canvas app, lbl_Filename.Text
  • the Excel file will not be available for local download but will be automatically emailed to an address in a label in the Canvas app, lbl_Recipient.Text.

 

Is this possible? If so, where do I upload the Excel template file to begin with? I am working with CDS entities only. No Sharepoint. And how may I go about achieving the list of what I want to do? Any help or point in the right direction would be appreciated please. I am very new to Powerapps.

 

Please and thank you very much!

16 REPLIES 16

If you want your data to be added/updated in excel, you need to upload that excel to OneDrive and use that as the data source (and not CDS).

Then you have to have a data table in excel. Ideally, the table you want should include the cells you want to get populated. You will have to use columns of that table as references in your app and submit data using Patch form or SubmitForm function. You can control the values you want to submit.

If you cannot use the existing spreadsheet as your datasource excel table, may be you can create the data table in another sheet within the same spreadsheet and use cell references to populate your main sheet with data from the other sheet (which will get populated by the Power App).

Let me know what you think of this approach and we can get into the details if needed.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

Thanks!
Hardit Bhatia
The Power Addict
https://thepoweraddict.com

Thank you! It is exciting that this is possible.

 

Yes, your suggestion to use a separate Excel sheet is perfect, and could provide even better results than I planned/hoped.

 

Can you guide me on how to move forward please?

Awesome! For starters, upload your excel file to OneDrive and create a data table in a separate sheet with your column headers. In your App, add that data table as a data source using the OneDrive Excel connector (I dont remember the exact name but its something like this).

Connect your forma to this data source and select the values/fields/columns you want to populate. Submit the form using either SubmitForm or Patch.

Let's get this done first amd then we can get to using cell references to populate your main sheet.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

Thanks!
Hardit Bhatia
The Power Addict
https://thepoweraddict.com
v-xida-msft
Community Support
Community Support

Hi @Lexicron ,

Based on the needs that you mentioned, I agree with @PowerAddict 's thought almost. You could consider format your Excel sheet data as a Table firstly, and then upload it to your OneDrive folder.

After that, you could generate a canvas app based on the Excel table in your OneDrive folder. More details about generating an app based on Excel table, please check the following article or video:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/get-started-create-from-data

https://www.youtube.com/watch?v=-Z_13J02RPU

 

More details about storing image data into a Excel table, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/add-images-pictures-audio-video

 

Currently, there are also some known limits within Excel table, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/connections/cloud-storage-blob-connecti...

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Hardit/ @PowerAddict ,

 

Thank you.

 

Connect your form to this data source and select the values/fields/columns you want to populate. Submit the form using either SubmitForm or Patch.

Do you mean my existing form that I have already set up in my Canvas app? I have a form already connected to a CDS entity. This form is how I/users do data entry into the mobile app (in lieu of data entry into the Excel template).

 

The CDS entity is updated multiple times over a period (usually a month), with new records added, and existing records deleted or amended. At some point I will be ready to send a set of those records to the data consuming team. It is at this point that I want those records moved into the Excel template.

 

I would not want to repeat another form data entry activity for the Excel datasource. In addition, the first instance of data entry (into my existing form connected to the CDS entity) cannot serve as an input into the Excel datasource either, because those records are still open for amendment or deletion, so they're not ready for the Excel template.

 

Is what I want to do still possible then?

 

Or, would I still have to a create a separate form connected to the Excel datasource, but set to Not Visible, then at the time of "readiness", send each record's field values as variables to the Excel-connected form and run a behind-the-scenes SubmitForm to get them into the Excel datasource, record-by-record? This would mean for each "export", the Canvas app will need to run several SubmitForm activities, could be up to 50 times for some users who don't tend to submit their reports regularly.

 

Would you say this is the way to do it?

Hi @Lexicron ,

Do you want to sync records from your CDS Entity to your Excel file at some point?

 

If you want to sync records from your CDS Entity to your Excel file at some point, I think Power Automate flow could achieve your needs. You could consider configure a flow as below:

5.JPG

Within above flow, add "Add a row into a Table" action of "Excel Online (OneDrive)" connector to add entry into your Excel table

 

You could also consider use a "When a record is updated" trigger of Common Data Service connector as Trigger of your flow, then you could specify Attribute Filter Item option to a specific field in your Entity, then this trigger would be fired only when the specific field value has been changed:

6.JPG

 

You could also consider add a Condition action within your flow, then check if the specific field value matches specific value, if true, execute the following actions, otherwise, do nothing.

https://docs.microsoft.com/en-us/power-automate/add-condition

 

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Kris,

 

Thank you. Flow sounds like it would offer a better user experience, since it's processing outside the Canvas app and the user won't be held up. However I have another issue to raise please.

 

The records that I want saved to Excel at any time are filtered by a criterion, where FieldX=<a record lookup variable that is assigned within the Canvas app>.

 

The Flow does allow me to include a Filter Query but I'm not sure if it is able to read the FieldX filter query since that variable is in the Canvas app. This variable is also not just a simple string or number or choice/option set, it is a record lookup from another CDS Entity.

 

So I'm back to my post title: my Canvas app has a filtered Gallery that displays exactly the records that I need saved to Excel. The export action will be triggered by an OnSelect action in the Canvas app. Is it possible to pass this set - and only this set - of records into the Flow to act on?

 

Perhaps if I collected their UniqueIDs into a collection, can I somehow get Flow's Filter Query to pick up only the UniqueIDs that match what is in the collection?

 

(Edit reason: I initially specified 2 filter criteria but on second thought the User filter isn't necessary as the FieldX criterion will sufficiently narrow the query down.)

Hi @Lexicron ,

Based on the needs that you mentioned, I think single Power Automate flow could not achieve your needs.

 

As an fixed solution, you could consider fire a flow from your canvas app. You could also consider define only single one parameter within a "Compose" action in your flow using "Ask in PowerApps" dynamic content. Within your app, filter out these records based on the two criteria, then convert the filtered result into a JSON String value using JSON function:

JSON(Filter('CDS Entity', Field1 = User().FullName, ...))

then you could pass above JSON String to your flow. Then within your flow, you could use the json expression to convert the passed JSON String value into a JSON Table, then you could apply a "Apply to each" action to this JSON Table. Within the "Apply to each" action, you could specify the "Add a row into a Table" action of Excel Online (OneDrive) connector.

Please check and see if the following thread would help in your scenario:

https://powerusers.microsoft.com/t5/Building-Power-Apps/Running-a-power-automate-flow-on-multiple-re...

https://www.youtube.com/watch?v=HLdOO4JPZ2I

 

More details about firing a flow from a canvas app, please check the following article or video:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/using-logic-flows

https://www.youtube.com/watch?v=1wl9AtxWdkg

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you Kris! It is sounding doable but I will read all the resources you linked. I'll report back with what I was able to achieve.

Much appreciated!

Helpful resources

Announcements

Power Platform Connections - Episode 7 | March 30, 2023

Episode Seven of Power Platform Connections sees David Warner and Hugo Bernier talk to Dian Taylor, alongside the latest news, product reviews, and community blogs.     Use the hashtag #PowerPlatformConnects on social media for a chance to have your work featured on the show.     

Announcing | Super Users - 2023 Season 1

Super Users – 2023 Season 1    We are excited to kick off the Power Users Super User Program for 2023 - Season 1.  The Power Platform Super Users have done an amazing job in keeping the Power Platform communities helpful, accurate and responsive. We would like to send these amazing folks a big THANK YOU for their efforts.      Super User Season 1 | Contributions July 1, 2022 – December 31, 2022  Super User Season 2 | Contributions January 1, 2023 – June 30, 2023    Curious what a Super User is? Super Users are especially active community members who are eager to help others with their community questions. There are 2 Super User seasons in a year, and we monitor the community for new potential Super Users at the end of each season. Super Users are recognized in the community with both a rank name and icon next to their username, and a seasonal badge on their profile.    Power Apps  Power Automate  Power Virtual Agents  Power Pages  Pstork1*  Pstork1*  Pstork1*  OliverRodrigues  BCBuizer  Expiscornovus*  Expiscornovus*  ragavanrajan  AhmedSalih  grantjenkins  renatoromao    Mira_Ghaly*  Mira_Ghaly*      Sundeep_Malik*  Sundeep_Malik*      SudeepGhatakNZ*  SudeepGhatakNZ*      StretchFredrik*  StretchFredrik*      365-Assist*  365-Assist*      cha_cha  ekarim2020      timl  Hardesh15      iAm_ManCat  annajhaveri      SebS  Rhiassuring      LaurensM  abm      TheRobRush  Ankesh_49      WiZey  lbendlin      Nogueira1306  Kaif_Siddique      victorcp  RobElliott      dpoggemann  srduval      SBax  CFernandes      Roverandom  schwibach      Akser  CraigStewart      PowerRanger  MichaelAnnis      subsguts  David_MA      EricRegnier  edgonzales      zmansuri  GeorgiosG      ChrisPiasecki  ryule      AmDev  fchopo      phipps0218  tom_riha      theapurva  takolota     Akash17  momlo     BCLS776  Shuvam-rpa     rampprakash  ScottShearer     Rusk  ChristianAbata     cchannon  Koen5     a33ik   Heartholme     AaronKnox        Matren        Alex_10        Jeff_Thorpe        poweractivate        Ramole        DianaBirkelbach        DavidZoon        AJ_Z        PriyankaGeethik        BrianS        StalinPonnusamy        HamidBee        CNT        Anonymous_Hippo        Anchov        KeithAtherton        alaabitar        Tolu_Victor        KRider        sperry1625        IPC_ahaas      zuurg    rubin_boer   cwebb365   Dorrinda   G1124   Gabibalaban   Manan-Malhotra   jcfDaniel   WarrenBelz   Waegemma      If an * is at the end of a user's name this means they are a Multi Super User, in more than one community. Please note this is not the final list, as we are pending a few acceptances.  Once they are received the list will be updated. 

Microsoft Power Platform Conference | Registration Open | Oct. 3-5 2023

We are so excited to see you for the Microsoft Power Platform Conference in Las Vegas October 3-5 2023! But first, let's take a look back at some fun moments and the best community in tech from MPPC 2022 in Orlando, Florida.   Featuring guest speakers such as Charles Lamanna, Heather Cook, Julie Strauss, Nirav Shah, Ryan Cunningham, Sangya Singh, Stephen Siciliano, Hugo Bernier and many more.   Register today: https://www.powerplatformconf.com/   

Check out the new Power Platform Communities Front Door Experience!

We are excited to share the ‘Power Platform Communities Front Door’ experience with you!   Front Door brings together content from all the Power Platform communities into a single place for our community members, customers and low-code, no-code enthusiasts to learn, share and engage with peers, advocates, community program managers and our product team members. There are a host of features and new capabilities now available on Power Platform Communities Front Door to make content more discoverable for all power product community users which includes ForumsUser GroupsEventsCommunity highlightsCommunity by numbersLinks to all communities Users can see top discussions from across all the Power Platform communities and easily navigate to the latest or trending posts for further interaction. Additionally, they can filter to individual products as well.       Users can filter and browse the user group events from all power platform products with feature parity to existing community user group experience and added filtering capabilities.     Users can now explore user groups on the Power Platform Front Door landing page with capability to view all products in Power Platform.    Explore Power Platform Communities Front Door today. Visit Power Platform Community Front door to easily navigate to the different product communities, view a roll up of user groups, events and forums.

Welcome to the Power Apps Community

Welcome! Congratulations on joining the Microsoft Power Apps community! You are now a part of a vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun! Now that you are a member, you can enjoy the following resources:   The Microsoft Power Apps Community Forums If you are looking for support with any part of Microsoft Power Apps, our forums are the place to go. They are titled "Get Help with Microsoft Power Apps " and there you will find thousands of technical professionals with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Apps community forums! Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered!   Microsoft Power Apps IdeasDo you have an idea to improve the Microsoft Power Apps experience, or a feature request for future product updates? Then the "Power Apps Ideas" section is where you can contribute your suggestions and vote for ideas posted by other community members. We constantly look to the most voted Ideas when planning updates, so your suggestions and votes will always make a difference.   Community Blog & NewsOver the years, more than 600 Power Apps Community Blog Articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on building Power Apps. On the Power Apps Community Blog, read the latest Power Apps related posts from our community blog authors around the world. Let us know if you would like to become an author and contribute your own writing — everything Power Apps related is welcome!   Power Apps Samples, Learning and Videos GalleriesOur galleries have a little bit of everything to do with Power Apps. Our galleries are great for finding inspiration for your next app or component. You can view, comment and kudo the apps and component gallery to see what others have created! Or share Power Apps that you have created with other Power Apps enthusiasts. Along with all of that awesome content, there is the Power Apps Community Video & MBAS gallery where you can watch tutorials and demos by Microsoft staff, partners, and community gurus in our community video gallery.   Again, we are excited to welcome you to the Microsoft Power Apps community family! Whether you are brand new to the world of process automation or you are a seasoned Power Apps veteran. Our goal is to shape the community to be your ‘go to’ for support, networking, education, inspiration and encouragement as we enjoy this adventure together!   Let us know in the Community Feedback if you have any questions or comments about your community experience.To learn more about the community and your account be sure to visit our Community Support Area boards to learn more! We look forward to seeing you in the Power Apps Community!The Power Apps Team

Top Solution Authors
Top Kudoed Authors
Users online (6,825)