private void OpenFile(string fileName) { Text = "Spreadsheet Viewer - " + fileName; Spreadsheet xls = new Spreadsheet(); xls.RegistrationName = "demo"; xls.RegistrationKey = "demo"; try { xls.LoadFromFile(fileName); } catch (SpreadsheetProtectionPasswordRequired) { PasswordDialog passwordDialog = new PasswordDialog(); if (passwordDialog.ShowDialog(this) == DialogResult.OK) { xls.LoadFromFile(fileName, CacheType.Memory, ",", Encoding.Default, passwordDialog.Password); } else { return; } } lblStub.Visible = false; if (_spreadsheetControl == null) { _spreadsheetControl = new SpreadsheetControl(); _spreadsheetControl.Dock = DockStyle.Fill; Controls.Add(_spreadsheetControl); _spreadsheetControl.BringToFront(); _spreadsheetControl.Focus(); } Cursor = Cursors.WaitCursor; try { _spreadsheetControl.Spreadsheet = xls; } catch (Exception e) { MessageBox.Show(e.ToString()); } finally { Cursor = Cursors.Default; } }