Download an excel(.xlsx) file using blob in angular 2
You could probably just use fetch
and file-saver to retrieve the Excel file:
import { saveAs } from 'file-saver';
// Client side.
// Note: it helps it server serves the appropriate response header, like e.g.
// 'Content-Type': 'application/vnd.openxmlformats'
return fetch(excelFileUrl, { headers: headerInfo })
.then(res => res.blob()) // extract binary blob from response
.then(blob => {
// Download blob with file-saver
FileSaver.saveAs(blob, "MyFile.xlsx");
})
.catch((err) => { console.error('Excel download failed', err); });
Download XLSX via Axios from Express.js server does not work
try adding responseType:'blob'
to request config option:
axios.post('/export', {
entity,
fileformat,
locale: props.locale
}, {
responseType: 'blob'
})
.then((res) => {
provideBlobDownload(filename, res.data);
});
Related Topics
Javascript How to Create One Json by Combining Two Jsons
Show Questions One At a Time in Quiz Website in HTML
Getting Null Value in List When Passing by Ajax Call to MVC Controller
Javascript Adding Variable to Href
How to Get First N Number of Elements from an Array
How to Merge Two Json Object Values by Id With Plain JavaScript (Es6)
How to Remove Single Uploaded File from Jquery in Multiple File Upload
Bootstrap 4 Dropdown Menu Not Working
Angularjs:Ng-Model Binding Not Updating When Changed With Jquery
Calculate the Total of Item Quantity into Item Price With Dynamic HTML Input Fields Using Jquery
How to Tell If a String Contains a Certain Character in JavaScript
How to Make a Bot Delete Messages After a Certain Time Period
How to Compare Two Json Have the Same Properties Without Order
How to Download Fetch Response in React as File
How to Remove Forward and Backward Slashes from String in JavaScript
Javascript or Jquery Browser Back Button Click Detector