Hi GaniTPT,
What did you use to access worksheets?
I made a test by using EPPlus and it worked fine.
Here is a test code you can refer to:
ExcelPackage.LicenseContext = LicenseContext.Commercial;
using (var p = new ExcelPackage(new FileInfo(@"C:\Users\Desktop\Test.xlsx")))
{
var ws = p.Workbook.Worksheets["Sheet1"];
// Filtering, sorting, protection
ws.Cells[7, 1, 10, 5].AutoFilter = true;
ws.View.FreezePanes(7, 1);
ws.ProtectedRanges.Add("FilteredCells", new ExcelAddress(7, 1, 10, 5));
// Worksheet protection
ws.Protection.AllowSort = true;
ws.Protection.IsProtected = true;
ws.Protection.AllowAutoFilter = true;
ws.Protection.SetPassword("hunter2");
p.SaveAs(new FileInfo(@"C:\Users\Desktop\Test1.xlsx"));
}
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.