Search code examples
c#asp.net-mvcexcelepplus

make Excel cells read-only using EPPLUS


I have following excel data out of which i wanna make first column and header row read-only.

CityMaster        POC       HeadCount
Mumbai          Prasad S       2
Delhi           Kishan T       5
Banglore        Shilpa S       7
Chennai         Prasad S       2

Second and third data should be editable.


Solution

  • I tried this and it worked:

    workSheet.Protection.IsProtected = true;
    
    workSheet.Cells[2, 3, pocDeatils.CityMaster.Rows.Count + 1, 4].Style.Locked = false;
    

    for more detail refer below link: https://epplus.codeplex.com/SourceControl/latest#SampleApp/Sample6.cs