Reputation: 27
I created an Electron app which generates an Excel file and I want to send it to the client. The file is generated properly and the dialog is shown to the client, but the file is not saved on the location selected by the user. Here is my code which send the file to the client:
var fs = require('fs');
/* WB is my Excel file generated previously with the module excel4node */
var wb = ....
await wb.write('tmp.xlsx', () => {
var filename = path.basename('tmp.xlsx');
res.setHeader('Content-Disposition', 'attachment; filename=' + filename);
res.setHeader('Content-type', 'application/vnd.ms-excel');
var filestream = fs.createReadStream('tmp.xlsx');
filestream.pipe(res);
});
if I invoke the action outside from the electron app (direct in the browser), the file is saved properly on the disk
Thanks for your help
Upvotes: 0
Views: 74