In this Power Apps article, I will explain how Power Apps can download a file from a SharePoint Document library.
By using the Download function, we can easily download a SharePoint library file [with extension] in Power Apps. The file may download and open instantly in a new browser tab, or it may save to the downloads folder only, depending on your browser’s settings.
Here, I will tell you some tricky ways to download documents from SharePoint library in Power Apps.
Also, we will discuss how to download files from the SharePoint library folder in Power Apps.
Create a SharePoint Document Library
I have a SharePoint Document Library named Project Documents. This library has various files, such as Excel, Text, PDF, and images [you can upload any files].
Power Apps Download File From SharePoint Document Library
These are the four various ways to easily download a file from the SharePoint Document library in Power Apps.
Method – 1: [Use the Copy link option of SharePoint file & Download]
- Select a file from the SharePoint library -> Click Show more options (…) -> Copy link.
- In Power Apps, insert a Button control [DOWNLOAD] and set its OnSelect property as:
Download("https://tsinfotechnologies.sharepoint.com/:t:/s/PowerApps/EchzEM7ARqFCrC-qJ3qzZNoBhOud_XldE3b0aYTLGf019g?e=uu0wfo")
OR
Download("https://tsinfotechnologies.sharepoint.com/:t:/s/PowerApps/EchzEM7ARqFCrC-qJ3qzZNoBhOud_XldE3b0aYTLGf019g?e=uu0wfo?web=1")
Where,
- “https://tsinfotechnologies.sharepoint.com/:t:/s/PowerApps/EchzEM7ARqFCrC-qJ3qzZNoBhOud_XldE3b0aYTLGf019g?e=uu0wfo” = Paste the link that you have copied from the library file with double quote (“”)
- ?web=1 = This helps to open the document in the browser instead of directly downloading
- Preview the app and click on the DOWNLOAD button. The specific SharePoint file will open in a new tab, as shown below. Click on Download.
- Next, you will be asked to provide a location on your system to save the file. Rename the file (optional) and click on Save.
NOTE:
Suppose you have an Excel file in the SharePoint library, and you want this file to be forced downloaded instead of opening in the browser; then you need to append &download=1 including the copied link, i.e.
Download("https://tsinfotechnologies.sharepoint.com/:x:/s/PowerApps/ESnkzgxvBaNAnqvNBKhQcZIBl-NI1HNyDe_BTVWqx04h3Q?e=xlioac&download=1")
This is the simplest approach to downloading any SharePoint library file in Power Apps.
Method – 2: [Use the SharePoint Source URL & Download]
There is another method that we can use to download the SharePoint library files in Power Apps. Refer to the code below:
Download("https://<site URL>/_layouts/download.aspx?SourceUrl=/sites/<sitename>/<libraryname>/filenamewithfileextension")
In my case, I have used the below one (On Button’s OnSelect property):
Download("https://tsinfotechnologies.sharepoint.com/sites/PowerApps/_layouts/15/download.aspx?SourceUrl=/sites/PowerApps/ProjectDocuments/Invoice-24CCF73B-0006.pdf")
Preview the app and click DOWNLOAD. It will directly take you to your system to download and ask you to provide the file name. Click Save.
This is one of the easiest ways to download the SharePoint Document file in Power Apps.
Method – 3: [Use Power Apps Launch Function & Download]
We can download files from the SharePoint document library using the Power Apps Launch function. Refer to the code below:
Launch("https://<DomainName>.sharepoint.com/sites/<SiteName>/_layouts/15/download.aspx?SourceUrl=/sites/<SiteName>/<LibraryName>/<FileNamewithExtension>")
I have used the below formula on Button’s OnSelect property:
Launch("https://tsinfotechnologies.sharepoint.com/sites/PowerApps/_layouts/15/download.aspx?SourceUrl=/sites/PowerApps/ProjectDocuments/Invoice-24CCF73B-0006.pdf")
In this way, we can download the SharePoint library file in Power Apps.
However, we can’t provide the link manually each time we want to download the specific library file. For this, you can refer to the other method below.
Method – 4: [Use Power Apps Gallery & Download]
Using Power Apps Gallery Control is the ideal way to choose and download the SharePoint library resources you need. Take a look at the gif below.
Refer to the steps below to achieve this:
- Insert a Vertical gallery control and set its Items property as:
Items = 'Project Documents'
- Select the Title label of the gallery and set its Text property:
Text = ThisItem.'File name with extension'
This code will give you the SharePoint Document file name with its extension.
- To display the SharePoint library document image, select the image control and set its Image property as:
Image = ThisItem.Thumbnail.Large
Also, you can use the code below:
Image = $"https://static2.sharepointonline.com/files/fabric/assets/item-types/24/{Last(Split(ThisItem.'File name with extension',".")).Value}.svg"
The code that follows first retrieves the file extension before pointing to the correct SharePoint URL.
- Next, to download the SharePoint file in Power Apps, we need to add a Download icon [Insert -> Icons -> Download] inside the gallery. [Also, remove the next icon button from gallery]
- Apply the code below on the Download icon’s OnSelect property as:
OnSelect = Download($"https://tsinfotechnologies.sharepoint.com/sites/PowerApps/_layouts/download.aspx?SourceUrl=https://tsinfotechnologies.sharepoint.com/sites/PowerApps/{ThisItem.'Full Path'}")
Replace your SharePoint domain name and site name.
This is another approach where user can download the SharePoint document in Power Apps based on their choice.
Power Apps Download File From SharePoint Library Folder
In the SharePoint Document library, there is a folder named Financial. Inside it, there is a file named Financial Sheet. Now, in Power Apps, we will download this file from the specific SharePoint library folder.
Refer to the code below:
Download("https://<site URL>/_layouts/download.aspx?SourceUrl=/sites/<sitename>/<libraryname>/<foldername>/filenamewithfileextension")
In my case, I have used the code below:
Download("https://tsinfotechnologies.sharepoint.com/sites/PowerApps/_layouts/15/download.aspx?SourceUrl=/sites/PowerApps/ProjectDocuments/Financial/Financial%20Sheet.xlsx")
Preview the app and click DOWNLOAD. Then save the downloaded file and click on Save as like below.
This is how we can download the file from the SharePoint library folder in Power Apps.
Some more articles you may also like:
- Power Apps Upload File to SharePoint Document Library
- Power Apps Choices Function Examples
- Power Apps Toggle Control
- Power Apps Sum Column Examples
- Power Apps Naming Conventions
I hope this article helped you a lot. In this tutorial, I have explained four various approaches to downloading the SharePoint document library files in Power Apps.
Also, I have discussed how Power Apps can download files from the SharePoint library folder with a simple example.
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