pentaho/pentaho-kettle · error · KettleException
Error writing line :" + e.toString() (logged)…
Error message
Error writing line :" + e.toString() (logged), KettleException( e )
What it means
ExcelWriterStep.writeNextLine catches any exception thrown while writing a row of data to the sheet, logs 'Error writing line :<exception>', and rethrows it as a KettleException to fail the step. It means cell/sheet write operations for the current input row failed.
Solutions
- Read the logged 'Error writing line :...' entry — it contains the underlying exception with row details.
- Check the input row's field values and types against the step's field mapping (content/types).
- If formulas are enabled, verify formula strings are valid Excel syntax.
- For XLS output, confirm no XLSX-only features (e.g. cell comments, >65536 rows, >256 columns) are used.
- Log or preview the failing row (add a 'Get rows' count / log row) to identify the offending data.
Example fix
// before: null field value written as-is causes POI failure
sheet.addCell( new jxl.write.Number( col, row, numericValue ) );
// after: guard conversions
if ( value == null ) {
sheet.addCell( new jxl.write.Blank( col, row ) );
} else {
sheet.addCell( new jxl.write.Number( col, row, numericValue ) );
} Defensive patterns
Strategy: validation
Validate before calling
// before running, validate the row fields written to Excel
rowMeta.getFieldNames(); // confirm mapping matches input
if ( value == null || String.valueOf( value ).length() > 32767 ) {
throw new IllegalArgumentException( "Cell content exceeds Excel limit or is null" );
} Type guard
boolean isExcelWritable( Object v ) { return v != null && !( v instanceof Double && !Double.isFinite( (Double) v ) ); } Try / catch
try { writeNextLine( row ); } catch ( KettleException e ) { logError( "Failed on row " + rowNum + ": " + e.getMessage(), e ); setErrors( 1 ); } Prevention
- Reject/blank null and non-finite numeric values before they reach the sheet.
- Match XLS vs XLSX features to the selected output format (comments are XLSX-only).
- Keep rows within Excel limits (65536 rows / 256 cols for XLS).
- Validate formula strings when formula evaluation is enabled.
When it happens
Trigger: writeNextLine() throws while creating/writing cells into data.sheet (e.g. invalid cell type/value, sheet write error, POI internal failure) for the current row; posX/posY advance only on success.
Common situations: Field values incompatible with the chosen Excel format (e.g. oversized strings, invalid formula content); unsupported cell comment/content on the current sheet type; POI limitations with the target workbook (XLS vs XLSX features); extremely wide rows exceeding column limits.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- KettleException( e )
- Bounds of this rule are not numeric: lowerBound=
- ConnectionFileObject.PVFSRoot.UnsupportedOperation
- ConnectionFileObject.UndefinedConnection
- Could not convert to the given local format.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/8b40d4dec1b51617.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/excel/core/src/main/java/org/pentaho/di/trans/steps/excelwriter/ExcelWriterStep.java:386
writeField( r[i], data.inputRowMeta.getValueMeta( i ), null, xlsRow, data.posX++, r, i, false );
}
} else {
/*
* Only write the fields specified!
*/
for ( int i = 0; i < meta.getOutputFields().length; i++ ) {
Object v = r[data.fieldnrs[i]];
writeField( v, data.inputRowMeta.getValueMeta( data.fieldnrs[i] ), meta.getOutputFields()[i], xlsRow,
data.posX++, r, i, false );
}
}
// go to the next line
data.posX = data.startingCol;
data.posY++;
} catch ( Exception e ) {
logError( "Error writing line :" + e.toString() );
throw new KettleException( e );
}
}
private Comment createCellComment( String author, String comment ) {
// comments only supported for XLSX
if ( data.sheet instanceof XSSFSheet ) {
CreationHelper factory = data.wb.getCreationHelper();
Drawing<?> drawing = data.sheet.createDrawingPatriarch();
ClientAnchor anchor = factory.createClientAnchor();
Comment cmt = drawing.createCellComment( anchor );
RichTextString str = factory.createRichTextString( comment );
cmt.setString( str );
cmt.setAuthor( author );
return cmt;
}
return null;
}View on GitHub (pinned to f3058517a1)