SpreadsheetControl.EncryptedFilePasswordRequest Event
Raises when the WorkbookImportOptions.Password property is not set or contains a wrong password.
Namespace: DevExpress.XtraSpreadsheet
Assembly: DevExpress.XtraSpreadsheet.v18.2.dll
Declaration
Event Data
The EncryptedFilePasswordRequest event's data class is EncryptedFilePasswordRequestEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Cancel | Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs. |
DocumentName | Gets the name of the encrypted document. |
Password | Gets or sets the password used to encrypt the document. |
Remarks
The EncryptedFilePasswordRequest event allows prompting an end-user for a password or specify it in code using the EncryptedFilePasswordRequestEventArgs.Password property.
If the event is not handled (the e.Handled is not set to true), the Password Dialog appears.
Example
The code snippet handles the SpreadsheetControl.EncryptedFilePasswordRequest
event to specify a password for loading a password encrypted file.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-load-and-save-a-password-encrypted-file-t464814
private void SpreadsheetControl1_EncryptedFilePasswordRequest(object sender, EncryptedFilePasswordRequestEventArgs e) {
if (e.DocumentName == "encrypted_test.xlsx") e.Password = "test";
if (e.DocumentName == "corrupted.xlsx") e.Password = "000";
e.Handled = true;
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the EncryptedFilePasswordRequest event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.