WriteProtection.ValidatePassword

WriteProtection.ValidatePassword method

Returns true if the specified password is the same as the write-protection password the file was protected with.

public bool ValidatePassword(string password)
ParameterTypeDescription
passwordStringThe specified password.

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class WriteProtectionMethodValidatePasswordWithStringDemo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            
            // Set write protection password
            workbook.Settings.WriteProtection.Password = "1234";
            
            // Validate password
            Console.WriteLine("Password '1234' is valid: " + 
                workbook.Settings.WriteProtection.ValidatePassword("1234"));
            Console.WriteLine("Password 'wrong' is valid: " + 
                workbook.Settings.WriteProtection.ValidatePassword("wrong"));
        }
    }
}

See Also