feat(excelio): allow DeleteRows on protected worksheets

Enable users to delete rows in protected Excel worksheets for better
data management flexibility.
This commit is contained in:
Joseph Doherty
2026-01-19 00:44:13 -05:00
parent 0c8657713b
commit 5a798b089b
2 changed files with 5 additions and 5 deletions
@@ -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]