I am having difficulty downloading an Excel
file in xlsx
format using my Vue.js
application. The Vue.js application sends a post request to the Node.js application which then downloads the Excel file from a remote SFTP server. The backend application is functioning without any issues.
Within the Vue.js application, I have the following code:
axios.post(config.backendHost + '/excel', {
file_name: fileName
}).then((response) => {
const url = URL.createObjectURL(new Blob([response.data], {
type: 'application/vnd.ms-excel'
}))
const link = document.createElement('a')
link.href = url
link.setAttribute('download', fileName)
document.body.appendChild(link)
link.click()
});
Upon browser download of the file, it automatically opens and I encounter an error message that reads:
We found a problem with some content
.xlsx
. Do you want us to try and recover as much as we can?