I was recently required to copy the data from the Power Apps gallery to Excel in a table format. Power Apps provides a useful function called the Copy() function to achieve this quickly.
In this article, I will explain the Power Apps Copy Function, its syntax, and how to use the Copy function in the Power Apps Canvas app. Along with that, we will also discuss the topics below:
- How to copy text to the clipboard in Power Apps
- Power Apps copy the table to the clipboard
- Power Apps copy the collection to the clipboard
Power Apps Copy Function
The Copy() function in Power Apps copies the text value directly to the clipboard. This function accepts any text string as its argument. We can use this function in any behavior properties(e.g., OnSelect, OnChange), typically triggered by user actions like clicking a button or icon.
Syntax:
Copy(text)
The copy function is limited to the app’s host’s access to the clipboard. Therefore, embedded apps, such as those in SharePoint, Power BI, or Teams, do not support this function.
Let’s see an example of copying the text to a clipboard.
Power Apps Copy Text to Clipboard
Look at the example below. When I click on the copy icon, the email in the text input control is copied and can be pasted into another text input control.
Follow the steps below to achieve the above example.
1. In Power Apps, add two text input controls for copying and pasting the email text.
2. Add a copy icon from the +Insert tab. Then, add the code below to its OnSelect property.
Now, save the changes. While previewing, provide an email in the text input control and click on the copy icon. Then, on the following input control, paste the copied text by clicking ctrl+ V on the keyboard.
Power Apps Copy Table to Clipboard
Look at the example below. I have displayed details of the upcoming workshop in the Power Apps gallery. After clicking on the copy icon, the details are copied, and then in the Excel sheet, when I click Ctrl + V, the details are displayed in table format.
Follow the steps below to achieve this!
1. In Power Apps, add a gallery control and connect it with the SharePoint list by providing the list name in its OnSelect property.
'Upcoming PowerApps Work Shops'
‘Upcoming PowerApps Work Shops’ is the SharePoint list name.
2. Provide the below formula on each label’s OnSelect property within the gallery control.
Copy(Self.Text)
Self.Text will take current data.
3. Add a copy icon and provide the below formula on its OnSelect property.
Copy(
Concat(Gal_WorkshopDetails.AllItems,
lbl_Title.Text & Char(9) & lbl_Date.Text & Char(9) & lbl_presenter.Text & Char(10)
)
);
The Concat function will concat all the details in each text label in the Power Apps gallery control.
- lbl_Title = Contains workshop title
- lbl_Date = Contains the workshop conducted to date
- lbl_presenter = Contains the workshop conducted presenter name
4. Now, save changes and preview the app. Then, click on each label in the Power Apps gallery control and click on the copy icon. In Excel, click on ctrl+V, and you’ll see the copied data in the excel.
Power Apps Copy Collection to Clipboard
With the Power Apps copy function, we can copy the collection to a clipboard and paste it anywhere. In the example below, you can see I have created a collection by clicking on the button control; later, click on the copy icon. I have now copied the collection in Excel.
Follow the steps below to achieve this!
1. Add a button control in the Power Apps and provide the below formula in its OnSelect property.
ClearCollect(colEmployees,
{ Name: "Alice" },
{ Name: "Bob" },
{ Name: "Charlie" },
{Name:"John"}
);
Set(NamesToCopy, Concat(colEmployees, Name & Char(10)));
Here, colEmployees is the collection name that contains sample employee names. NamesToCopy is the variable name that stores the concatenated employee names with a new line. Char(10) is used to create a new line.
2. Add a copy icon and the formula below in its OnSelect property.
Copy(NamesToCopy);
3. Now, save the changes and preview the app. Click on the button control to create a collection, then check whether the collection has been created or not. Later, click on the copy icon and paste it into Excel.
This way, we can copy the text from the controls in Power Apps and paste it anywhere.
I hope you understand the Power App copy function. In this article, I have explained various examples of copying and pasting text from Power Apps controls. You can follow this article while trying to copy the text from Power Apps control to outside the app or within the app.
Also, you may like:
- Power Apps Calendar Function With Examples
- Power Apps count function
- Power Apps sequence function
- Power Apps sort function
- Power Apps Modern Form Control
- Power Apps Download Function
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com