I'm trying to create an excel workbook on the server side that is send to the user when they visit a certain route (using express.js)
I'm using the module from https://github.com/riyadhalnur/excelbuilderjs-node
and I do have a large chunk of data in the
const result = Excel.createFile( workBook );
const workBookB64 = new Buffer( result, 'base64' );
res.setHeader( 'Content-Disposition', 'attachment; filename=' + fileName );
res.setHeader( 'Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64' );
res.end( workBookB64 );
I solved this on my own. It turns out that the issue was in how I was requesting the URL. The client side code was using a jQuery call:
$.get("/getReport") so the response was going back to this call, which had no callback handler. So to me it appeared as if it wasn't working.
The solution I used was to eliminate the JS, and just use an anchor tag, and call the URL directly.
Note: If you feel the need to down vote my answer too, at least leave a comment.