We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Excel protection where password contains dollar symbol

We are using setPassword in Java to protect an Excel spreadsheet. This is working fine unless the password contains a dollar symbol in the middle of the text (e.g. test$test). It is even working fine if the password has a dollar at the end of the text (e.g. test$).

This leads us to suspect that $t is being treated as a special character, and is not being passed “as-is” to MS Excel. Have tried escaping the dollar symbol within the password (e.g. test\$test) in case it was a Java issue, but this has not made any difference. Indeed, changing test$ to test\$ just resulted in MS Excel requiring the additional slash character to be entered in the password.

Can you confirm whether this issue can be recreated, and whether there is a simple solution that will allow us to resolve it?

Thanks,
Kevan

@kevanc,

Thanks for your query.

I have tried to reproduce this issue but unable to observe it using following sample code. The password is set fine and file is opened successfully in Excel using same password. Could you please give it a try using latest version Aspose.Cells for Java 19.1.x and provide your feedback? If your issue is not resolved, please share the complete sample code and input/output files for our analysis.

// Instantiate a Workbook object by excel file path
Workbook workbook = new Workbook("Book1.xlsx");

// Password protect the file.
workbook.getSettings().setPassword("test$test");

// Specify XOR encrption type.
workbook.setEncryptionOptions(EncryptionType.XOR, 40);

// Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic
// Provider).
workbook.setEncryptionOptions(EncryptionType.STRONG_CRYPTOGRAPHIC_PROVIDER, 128);

// Save the excel file.
workbook.save("EncryptingFiles_out.xls");

Book1.zip (11.5 KB)