Rachel
Rachel

Reputation: 41

How can I download an excel file in angular 6

How do I download excel file at an angular 6

The file sent to my angular from C# as an array of bytes by webApi

The required format is .xlsx

 downloadFile(result, fileName) {
    var byteArray = new Uint8Array(atob(result).split('').map(char => char.charCodeAt(0)));
    var blb = new Blob([byteArray], { type: EXCEL_TYPE });
    FileSaver.saveAs(blb, fileName);
  }

(resulat = c# byte array)

Upvotes: 2

Views: 728

Answers (1)

Danielle
Danielle

Reputation: 1496

Try File Saver. That's what I use.

npm install file-saver --save
npm install @types/file-saver --save

This post may help you:

How do I download a file with Angular2 or greater

Cheers.

Upvotes: 3

Related Questions