{"record":{"id":"dcf7eef59c527614","repo":"pentaho/pentaho-kettle","slug":"password-protection-currently-only-supported-for-xls-file","errorCode":null,"errorMessage":"Password protection currently only supported for XLS file format.","messagePattern":"Password protection currently only supported for XLS file format\\.","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/excel/core/src/main/java/org/pentaho/di/trans/steps/excelwriter/ExcelWriterStep.java","lineNumber":991,"sourceCode":"  @Override\n  public void dispose( StepMetaInterface smi, StepDataInterface sdi ) {\n    meta = (ExcelWriterStepMeta) smi;\n    data = (ExcelWriterStepData) sdi;\n    clearWorkbookMem();\n    super.dispose( smi, sdi );\n  }\n\n  /**\n   * Write protect Sheet by setting password works only for xls output at the moment\n   */\n  protected void protectSheet( Sheet sheet, String password ) throws KettleException {\n    if ( sheet instanceof HSSFSheet ) {\n      // Write protect Sheet by setting password\n      // works only for xls output at the moment\n      sheet.protectSheet( password );\n    } else {\n      // prevented at UI, but still\n      throw new KettleException( \"Password protection currently only supported for XLS file format.\" );\n    }\n  }\n\n\n\n\n  public String[] getFormats() {\n    // Prepare a list of possible formats, filtering reserved internal formats away\n    String[] formats = BuiltinFormats.getAll();\n\n    List<String> allFormats = Arrays.asList( formats );\n    List<String> nonReservedFormats = new ArrayList<>( allFormats.size() );\n\n    for ( String format : allFormats ) {\n      if ( !format.startsWith( \"reserved\" ) ) {\n        nonReservedFormats.add( format );\n      }\n    }","sourceCodeStart":973,"sourceCodeEnd":1009,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/excel/core/src/main/java/org/pentaho/di/trans/steps/excelwriter/ExcelWriterStep.java#L973-L1009","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Change the file extension/format in the Excel Writer step to XLS, or","Clear the 'Password' / sheet-protection setting when writing XLSX","If XLSX protection is required, apply protection post-processing (e.g. Apache POI in a UDJC step) since the step does not support it"],"exampleFix":"// before: xlsx output with password set\nmeta.setExtension(\"xlsx\"); meta.setPassword(\"secret\");\n// after\nif ( \"xlsx\".equalsIgnoreCase( meta.getExtension() ) ) { meta.setPassword( null ); }","handlingStrategy":"validation","validationCode":"if ( \"xls\".equalsIgnoreCase( stepMeta.getExtension() ) == false && stepMeta.getPassword() != null ) {\n  throw new IllegalArgumentException( \"Sheet password requires XLS output\" );\n}","typeGuard":null,"tryCatchPattern":"try { transform.execute(...) } catch ( KettleException e ) { if ( e.getMessage().contains( \"only supported for XLS\" ) ) { /* fix format or clear password */ } }","preventionTips":["Keep password protection and XLSX extension mutually exclusive in your UI/config","Use metadata injection validation to reject xlsx+password combos","Test transformations with the same format they will run in production"],"tags":["excel","xls","unsupported-feature","kettle"],"backgroundTag":"unsupported-operation","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"}