Protected Worksheet and Worksheet.Protection.IsFormattingColumnsAllowed = true;

In order to protect some content on the sheets I use Worksheet protection.

Whenever I enable worksheet protection the worksheet doesn't allow column resizing when I alter it in an Excel client.

Their exists an option Worksheet.Protection.IsFormattingColumnsAllowed and I do set it to true, but it seems that it has no effect.

Is their a certain interaction with other Protection properties?

When enabling Worksheet protection I use ProtectionType.Contents. as parameter.

Please check

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;

protection.IsFormattingColumnsAllowed = true;
excel.Save("c:\\book1.xls", FileFormatType.ExcelXP);

Laurence wrote:

Please check `http://www.aspose.com/wiki/default.aspx/Aspose.Excel/ProtectingWorksheet.html`.

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;

protection.IsFormattingColumnsAllowed = true;
excel.Save("c:\\book1.xls", FileFormatType.ExcelXP);

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

Edit : I'm using Excel 2003

1. This piece of code works in my machine. Maybe your Aspose.Excel is not the latest one. Please try this attached fix.

2. You can access it directly:

Excel excel = new Excel();
excel.Worksheets[0].Protection.IsFormattingColumnsAllowed = true;
excel.Save("c:\\book1.xls", FileFormatType.ExcelXP);

Ok

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.

Thank you for your help.