Axios download excel file cannot be opened

Project requirements, download reports of excel file type, post request, and the backend returns to me in the form of file stream. I first judge the type of response header, such as excel file, and dynamically create an a tag to get the file. The code is as follows!

a
post

the result is that the file is downloaded, but it can"t be opened. I don"t know why

Mar.18,2021

Let me tell you a problem I encountered the day before yesterday
scenario:

header('Content-type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="export.csv"');
$header = array('ID', '...', '...');

//echo content

...
At that time, the scene in the backend is like this. The header of the output has a capital "ID". As a result, downloading and opening the file under windows always prompts you to report an error, and then checks the content all the time. A little bit of debugging will find this problem. Just modify the "ID". So I'll give you some ideas.


and communicate with the background to provide a download connection through streaming. Click download

Menu