1

I don't want the user allowed to edit objects. The checkmark for "edit objects" should be unchecked.

enter image description here

Here is my code:

        using (var workbook = new XLWorkbook(download))
        {
            foreach (var worksheet in workbook.Worksheets.Skip(4))
            {
                var protection = worksheet.Protect("password");
                protection.SelectLockedCells = false;
                protection.SelectUnlockedCells = false;
                protection.SetObjects(false);
            }

            workbook.SaveAs(download, true, true);
            download.Position = 0;
        }

I've also tried:

                protection.Objects = false;
                protection.Objects = true;
                workbook.SaveAs(download, false);
                workbook.SaveAs(download, true);

Any idea? I think this might be a glitch.

MIKE
  • 1,039
  • 7
  • 24

1 Answers1

1

This is a bug in ClosedXML. It is fixed in this pull request: https://github.com/ClosedXML/ClosedXML/pull/1038

Francois Botha
  • 4,520
  • 1
  • 34
  • 46