{"record":{"id":"dd20c752946bf9fc","repo":"pentaho/pentaho-kettle","slug":"e-getlocalizedmessage","errorCode":null,"errorMessage":"e.getLocalizedMessage()","messagePattern":"e\\.getLocalizedMessage\\(\\)","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/excel/core/src/main/java/org/pentaho/di/trans/steps/excelinput/poi/PoiWorkbook.java","lineNumber":87,"sourceCode":"        } catch ( Exception ofe ) {\n          try {\n            opcpkg = OPCPackage.open( excelFile );\n            workbook = XSSFWorkbookFactory.createWorkbook( opcpkg );\n          } catch ( Exception ex ) {\n            workbook = org.apache.poi.ss.usermodel.WorkbookFactory.create( excelFile, password );\n          }\n        }\n      } else {\n          //default value for maximum allowed size we are maintaining 150MB  150 * 1024 * 1024\n          int maxSize = Const.toInt( EnvUtil.getSystemProperty( Const.POI_BYTE_ARRAY_MAX_SIZE ), 157286400 );\n          // Increase the maximum allowed size\n          org.apache.poi.util.IOUtils.setByteArrayMaxOverride( maxSize );\n          internalIS = KettleVFS.getInstance( bowl ).getInputStream( filename );\n          workbook = org.apache.poi.ss.usermodel.WorkbookFactory.create( internalIS, password );\n      }\n    } catch ( EncryptedDocumentException e ) {\n      log.logError( \"Unable to open spreadsheet.  If the spreadsheet is password protected please double check the password is correct.\" );\n      throw new KettleException( e.getLocalizedMessage() );\n    } catch ( Exception e ) {\n      throw new KettleException( e );\n    }\n  }\n\n  public PoiWorkbook( InputStream inputStream, String encoding ) throws KettleException {\n    this.encoding = encoding;\n\n    try {\n      workbook = org.apache.poi.ss.usermodel.WorkbookFactory.create( inputStream );\n    } catch ( Exception e ) {\n      throw new KettleException( e );\n    }\n  }\n\n  public void close() {\n    try {\n      if ( internalIS != null ) {","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/excel/core/src/main/java/org/pentaho/di/trans/steps/excelinput/poi/PoiWorkbook.java#L69-L105","documentation":"In PoiWorkbook's filename constructor, an EncryptedDocumentException from WorkbookFactory.create is caught, logged with a hint about password-protected spreadsheets, and rethrown as a KettleException carrying e.getLocalizedMessage(). It specifically signals that the workbook is encrypted/password-protected and POI cannot decrypt it with the supplied credentials.","triggerScenarios":"Opening a password-protected (encrypted) .xlsx/.xls via new PoiWorkbook(bowl, filename, password, encoding, log) where the password is missing, wrong, or the encryption scheme is unsupported by POI.","commonSituations":"Users saving workbooks with 'Encrypt with Password' and forgetting to supply it in the Excel Input step; enterprise files with legacy encryption POI cannot handle; mistyped password stored in the transformation metadata.","solutions":["Supply the correct password to the Excel Input step / PoiWorkbook constructor.","Remove workbook protection by re-saving the file without a password in Excel, then re-run.","If the password is unknown, obtain it from the file owner before processing.","Check the cause message for unsupported encryption; if POI can't handle the scheme, decrypt externally (e.g. with msoffcrypto-tool) and feed the decrypted stream."],"exampleFix":"// before\nWorkbook wb = new PoiWorkbook(bowl, filename, null, encoding, log); // fails on encrypted file\n// after\nWorkbook wb = new PoiWorkbook(bowl, filename, \"correctPassword\", encoding, log);\n// or preprocess:\n// msoffcrypto-tool -p password in.xlsx out_decrypted.xlsx","handlingStrategy":"try-catch","validationCode":"// Detect encryption up front\ntry (org.apache.poi.poifs.filesystem.POIFSFileSystem fs = new org.apache.poi.poifs.filesystem.POIFSFileSystem(new File(filename), true)) {\n  boolean encrypted = fs.getRoot().hasEntry(\"EncryptionInfo\");\n  if (encrypted && (password == null || password.isEmpty())) throw new KettleException(\"Workbook is encrypted; provide a password\");\n}","typeGuard":null,"tryCatchPattern":"try { wb = new PoiWorkbook(bowl, filename, password, encoding, log); } catch (KettleException e) { if (e.getMessage() != null && e.getMessage().toLowerCase().contains(\"encrypt\")) { promptForPassword(); } else { throw e; } }","preventionTips":["Store and verify the workbook password in transformation metadata","Detect 'EncryptionInfo' in the OLE2 header before opening","Ask users to remove workbook encryption before automated processing","Use msoffcrypto-tool to decrypt unsupported schemes upstream"],"tags":["poi","workbook-open","encrypted-document","password"],"backgroundTag":"authentication-required","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}