worksheet.Protect(ProtectionType.Objects) does not work for XLS files

I found a bug in .NET version of method worksheet.Protect(ProtectionType.Objects) for XLS file. Protection is not activated for worksheet in any XLS file.

worksheet.Protect(ProtectionType.All) works fine for both XLS and XLSX.

worksheet.Protect(ProtectionType.Objects) works fine only for XLSX, but protection is not activated for XLS.

@gennadyz,

Thanks for providing us some details.

I did test your scenario/case a bit by protecting an XLS file via worksheet.Protect(ProtectionType.Objects) API and it works fine. Could you provide us sample code (runnable) or preferably a simple console demo application, zip the project (excluding Aspose.Cells assembly) and post us here to reproduce the issue, we will check it soon. Also attach your template Excel files, this will help us really to evaluate your issue precisely and to consequently figure it out soon.

Dear Amjad_Sahi,

I attached a test Console Application created in Visual Studio 2017 which reproduces the bug. I use Excel 2013 to open the problem XLS file.

XlsProtectionBug.zip (152.8 KB)

@gennadyz,

Thanks for the sample project with template file.

After an initial test, I am able to observe the issue as you mentioned by using your template file and sample code. I found that Worksheet.Protect(ProtectionType.Objects) does not work for XLS files, it works fine when we save to XLSX file format:
e.g
Sample code:

  using (var workbook = new Workbook("e:\\test2\\Test.xls")) 
            { 
                foreach (Worksheet sheet in workbook.Worksheets) 
                { 
                    sheet.Protect(ProtectionType.Objects); 
                } 

                workbook.Save("e:\\test2\\Test_protected1.xlsx", SaveFormat.Xlsx); //Success. Image and worksheet is protected. 
                workbook.Save("e:\\test2\\Test_protectedasdf2.xls", SaveFormat.Excel97To2003); //BUG. Image and worksheet is NOT protected. 
            }; 

I have logged a ticket with an id “CELLSNET-45977” for your issue. We will look into it soon.

Once we have an update on it, we will let you know here.

@gennadyz,

Please try our latest version/fix: Aspose.Cells for .NET v18.2.8:

Your issue “CELLSNET-45977” should be fixed in it.

Let us know your feedback.

The issues you have found earlier (filed as CELLSNET-45977) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi

The issues you have found earlier (filed as CELLSNET-45977) have been fixed in this update. Please also check the following article:* <a href="Install Aspose Cells through NuGet|Documentation