Aspose Cells java code to remove password for an Excel ".xlsx" file

I have a “.xlsx” file that is protected by password. I need to remove the password for the file so that next time i double click on the file , it should not prompt me to enter password.
Please provide me sample java code to remove password for an Excel “.xlsx” file

@shashimn,

If you need to clear the password for an encrypted file, you may try to use Workbook.getSettings().setPassword(null). See the sample code for your reference. Aspose.Cells will first read the password protected file (using some password) and then clear the encryption to re-save the file:
e.g
Sample code:

try {
    com.aspose.cells.LoadOptions loadOptions = new com.aspose.cells.LoadOptions(FileFormatType.XLSX);
    loadOptions.setPassword("sdra");
    Workbook workbook = new Workbook("Book1.xlsx", loadOptions);
    workbook.getSettings().setPassword(null);
    workbook.save("Output.xlsx", FileFormatType.XLSX);
} catch (Exception e)
{
        System.out.println(e);
}

Hope, this helps a bit.

Hi,
Above sample code is not working for me for a password protected xlsx file which we forgot. Any help will be appreciatted.

Getting folliwing error:

com.aspose.cells.CellsException: Invalid password.
at com.aspose.cells.zvm.b(Unknown Source)
at com.aspose.cells.zjt.a(Unknown Source)
at com.aspose.cells.zjt.a(Unknown Source)
at com.aspose.cells.zjt.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)

@abhishekbshankar
Aspose.Cells only support opening the protected file with correct password.
If you forgot the password, you can try some possible passwords to open the file with Aspose.Cells.
But password verification is time-consuming.

Thanks Simon for your reply. However, we tried all posible password we can think off.

@abhishekbshankar,
If there is no correct password. Aspose.Cells cannot parse the file. Sorry for the inconvenience.

No issue. Thanks for your prompt reply.

@abhishekbshankar,
You are welcome.