Use Copy() function to copy and paste tabular formated data from Power Apps to Excel

Use Copy() function to copy and paste tabular formated data from Power Apps to Excel

We've been waiting for the copy to clipboard feature in Canvas apps for a long time. Now that it has been added, it opens up many possibilities.

One of the features that I have often been asked for, was to make it possible to copy and paste from a Power Apps to Excel in the form of a table. It's now very easy with the Copy() function!


When we copy a selection of cells from Excel, and paste the contents into Notepad, we can notice that:

  1. Columns are separated by a tab
  2. Lines are separated by a carriage return


We can therefore use the Concat() and Char() functions to reproduce this format. In the following example, we are going to use a "Sample List", which contains the columns:

  • Name (type text)
  • Number (decimal type)
  • Choice (choice type)
  • DateTime (DateType)
  • YesNo (Boolean type)
  • ImageUrl (Type Text)


We are going to add a button or an icon with the following code in its OnSelect property:


Copy(
? ? Concat(
? ? ? ? 'Sample List',
? ? ? ? Name & Char(9) & Number & Char(9) & Choice.Value & Char(9) & Text(DateTime,DateTimeFormat.ShortDateTime,"fr-FR") & Char(9) & YesNo & Char(9) & ImageUrl,
? ? ? ? Char(13)
? ? )
);Notify("All gallery data copied to clipboard",NotificationType.Success)(        


Aucun texte alternatif pour cette image


We concatenate the values of each line, separated by a Char(9) which is the tab character.

We define the separator of our Concat() function with a Char(13) which is the code for the carriage return character.

We then add a Notify() to let the user know the data has been successfully copied to the clipboard.

?

At this point, this is what the contents of the clipboard look like:

Lorem *	712.54	Choix 3	08/11/2022 13:15	true	https://i.insider.com/602ee9ced3ad27001837f2ac?width=1000&format=jpeg&auto=webp
Ipsum	196.22	Choix 2	05/09/2022 05:30	false	https://wallpapercave.com/wp/wp9414344.jpg
Dolor	504.39	Choix 3	02/09/2022 09:00	true	https://cdn.musicfeeds.com.au/assets/uploads/2021/02/Rick-roll-2021.png
Sit	175.74	Choix 2	06/11/2022 08:00	false	https://i.ytimg.com/vi/Gm2IgoXVB5I/maxresdefault.jpg
Amet	634.15	Choix 3	30/09/2022 09:00	true	https://th.bing.com/th/id/OIP.kBv7vHExzeSqcP4QQeKTYAHaEK?pid=ImgDet&rs=1
Consecutor	814.4	Choix 1	08/09/2022 09:00	false	https://i.ytimg.com/vi/5GTTYyQ2PKg/hqdefault.jpg
Drecuasers	361.67	Choix 1		false	https://th.bing.com/th/id/OIP.a_LfXVUcCaxB2Du2aPApwQHaD5?pid=ImgDet&rs=1
Rolmunaris	672.19	Choix 3		true	https://th.bing.com/th/id/R.53397c074774d50bf6869a91fd389b3c?rik=hIsRGz0BBUlt3w&pid=ImgRaw&r=0
Sin Pecador	421.37	Choix 1		true	https://i.imgflip.com/4ty18o.jpg
cansuilis	43.79	Choix 1	23/11/2022 00:00	true	https://www.punto-informatico.it/app/uploads/2021/02/rick.jpg
Veritas	852.33	Choix 1	15/11/2022 00:00	true	https://i.insider.com/602ee9ced3ad27001837f2ac?width=1000&format=jpeg&auto=webp
Nouveau	9.5	Choix 1	15/12/2022 15:30	true	https://i.ytimg.com/vi/Gm2IgoXVB5I/maxresdefault.jpg        

?

But once pasted into Excel, each value is housed in its cell !

Aucun texte alternatif pour cette image

?

I have been trying to do the opposite, to allow the users to copy a table from excel and paste it in the app to populate the input fields in a gallery (I want it to feel like when you copy data from one excel sheet to another).? I tried using a text input and the Split function trying to split it by Char(10)&Char(13) but it seems like the text input does not keep the characters, any idea on how could we achieve this? I dont see any functions that allows me to read directly what's on the user's clipboard?

赞
回复
Alejandro Nicolas Rodriguez Garcia

SSO | Federation Services | ADFS | PingFederate | PingAccess | PlainID | MFA | AzureAD

11 个月

This is great! any way to add the headers also? thanks

赞
回复
Yeshai Mishal

Business Analytics Manager, Avantor | Lean Six Sigma Black Belt

1 å¹´

Very useful post that I will definitely reference. FYI I think you may have some very minor bracket-related typos in your code, but it should be obvious enough for anyone to fix when they try it out.

Fadi Ahdab

IT Manager at NIVA Oil Trading Ltd

1 å¹´

Thank you ,what a grate post ,you made my day

要查看或添加评论,请登录

社区洞察

其他会员也浏览了