Creating password unprotected XLSX file from a password protected file


#1

Hello Support Team,
I am using below code and seeing that the password is still sticking with the newer XLSX file which I created from source password protected file.Sprint 4.zip (12.4 KB)

Password for the XLsX file inside the zip file is sdra

////-------------------------
loadOptionObj = new com.aspose.cells.LoadOptions();
loadOptionObj.setPassword(passwordKey);
println ( “handleNonPDFPasswordProtectedFile passwordKey was: " + passwordKey );
contentFileWithPath = attachmentObject.getFileEx(null, attachmentObject.getContentType(), 0, false);
println ( “handleNonPDFPasswordProtectedFile contentFileWithPath was: \n " + contentFileWithPath );
workBookObj = new com.aspose.cells.Workbook(contentFileWithPath, loadOptionObj) ;
//--------------- Does not work ???
workBookObj.unprotect(””);
// ***/
println ( “handleNonPDFPasswordProtectedFile loaded workbook with password " );
contentFileWithPath = contentFileWithPath +”_1.xlsx";
workBookObj.save( contentFileWithPath , com.aspose.cells.FileFormatType.XLSX ) ;

////------------------------


#2

@v11krams,

Please use this code creating un-protected Excel file.

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