Created Excel spreadsheet not downloading

504 Views Asked by At

I have created an Excel workbook using the excel4node library.

var workbook = new excel.Workbook();
var worksheet = workbook.addWorksheet('Sheet 1');
worksheet.cell(1,1).string('Component');
worksheet.cell(1,2).string('Part Name');
worksheet.cell(1,3).string('Value');

I have filled a bunch more cells but I'll keep it short and sweet here as it's not relevant to the question!

I've saved the workbook to my local environment with:

workbook.write(productName + ".xlsx", res);

The name variable is taken from a database. How would I be able to get the user to download this spreadsheet?

If anybody has an idea as to why any help is much appreciated!

1

There are 1 best solutions below

1
OBN On

I was not familiar with excel4node, but just looked it up. Interesting!

To better answer your question I think it may help to understand what you are trying to achieve. Are you testing the library and just creating a file locally, or trying to serve a workbook from a bucket (S3) or server?

If all is done locally, you say:

I've saved the workbook to my local environment with:

workbook.write(productName + ".xlsx");

Can you open this file with Excel the old fashioned way - clicking on it? If so, excel4node is doing its job and you can investigate the S3 serving process.