Protect worksheet - prevent copy/paste comments, formatting

Hello -

I’d like to protect a worksheet such that specific cells are writeable, but the user cannot copy/paste comments into those cells or change the formatting.

For every cell that I want the user to be able to write to, I am calling Cell.Unlock();
Then I call Worksheet.Protect(ProtectionType.All, “my password” null);

Overall it prevents editing most of the worksheet.

However, I am able to copy/paste from a cell in a different workbook/worksheet into the unlocked cells. When I paste, the formatting is overwritten and the comment is overwritten.

Is there any way to unlock a cell so that it can only be written to, but the formatting and the comments cannot be overwritten on that cell?

Side note - these example seem to all be empty (no .cs files):

@cometrics

Thanks for using Aspose APIs.

Please manually create your Excel file using Microsoft Excel 2003 or 2016 etc. and provide it to us. We will look into your provided Excel file and create a replica of it using Aspose.Cells and provide you a sample code that will fulfill your requirements.


For .cs files, look into CSharp folder not Data folder. So the correct link is this.

https://github.com/aspose-cells/Aspose.Cells-for-.NET/tree/master/Examples/CSharp/Worksheets/Security

I’m actually not sure if Excel supports this feature or not. I’ve posted to SuperUser to find out: microsoft excel - How to protect worksheet with writeable cells that retain formatting and comments - Super User

I’ll respond when I have an answer.

@cometrics

Thanks for your cooperation in this regard. Meanwhile, you can also check these articles that might be useful for you.