I am creating an Excel file using the XlsxPopulate library. This file contains two sheets, and I want to protect second sheet.
"xlsx-populate": "^1.21.0",
"exceljs": "^4.4.0",
const workbook = await XlsxPopulate.fromBlankAsync();
const sheet = workbook.sheet(0);
const sheet2 = workbook.addSheet('WEB');
const excelBuffer = await workbook.outputAsync();
const workbookJS = new ExcelJS.Workbook();
await workbookJS.xlsx.load(excelBuffer);
const workSheet2 = workbookJS.getWorksheet(2);
// Protecting the second sheet
await workSheet2.protect('P2', {});
const modifiedBuffer = await workbookJS.xlsx.writeBuffer();
return modifiedBuffer as Buffer;