-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
When setting a column or row level Protection lock, the resulting .xlsx file still has those columns/cells editable. It is possible to lock the entire worksheet, but not individual cells.
import * as Excel from 'exceljs';
import * as fs from 'fs';
const stream = fs.createWriteStream(
`${FilePath}`,
{
flags: 'a',
}
);
const DefaultColumns = [
'Col1',
'Col2',
'Col3',
'Col4',
'Col5',
];
const placeHolders = new Array(DefaultColumns.length);
const workbook = new Excel.Workbook();
workbook.created = new Date();
workbook.modified = new Date();
const sheet = workbook.addWorksheet('sheet 1', {
//Also not sure what this is supposed to show
//No difference if datavalidation condition is failed
pageSetup: { errors: 'dash' },
});
const headerRow = sheet.addRow(DefaultColumns);
headerRow.eachCell((cell, rowNum) => {
//@ts-ignore Typing is wrong
cell.note = `This is ${rowNum}`;
//Doesn't do anything
cell.protection = { locked: true };
});
//Also doesn't do anything
headerRow.protection = { locked: true };
headerRow.commit();
await workbook.xlsx.write(res);
alessandro308, mcmule, ittichoatsoftthai, favasconcelos and Eseoghene94
Metadata
Metadata
Assignees
Labels
No labels