diff --git a/NEW/src/JdeScoping.ExcelIO/Formatting/WorksheetProtector.cs b/NEW/src/JdeScoping.ExcelIO/Formatting/WorksheetProtector.cs index 378305c..f517151 100644 --- a/NEW/src/JdeScoping.ExcelIO/Formatting/WorksheetProtector.cs +++ b/NEW/src/JdeScoping.ExcelIO/Formatting/WorksheetProtector.cs @@ -18,6 +18,7 @@ public static class WorksheetProtector // Allow these operations protection.AllowElement(XLSheetProtectionElements.DeleteColumns); + protection.AllowElement(XLSheetProtectionElements.DeleteRows); protection.AllowElement(XLSheetProtectionElements.AutoFilter); protection.AllowElement(XLSheetProtectionElements.FormatCells); protection.AllowElement(XLSheetProtectionElements.FormatColumns); @@ -26,8 +27,6 @@ public static class WorksheetProtector protection.AllowElement(XLSheetProtectionElements.SelectUnlockedCells); protection.AllowElement(XLSheetProtectionElements.EditObjects); protection.AllowElement(XLSheetProtectionElements.Sort); - - // Note: DeleteRows is NOT allowed (not in AllowElement call) } /// diff --git a/NEW/tests/JdeScoping.ExcelIO.Tests/WorksheetProtectorTests.cs b/NEW/tests/JdeScoping.ExcelIO.Tests/WorksheetProtectorTests.cs index 38a646d..af41d38 100644 --- a/NEW/tests/JdeScoping.ExcelIO.Tests/WorksheetProtectorTests.cs +++ b/NEW/tests/JdeScoping.ExcelIO.Tests/WorksheetProtectorTests.cs @@ -28,6 +28,7 @@ public class WorksheetProtectorTests // Check that specified operations are allowed worksheet.Protection.AllowedElements.HasFlag(XLSheetProtectionElements.DeleteColumns).ShouldBeTrue(); + worksheet.Protection.AllowedElements.HasFlag(XLSheetProtectionElements.DeleteRows).ShouldBeTrue(); worksheet.Protection.AllowedElements.HasFlag(XLSheetProtectionElements.AutoFilter).ShouldBeTrue(); worksheet.Protection.AllowedElements.HasFlag(XLSheetProtectionElements.FormatCells).ShouldBeTrue(); worksheet.Protection.AllowedElements.HasFlag(XLSheetProtectionElements.FormatColumns).ShouldBeTrue(); @@ -39,15 +40,15 @@ public class WorksheetProtectorTests } [Fact] - public void ApplyProtection_DoesNotAllowDeleteRows() + public void ApplyProtection_AllowsDeleteRows() { using var workbook = new XLWorkbook(); var worksheet = workbook.Worksheets.Add("Test"); WorksheetProtector.ApplyProtection(worksheet, "TestPassword"); - // DeleteRows should NOT be allowed - worksheet.Protection.AllowedElements.HasFlag(XLSheetProtectionElements.DeleteRows).ShouldBeFalse(); + // DeleteRows should be allowed + worksheet.Protection.AllowedElements.HasFlag(XLSheetProtectionElements.DeleteRows).ShouldBeTrue(); } [Fact]