This sets the workbook so that it can be opened in read-only mode with the option to open in read-write mode, if the user supplies a matching password when opening the spreadsheet.

 public System.String PasswordToModify{ set; }
Public WriteOnly Property PasswordToModify() As String
wb.PasswordToModify = "MyPassword";
wb.PasswordToModify = "MyPassword"