This example demonstrates the technique required to open a password protected .xls file prompting user for a correct password.
When the Spreadsheet control attempts to open a password protected .xls file and the Password property is not set, the control raises the InvalidFormatException event with the SpreadsheetDecryptionException exception in event arguments. If this event is not handled, the control cancels loading without any alert.
The method is to subscribe to the InvalidFormatException event, prompt the user for a password, specify the password and call the SpreadsheetControl.LoadDocument.
Note that this technique can be used for password-protected .xls documents created with Microsoft Excel versions up to 2010. The test file password123.xls is included in the project. Run the application and open this file using CTRL-O or the Open File... command. When prompted for a password, type in 123.
When the Spreadsheet control attempts to open a password protected .xls file and the Password property is not set, the control raises the InvalidFormatException event with the SpreadsheetDecryptionException exception in event arguments. If this event is not handled, the control cancels loading without any alert.
The method is to subscribe to the InvalidFormatException event, prompt the user for a password, specify the password and call the SpreadsheetControl.LoadDocument.
Note that this technique can be used for password-protected .xls documents created with Microsoft Excel versions up to 2010. The test file password123.xls is included in the project. Run the application and open this file using CTRL-O or the Open File... command. When prompted for a password, type in 123.