1

using excel4node

Is there any methed set some cells locked or other cells is not locked using the package, excel4node; I found sheetProtection can lock the Workbook, but I want to lock one cell or some cells. I've tried to find a method. I think locked cell missing in cell style settings

laminatefish
  • 5,197
  • 5
  • 38
  • 70
L.CH
  • 13
  • 5

2 Answers2

1

This is the workaround I use- it gives an error message when you try to edit a cell.

const lockCell = (worksheet, range) => {
  worksheet.addDataValidation({
    type: "textLength",
    error: "This cell is locked",
    operator: "equal",
    sqref: range,
    formulas: [""],
  });
};

eg, lockCell(worksheet,'B12');
n-a-t-e
  • 141
  • 5
0

No, currently this is not supported. See here

There isn't currently functionality to change the "locked" flag on a cell by cell basis. I can add that as an enhancement request.

laminatefish
  • 5,197
  • 5
  • 38
  • 70
  • https://stackoverflow.com/questions/53009804/excel4nodehow-to-achieved-add-datavalidationindriect please!!! – L.CH Nov 02 '18 at 12:31