{"record":{"id":"6b126ee9f841aff7","repo":"pentaho/pentaho-kettle","slug":"error-writing-field-posx-posy-logged-kettleexception-e","errorCode":null,"errorMessage":"Error writing field (posX,posY) (logged), KettleException( e )","messagePattern":"Error writing field \\(posX,posY\\) \\(logged\\), KettleException\\( e \\)","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/excel/core/src/main/java/org/pentaho/di/trans/steps/excelwriter/ExcelWriterStep.java","lineNumber":593,"sourceCode":"              cell.setCellValue( vMeta.getNumber( v ) );\n            } else if ( !meta.isRetainNullValues() ) {\n              cell.setCellValue( \"\" );\n            }\n            break;\n          default:\n            // fallthrough: output the data value as a string\n            if ( v != null ) {\n              cell.setCellValue( vMeta.getString( v ) );\n            } else if ( !meta.isRetainNullValues() ) {\n              cell.setCellValue( \"\" );\n            }\n            break;\n        }\n      }\n    } catch ( Exception e ) {\n      logError( \"Error writing field (\" + data.posX + \",\" + data.posY + \") : \" + e.toString() );\n      logError( Const.getStackTracker( e ) );\n      throw new KettleException( e );\n    }\n  }\n\n  /**\n   * Set specified cell format\n   *\n   * @param excelFieldFormat\n   *          the specified format\n   * @param cell\n   *          the cell to set up format\n   */\n  private void setDataFormat( String excelFieldFormat, Cell cell ) {\n    if ( log.isDebug() ) {\n      logDebug( BaseMessages.getString( PKG, \"ExcelWriterStep.Log.SetDataFormat\", excelFieldFormat,\n        CellReference.convertNumToColString( cell.getColumnIndex() ), cell.getRowIndex() ) );\n    }\n\n    DataFormat format = data.wb.createDataFormat();","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/excel/core/src/main/java/org/pentaho/di/trans/steps/excelwriter/ExcelWriterStep.java#L575-L611","documentation":"ExcelWriterStep.writeField() catches any exception thrown while writing a single field into a cell (POI cell write, data formatting, style application). It logs the field position (posX,posY), the stack trace, and rethrows as a KettleException to abort the transformation.","triggerScenarios":"Any Exception during cell creation/writing in writeField: unsupported value type for the field's value meta, POI cell style exhaustion, invalid date/number conversion, or an underlying IOException writing to the sheet.","commonSituations":"Writing a field whose value cannot be formatted by the chosen value metadata (e.g. binary field to a string cell); exceeding the 64000 cell styles limit in HSSF; writing to a closed workbook stream.","solutions":["Check the stack trace logged via Const.getStackTracker to find the root cause","Verify the field's value metadata (Data meta) matches the actual incoming value type","For large workbooks, reduce distinct cell formats or switch to XLSX (XSSF) to avoid style exhaustion","If caused by a closed stream, ensure the output file is not closed before writeNextLine completes"],"exampleFix":"// before: writing raw object may fail formatting\nstep.writeField(fieldName, vMeta, value, xlsRow, posX, null, -1, false);\n// after: pre-format to a compatible type\nif (value instanceof byte[]) { value = new String((byte[]) value, StandardCharsets.UTF_8); }\nstep.writeField(fieldName, vMeta, value, xlsRow, posX, null, -1, false);","handlingStrategy":"try-catch","validationCode":"// Java (calling step config check)\nfor (ExcelWriterStepField f : meta.getOutputFields()) {\n  if (f.getName() == null || f.getName().isEmpty()) throw new IllegalArgumentException(\"Field name required\");\n}","typeGuard":null,"tryCatchPattern":"try { writer.writeField(name, vMeta, value, row, pos, null, -1, true); }\ncatch (KettleException e) {\n  logError(\"Field write failed at \" + pos + \": \" + e.getCause(), e);\n  setErrors(1);\n}","preventionTips":["Match each field's value metadata to the actual data type","Avoid binary/blob fields unless converted to strings first","Prefer xlsx over xls for many distinct formats (style limit)","Confirm output stream is open before writing"],"tags":["excel","poi","cell-write","kettle"],"backgroundTag":"file-write-failed","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"}