2

I'm using Express and ExcelJs to create a CSV that users can download. I'm sending the users an email using Sendgrid and putting the params in a link in the email that dynamically generates the CSV. Everything works locally, and on macs. But on my windows computer, what happens is when I click the link, a new tab temporarily opens, then closes. Here is the ExcelJs code that being returned from the script that actually creates the CSV (with all the CSV logic excluded):

return await workbook.xlsx.writeBuffer()

then this is the Express code that sends the CSV to the user in the response:

const buffer = await generateWorkbook(csvData, styleInfo)

res.status(200)
  .set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
  .attachment("csv.xlsx")
  .send(buffer)

Any thoughts why this doesn't work across all platforms? Follow up question, if it isn't possible for this approach to work across all platforms, would a more consistent approach be to create a new tab, send the user to a page in our domain, then initiate the download from there and close the new tab?

thesofaking
  • 45
  • 1
  • 7

0 Answers0