Aspose.Cells workbook unprotect worksheet not working even with correct password

I am using Aspose.Cells workbook and worksheet objects to protect with a password. Once the xlsx is created with this code, i am able to unprotect the workbook using the password. but the unprotect sheet doesnt work. i get error “The password you supplied is not correct. Verify that the CAPS LOCK key is off and be sure to use the correct capitalization.”.
i also tried it through code by using Unprotect but that doesnt work either.

I need this to support business requirements. Any help is appreciated. TIA

            var iWSCount = workbook.Worksheets.Count;

            for (int i = 0; i < iWSCount; i++)
            {
                Worksheet wk = workbook.Worksheets[i];
                wk.Protect(ProtectionType.All, "test", "");
            }

@ashsawant,
I have tried the following sample code but could not reproduce this issue. The worksheet can be unprotected using the same password without any error. You may please try this scenario using the latest version 21.10 and if the issue is not resolved, share your runnable sample console application for our testing.

Workbook workbook = new Workbook();
Worksheet wk = workbook.Worksheets[0];
wk.Protect(ProtectionType.All, "test", "");
workbook.Save("Output.xlsx");

Is it possible for you to test using version 20.7? more testing would be needed on our end if we upgrade aspose.

Here is the code i tested which gives the exception “Invalid password for unprotecting the worksheet.” on the line of Unprotect

            var iWSCount = workbook.Worksheets.Count;

            for (int i = 0; i < iWSCount; i++)
            {
                Worksheet wk = workbook.Worksheets[i];
                wk.Protect(ProtectionType.All, "test", "");
            }

            workbook.Save(sFile);

            for (int i = 0; i < iWSCount; i++)
            {
                Worksheet wk = workbook.Worksheets[i];
                wk.Unprotect("test");
            }

@ashsawant,
Please note that we do not rectify the issues in the previous versions. I have tested your sample code using the latest version Aspose.Cells for .NET 21.10 and also with previous version 20.7 but could not observe any issue. The following code works fine without any error with versions 20.7 and 21.10. Please give it a try and ensure that you are using the correct version in your testing. You may display the product version number as demonstrated in the following sample code to verify it.

using System;
using Aspose.Cells;

namespace TestDotNet
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Console.WriteLine(CellsHelper.GetVersion());

            Workbook workbook = new Workbook();
            var iWSCount = workbook.Worksheets.Count;

            for (int i = 0; i < iWSCount; i++)
            {
                Worksheet wk = workbook.Worksheets[i];
                wk.Protect(ProtectionType.All, "test", "");
            }

            workbook.Save("output.xlsx");

            for (int i = 0; i < iWSCount; i++)
            {
                Worksheet wk = workbook.Worksheets[i];
                wk.Unprotect("test");
            }
            Console.WriteLine("Completed successfully");
        }
    }
}

Following is the output:

20.7
Completed successfully

If the issue is not resolved, share your complete solution along with the environment details for our referencce.