how to make a value in an excel cell read only using c#?
-
hey ppl, am developing an excel com add-in using c# and displaying certain data over excel sheets. How can i make a cell or a range of cells or some arbitrary cells "read-only" using c# code?!
-
hey ppl, am developing an excel com add-in using c# and displaying certain data over excel sheets. How can i make a cell or a range of cells or some arbitrary cells "read-only" using c# code?!
There is no "ReadOnly" attribute for cells or worksheets. You have to do this the exact same way you would if youwere to do it in Excel itself. Turn on the "Locked" property of the cell, then call the method to protect the worksheet to turn on all the protection. I don't the exact code or classes/methods to use since I don't normally do Office interop.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
There is no "ReadOnly" attribute for cells or worksheets. You have to do this the exact same way you would if youwere to do it in Excel itself. Turn on the "Locked" property of the cell, then call the method to protect the worksheet to turn on all the protection. I don't the exact code or classes/methods to use since I don't normally do Office interop.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008Erm, i know this process, but was not finding a way to protect my active sheet. It would be gr8 to get the exact code to do so. Thanks.
-
Erm, i know this process, but was not finding a way to protect my active sheet. It would be gr8 to get the exact code to do so. Thanks.
A little Googling found this[^].
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
A little Googling found this[^].
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008I did try it before but, I want the remaining cells to remain unlocked!!where as this is protecting my entire sheet. I want for example, only my active cell to be made readonly. what has to be done then?
-
I did try it before but, I want the remaining cells to remain unlocked!!where as this is protecting my entire sheet. I want for example, only my active cell to be made readonly. what has to be done then?
All cells, by default, have Protection turned on. You have to specifically unprotect the cells you went to remain active when the sheet protection is turned on.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008