Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi There,

I am trying to download a file from my folder on a button click in angular. I tried below code but it's not working. Can someone please suggest what I am missing?
JavaScript
Installed XLSX and file-save npm package
   this.fileName= 'D:\\temp\\Final_output.xlsx';  
     var data = new Blob([this.fileName], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
    FileSaver.saveAs(data, this.fileName);     


through above code I am able to download the file but while opening that xlsx file I am getting an error, invalid file type or extension.

So I tried below code:
JavaScript
this.fileName= 'D:\\temp\\Final_output.xlsx';  
FileSaver.saveAs(this.fileName, "OutputFile");    

This is not working at all.

Please help.

Thanks

What I have tried:

I have tried two ways mentioned above but both are not working.
Posted
Comments
F-ES Sitecore 2-Jul-20 7:25am    
Consult the documentation about how to do what you want to do. It's not clear from your question what you're trying to do, but you won't be able to load files from the client system via js. If the xlsx file is on your server then you'll need to stream it from a url rather than accessing it by path.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900