officefileapi-devexpress-dot-spreadsheet-dot-workbook-a40c5e68.md
Fires when the supplied data could not be recognized as data in the assumed format for import.
You need a license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use this event in production code.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Docs.v25.2.dll
NuGet Package : DevExpress.Document.Processor
public event InvalidFormatExceptionEventHandler InvalidFormatException
Public Event InvalidFormatException As InvalidFormatExceptionEventHandler
The InvalidFormatException event's data class is SpreadsheetInvalidFormatExceptionEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Exception | Gets the exception which triggers the InvalidFormatException event. |
| SourceUri | Gets the source location for the document which triggers the InvalidFormatException event. |
If the data for import is in an incorrect format, the spreadsheet component silently cancels import if the InvalidFormatException is not handled. If you subscribe to the InvalidFormatException event, the event is fired when the component attempts to load incorrect data, so you can provide custom logic in this situation.
To throw an exception on loading an invalid document, set the WorkbookImportOptions.ThrowExceptionOnInvalidDocument property to true (import options are accessible via the Workbook.Options.Import notation).
The following code snippets (auto-collected from DevExpress Examples) contain references to the InvalidFormatException 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.
asp-net-web-forms-grid-upload-and-display-excel-file/CS/Solution/Default.aspx.cs#L23
Workbook book = new Workbook();
book.InvalidFormatException += book_InvalidFormatException;
book.LoadDocument(FilePath);
spreadsheet-document-api-encryption/VB/EncryptionExample/Program.vb#L18
AddHandler workbook.EncryptedFilePasswordCheckFailed, AddressOf Workbook_EncryptedFilePasswordCheckFailed
AddHandler workbook.InvalidFormatException, AddressOf Workbook_InvalidFormatException
Dim encryptionOptions As EncryptionSettings = New EncryptionSettings()
asp-net-web-forms-grid-upload-and-display-excel-file/VB/Solution/Default.aspx.vb#L29
Dim book As New Workbook()
AddHandler book.InvalidFormatException, AddressOf book_InvalidFormatException
book.LoadDocument(FilePath)
See Also