Working with workbook cell protection and hiding using Aspose.Cells for .NET in C#

Cell protection and cell hiding is not working correctly. I entered “=a1” in cell b1, then right clicked cell b1 and chose format cells. Then I chose the protection tab and checked locked and hidden. It seems that lock and hidden are not functioning. The checkboxes for lock and hidden are not functioning. I was still able to change the formula and view the formula in this cell.

Hi Curt,

Thank you for contacting support.

It would be of great help in understanding your presented scenario if you could provide the code snippet used to create/protect the spreadsheet along with any template file for our review. Moreover, if you are using any older version of the API, I would request you to please give the latest version of Aspose.Cells for .NET (Latest Version) a try at your end, and see if you still can reproduce the issue.

I attached the aspose file and an example excel file. If you load the file into aspose and then right-click some of the cells with values, then choose format cells, protection and check on locked and hidden, it does not seem to lock or hide the formulas/values. Thank you.

Hi Curt,

Thank you for providing the sample spreadsheet.

By looking at your provided archive, it seems that you are probably using the Aspose.Cells.GridDesktop in your application, and your inquiry is in same reference. I would suggest you to always mention the component in the title of the thread or at least in the problem description so we could quickly move forward to evaluate your presented scenario.

Regarding your inquiry about Locked and Hidden Cells, I was able to reproduce the problem on my end while using the latest version of Aspose.Cells.GridDesktop 5.0.1.2000. A ticket (CELLSNET-42317) has been logged in our bug tracking system to look further into this matter. Please spare us little time to properly analyze the problem cause, and to provide a fix (if applicable). In the meanwhile, we will keep you posted with updates in this regard.

Hi Curt,

We have evaluated your presented scenario further, and we have concluded that Aspose.Cells.GridDesktop behaves exactly as MS Excel does. Please note, in MS Excel if you wish to protect or hide a cell you have to first set the protection for the underlying worksheet, otherwise protection does not work. You may confirm this on your end as well.

If you wish to protect worksheet you can use the Worksheet.Protected property. This will protect all the cells in the worksheet. In case you wish to protect only a few cells then please use the Worksheet.SetProtected method that accepts an object of Aspose.Cells.GridDesktop.CellRange for first parameter and a boolean as second parameter.

Sample code is as follow,


gridDesktop.Worksheets[0].SetProtected(new Aspose.Cells.GridDesktop.CellRange(“A1”, “A1”), true);

The issues you have found earlier (filed as CELLSNET-30020) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.