windowsforms-devexpress-dot-xtraspreadsheet-dot-spreadsheetcontrol-f48fac3c.md
Occurs when the encrypted file does not pass data integrity verification.
Namespace : DevExpress.XtraSpreadsheet
Assembly : DevExpress.XtraSpreadsheet.v25.2.dll
NuGet Package : DevExpress.Win.Spreadsheet
public event EncryptedFileIntegrityCheckFailedEventHandler EncryptedFileIntegrityCheckFailed
Public Event EncryptedFileIntegrityCheckFailed As EncryptedFileIntegrityCheckFailedEventHandler
The EncryptedFileIntegrityCheckFailed event's data class is EncryptedFileIntegrityCheckFailedEventArgs. 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. |
SpreadsheetControl uses the Hash-based message authentication code (HMAC) to verify the document data integrity. If the document did not pass the code verification, the EncryptedFileIntegrityCheckFailed event is raised and the following message window is shown.
Note
The HMAC is calculated only for certain encryption types. When you save a password encrypted workbook, set the EncryptionOptions.Type to the EncryptionType.Strong to calculate HMAC.
This code snippet handles the SpreadsheetControl.EncryptedFileIntegrityCheckFailed event to perform certain actions when loading a corrupted password encrypted file.
private void SpreadsheetControl1_EncryptedFileIntegrityCheckFailed(object sender, EncryptedFileIntegrityCheckFailedEventArgs e) {
e.Cancel = true;
e.Handled = true;
MessageBox.Show("File is corrupted. Cannot load.","Warning");
}
Private Sub SpreadsheetControl1_EncryptedFileIntegrityCheckFailed(ByVal sender As Object, ByVal e As EncryptedFileIntegrityCheckFailedEventArgs)
e.Cancel = True
e.Handled = True
MessageBox.Show("File is corrupted. Cannot load.","Warning")
End Sub
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the EncryptedFileIntegrityCheckFailed 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.
winforms-spreadsheet-load-and-save-a-password-encrypted-files/CS/EncryptionExample/Form1.cs#L21
// The EncryptedFileIntegrityCheckFailed event allows you to perform custom actions when trying to load a corrupted file.
spreadsheetControl1.EncryptedFileIntegrityCheckFailed += SpreadsheetControl1_EncryptedFileIntegrityCheckFailed;
// If
winforms-spreadsheet-load-and-save-a-password-encrypted-files/VB/EncryptionExample/Form1.vb#L19
' The EncryptedFileIntegrityCheckFailed event allows you to perform custom actions when trying to load a corrupted file.
AddHandler spreadsheetControl1.EncryptedFileIntegrityCheckFailed, AddressOf SpreadsheetControl1_EncryptedFileIntegrityCheckFailed
' If
See Also