Skip to main content
All docs
V24.2
Row

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

WriteProtectionOptions.CheckPassword(String) Method

Checks whether the specified password is the same as the password used to write-protect a workbook.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v24.2.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

#Declaration

bool CheckPassword(
    string password
)

#Parameters

Name Type Description
password String

The password to check.

#Returns

Type Description
Boolean

true if the password is valid; otherwise, false.

#Remarks

The following example checks a given password and removes write-protection from a workbook if the password is valid:

using (Workbook workbook = new Workbook())
{
    workbook.LoadDocument("WriteProtectedDocument.xlsx");
    RemoveWriteProtection(workbook, "password");
}
// ...

private void RemoveWriteProtection(Workbook workbook, string password)
{
    var wpOptions = workbook.DocumentSettings.WriteProtection;
    if (wpOptions.IsPasswordProtected && wpOptions.CheckPassword(password))
        wpOptions.ClearPassword();
    else
    {
        Console.WriteLine("The file is not write-protected or the specified password is invalid!");
        Console.ReadKey();
    }
}
See Also