I am looking for an npm package or any other workaround to be able to generate xlsx file with password. I do not want to protect the sheet(s) or cell(s)... I want the whole file password protected. I found few quite good packages (excel4node, exceljs..) but none of them able to do what I need.
Any suggestion appreciated
You can use the xlsx-populate module to do this, for example:
const XlsxPopulate = require('xlsx-populate');
XlsxPopulate.fromBlankAsync().then(workbook => {
workbook.sheet("Sheet1").cell("A1").value("Some sample text");
return workbook.toFileAsync("./test.xlsx", { password: "$secret_password" });
});
The resulting workbook will require the user to enter the correct password if they wish to access it.