Open dev-aes opened 1 year ago
I have the same problem.
@dev-aes You can refer to my code snippet. Here I save the file to storage_path and then send it to the client. PHP code
$fastexcel = new FastExcel($collection);
$fastexcel->export(storage_path("temp_file.csv"));
return response()->download(storage_path("temp_file.csv"), "temp_file.csv")->deleteFileAfterSend(true);
Js code
axios({
url: 'export-csv',
method: 'post',
responseType: 'blob',
data: {},
}).then((response) => {
let url = window.URL.createObjectURL(new Blob([response.data]));
let link = document.createElement('a');
link.href = url;
link.setAttribute('download', "temp_file.csv");
document.body.appendChild(link);
link.click();
});
is there any solution to this problem? I don't see any guides about downloading sheet files thru ajax request ( Axios)