pentaho/pentaho-kettle · error · KettleException

e.getLocalizedMessage()

Error message

e.getLocalizedMessage()

What it means

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.

Solutions

  1. Supply the correct password to the Excel Input step / PoiWorkbook constructor.
  2. Remove workbook protection by re-saving the file without a password in Excel, then re-run.
  3. If the password is unknown, obtain it from the file owner before processing.
  4. 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.

Example fix

// before
Workbook wb = new PoiWorkbook(bowl, filename, null, encoding, log); // fails on encrypted file
// after
Workbook wb = new PoiWorkbook(bowl, filename, "correctPassword", encoding, log);
// or preprocess:
// msoffcrypto-tool -p password in.xlsx out_decrypted.xlsx
Defensive patterns

Strategy: try-catch

Validate before calling

// Detect encryption up front
try (org.apache.poi.poifs.filesystem.POIFSFileSystem fs = new org.apache.poi.poifs.filesystem.POIFSFileSystem(new File(filename), true)) {
  boolean encrypted = fs.getRoot().hasEntry("EncryptionInfo");
  if (encrypted && (password == null || password.isEmpty())) throw new KettleException("Workbook is encrypted; provide a password");
}

Try / catch

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; } }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/dd20c752946bf9fc. Report an issue: GitHub.

Appendix: source

Thrown at plugins/excel/core/src/main/java/org/pentaho/di/trans/steps/excelinput/poi/PoiWorkbook.java:87

        } catch ( Exception ofe ) {
          try {
            opcpkg = OPCPackage.open( excelFile );
            workbook = XSSFWorkbookFactory.createWorkbook( opcpkg );
          } catch ( Exception ex ) {
            workbook = org.apache.poi.ss.usermodel.WorkbookFactory.create( excelFile, password );
          }
        }
      } else {
          //default value for maximum allowed size we are maintaining 150MB  150 * 1024 * 1024
          int maxSize = Const.toInt( EnvUtil.getSystemProperty( Const.POI_BYTE_ARRAY_MAX_SIZE ), 157286400 );
          // Increase the maximum allowed size
          org.apache.poi.util.IOUtils.setByteArrayMaxOverride( maxSize );
          internalIS = KettleVFS.getInstance( bowl ).getInputStream( filename );
          workbook = org.apache.poi.ss.usermodel.WorkbookFactory.create( internalIS, password );
      }
    } catch ( EncryptedDocumentException e ) {
      log.logError( "Unable to open spreadsheet.  If the spreadsheet is password protected please double check the password is correct." );
      throw new KettleException( e.getLocalizedMessage() );
    } catch ( Exception e ) {
      throw new KettleException( e );
    }
  }

  public PoiWorkbook( InputStream inputStream, String encoding ) throws KettleException {
    this.encoding = encoding;

    try {
      workbook = org.apache.poi.ss.usermodel.WorkbookFactory.create( inputStream );
    } catch ( Exception e ) {
      throw new KettleException( e );
    }
  }

  public void close() {
    try {
      if ( internalIS != null ) {

View on GitHub (pinned to f3058517a1)