How to Force a SharePoint File to Download Instead of Open
Question details
How to create a direct link that forces a SharePoint file to download to the user's computer rather than opening in the web browser.

- Product
- SharePoint
- Device & OS
- not provided
- Scenario
- A user wants to provide a 'Download Form' link on a SharePoint site for an Excel file, but standard links open the file in Excel for the Web, and hardcoded links break when the file is renamed.
- Observed behavior
- Clicking the SharePoint file link opens the document in the browser by default. Alternatively, using an HTML download link stops working if the file's name in the library is modified.
Verify your SharePoint site URL and ensure you have Site Member or Owner permissions to modify web parts or apply column formatting in your document library.
Use the SharePoint Download Endpoint for Static Links
Force the file to download instantly by prepending the built-in SharePoint download URL to your file link.
This approach utilizes SharePoint's native download page. It is best suited for files whose names are permanent and unlikely to change, ensuring users get a direct download prompt instead of opening the file in Excel for the web.
Navigate to your SharePoint document library, locate the file (such as your Excel form), and copy its direct URL path.
Open a text editor and paste the base download endpoint for your site: https://yourtenant.sharepoint.com/sites/yoursite/_layouts/download.aspx?SourceUrl=. Immediately following the equals sign, paste the direct file URL you copied in the previous step.
Insert the newly constructed URL into your Script Editor web part or hyperlink text (e.g., <a href="your_constructed_url">Download Form</a>). When clicked, the file will automatically download.

Apply Dynamic Column Formatting for Changing File Names
Implement JSON column formatting to automatically generate valid download links even if the file name changes in the library.
View and Edit Downloaded Excel Forms with WPS Office
Once you have successfully downloaded your SharePoint Excel files, you can quickly open, edit, and analyze them using WPS Office. It provides a lightweight, highly compatible, and free alternative to Microsoft Office, keeping your productivity high without the premium cost.
- 1. Launch WPS Office: Open the WPS Office application on your computer after downloading your file from SharePoint.
- 2. Open the downloaded file: Click 'Open' on the home screen and navigate to your computer's 'Downloads' folder.
- 3. Start editing: Select the downloaded Excel form to open it instantly. You can now edit the document and save it locally.

Frequently Asked Questions
Why does my SharePoint file open in the browser instead of downloading?
By default, SharePoint is configured to open Office documents (like Word, Excel, and PowerPoint) in their respective web applications (e.g., Excel for the Web) to facilitate quick viewing and co-authoring. You must explicitly use the download.aspx endpoint to override this default behavior.
Will this download method work for non-Office files like PDFs?
Yes, utilizing the _layouts/download.aspx endpoint works for forcing the download of almost all file types stored in a SharePoint library, including PDFs, images, and text files.
How do I fix the download link if I rename the SharePoint file?
If you are using a static download link, you must manually edit the URL and update the SourceUrl parameter to reflect the new file name. To avoid this manual update, it is recommended to use dynamic SharePoint column formatting with the [$FileRef] parameter.




