So I am reading lots of data from my mongoose database and writing them into XLSX of SheetJS. I want to return a downloadable file from my controller. I got an object below, question is how can i return this object for download?
const wbout = XLSX.write(wb, { bookType: 'xlsx', type: 'buffer' });
I done it with code below. Header prompts a file download, type sets the correct type for file and you can send it with res.send()
res.header('Content-disposition', 'attachment; filename=anlikodullendirme.xlsx');
res.type('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
return res.send(buffer);