How to create a download link to an Excel file?

I have an Excel spreadsheet (.xls) that I want to allow users to download it from my web page. Perhaps the “download” button on the page, and when users click on it, the file will be downloaded.

May I know how to do this? Snippets of code and links will be appreciated.

+4
source share
3 answers

You can use simple html links:

link

<a href='/path/to/excel/file.xls' target="_blank">Download</a> 

button

 <form> <input type="button" value="Download" onClick="window.location.href='/path/to/excel/file.xls'"> </form> 
+10
source

How to just link to a file through a binding?

 <a href="path-to-file.xls">Download</a> 
+2
source

I think this should be good too:

 <a href="path-to-file" download="abc.xls">Download</a> 

download: file name to download as.

0
source

Source: https://habr.com/ru/post/1389580/


All Articles