Check Password to modify using Aspose.Cells
You can assign a Password to open and a Password to modify while creating your workbooks in Microsoft Excel. Please see this screenshot which shows the interface Microsoft Excel provides to specify these passwords.
Sometimes, you need to check if the given password matches with the Password to modify programmatically. Aspose.Cells provides workbook.getSettings().getWriteProtection().validatePassword() method which you can use to check if the given password to modify is correct or not.
Java code to check Password to modify using Aspose.Cells
The following sample codes load the source Excel file. It has a password to open as 1234 and password to modify as 5678. The code first checks if 567 is correct password to modify and it returns false and then it checks if 5678 is password to modify and it returns true.
Console Output generated by the Java code
Here is the Console Output of the above sample code after loading the source Excel file.
Is 567 correct Password to modify: false Is 5678 correct Password to modify: true