Im trying to download an Excel file in Reactjs by calling a Spring REST endpoint but I\'m running into issues with a corrupt file.
React call...
getF
You just have to add response type to the axios request:
responseType: 'arraybuffer'
In my application following function downloads excel file:
function exportIssues() {
axios.get('/issues/export', { responseType: 'arraybuffer' })
.then((response) => {
var blob = new Blob([response.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
fileSaver.saveAs(blob, 'fixi.xlsx');
});
}