Sorry for the delay - I missed this post.
Passwords in Excel's worksheet and workbook protection are stored with their hash value in the xlsx file. Since I don't know the hashing algorithm I cannot calculate the hash from the password that you select. I am not very much motivated to search the web for information on this feature. Unless somebody submits a patch for hashing a password this feature will remain incomplete in fpspreadsheet.
Thanks for your reply.
I have work around (to prevent casual user from unprotecting worksheet) as follows:
1. ask the user for password whenever the user try to unprotected a worksheet;
2. the program would unprotect the worksheet only if :-
Worksheet.CryptoInfo.PasswordHash = Format('%.4x', [ExcelPasswordHash( <password keyed in by user>)]))
The problem with this work around is: anyone who knowns programming can just call worksheet.Protect(false) to unprotect the worksheet.
Is possible to have the similar code/check (like 2 above) in the worksheet.protect method ?