If you just want to protect worksheet, please use protect method. However, if you want to use more protection options, please use Protection class. And proteciton class only works in ExcelXP and Excel2003 format. Please try the following code:
Excel excel = new Excel(); Protection protection = excel.Worksheets[0].Protection;
If you just want to protect worksheet, please use protect method. However, if you want to use more protection options, please use Protection class. And proteciton class only works in ExcelXP and Excel2003 format. Please try the following code:
Excel excel = new Excel(); Protection protection = excel.Worksheets[0].Protection;
First of all, the piece of code written here above will, unless I'm wrong, never work. Protection isn't enabled by enabling that one property alone. I also tried enabling protection first and then setting the property and visa versa. Nothing works. Meaning: I can't change the column width when the document is protected and protection isn't enabled without calling ws.Protect().
I don't understand why you would create a separate Protection class where evn by not doing so the properties can be accessed directly. ws.Protection.IsFormattingColumnsAllowed = true
I found what my problem actualy was. I used FileFormatType.Default as save-type, which doesn't allow the functionality to work, even if you open the file in Excel XP/2003.