Vue + element ui cannot open Excel after downloading it

byte Stream

element ui

download

excel

We now have a requirement: upload a file at the front end, return a new byte stream to the front end under file processing at the back end, and then download it directly.
question: an error is displayed after downloading Excel. Does anyone know how to solve this problem, or where is the setting wrong? Thank you very much!

Excel 2007 template is used in the back end, and Excel 2007 is also used when downloading and opening the front end

PS: cannot be downloaded by returning url download for the time being due to system limitations.

May.22,2021

suspects that the excel generated by the backend will not open itself.
it is recommended that the backend do not return the stream to the front end, just generate the excel file and put it in a temporary directory, and open it to see if the generated excel can be opened.
if it can be opened, the problem occurs when the transmission and the browser receives the stream to generate the excel file; if it cannot be opened, there is something wrong with the excel you generated.


this problem is that there is a problem with the excel file generated by the backend.
it is recommended that the backend check the problem


. The original Blob object is to be built with Object.data, which was written incorrectly before.
the correct code should be:
let url = window.URL.createObjectURL (new Blob ([res.data])

Menu