pentaho/pentaho-kettle · error · KettleException

Password protection currently only supported for XLS file…

Error message

Password protection currently only supported for XLS file format.

What it means

ExcelWriterStep throws this when a sheet password is requested for output that is not the legacy HSSF (.xls) format. Only HSSFSheet supports protectSheet in this step; XSSF (.xlsx) and streaming outputs are rejected. It is a deliberate guard since the UI should prevent this combination.

Solutions

  1. Change the file extension/format in the Excel Writer step to XLS, or
  2. Clear the 'Password' / sheet-protection setting when writing XLSX
  3. If XLSX protection is required, apply protection post-processing (e.g. Apache POI in a UDJC step) since the step does not support it

Example fix

// before: xlsx output with password set
meta.setExtension("xlsx"); meta.setPassword("secret");
// after
if ( "xlsx".equalsIgnoreCase( meta.getExtension() ) ) { meta.setPassword( null ); }
Defensive patterns

Strategy: validation

Validate before calling

if ( "xls".equalsIgnoreCase( stepMeta.getExtension() ) == false && stepMeta.getPassword() != null ) {
  throw new IllegalArgumentException( "Sheet password requires XLS output" );
}

Try / catch

try { transform.execute(...) } catch ( KettleException e ) { if ( e.getMessage().contains( "only supported for XLS" ) ) { /* fix format or clear password */ } }

Prevention

When it happens

Trigger: Running an Excel Writer step with 'Sheet password protection' set while 'Extension' is xlsx (or another non-XLS format), bypassing the UI check (e.g. metadata injection, KTR edited by hand, or API-driven transformation generation).

Common situations: Users migrating an old .xls-based transformation to .xlsx output but leaving the password field populated; generating transformations programmatically where the UI validation never runs.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at plugins/excel/core/src/main/java/org/pentaho/di/trans/steps/excelwriter/ExcelWriterStep.java:991

  @Override
  public void dispose( StepMetaInterface smi, StepDataInterface sdi ) {
    meta = (ExcelWriterStepMeta) smi;
    data = (ExcelWriterStepData) sdi;
    clearWorkbookMem();
    super.dispose( smi, sdi );
  }

  /**
   * Write protect Sheet by setting password works only for xls output at the moment
   */
  protected void protectSheet( Sheet sheet, String password ) throws KettleException {
    if ( sheet instanceof HSSFSheet ) {
      // Write protect Sheet by setting password
      // works only for xls output at the moment
      sheet.protectSheet( password );
    } else {
      // prevented at UI, but still
      throw new KettleException( "Password protection currently only supported for XLS file format." );
    }
  }




  public String[] getFormats() {
    // Prepare a list of possible formats, filtering reserved internal formats away
    String[] formats = BuiltinFormats.getAll();

    List<String> allFormats = Arrays.asList( formats );
    List<String> nonReservedFormats = new ArrayList<>( allFormats.size() );

    for ( String format : allFormats ) {
      if ( !format.startsWith( "reserved" ) ) {
        nonReservedFormats.add( format );
      }
    }

View on GitHub (pinned to f3058517a1)