apache/dolphinscheduler · error · AlertEmailException
generate excel error
Error message
generate excel error
What it means
The final stage of genExcelFile wraps any exception thrown while building the workbook or writing it to the FileOutputStream (wb.write(fos)) in AlertEmailException('generate excel error', e). It is a generic wrapper: the root cause (POI error, IO error) is in the chained exception.
Source
Thrown at dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/ExcelUtils.java:129
} else {
String cellValue = String.valueOf(values[j]);
int maxLen = SpreadsheetVersion.EXCEL2007.getMaxTextLength();
if (cellValue.length() > maxLen) {
cellValue = cellValue.substring(0, maxLen - 67) + "...(truncated)";
}
cell1.setCellValue(cellValue);
}
}
}
for (int i = 0; i < headerList.size(); i++) {
sheet.setColumnWidth(i, headerList.get(i).length() * 800);
}
// setting file output
wb.write(fos);
} catch (Exception e) {
throw new AlertEmailException("generate excel error", e);
}
}
}
View on GitHub (pinned to 02eac45a1b)
Solutions
- Inspect the chained cause exception in the logs for the true root cause.
- Ensure xlsFilePath is a writable file path, not a directory, and the disk has free space.
- Upgrade/verify Apache POI dependencies are consistent on the classpath.
- Sanitize alert content so header keys are never null.
Example fix
// before
FileOutputStream fos = new FileOutputStream(xlsFilePath + title + ".xlsx");
// after
File outFile = new File(xlsFilePath, title + ".xlsx");
if (outFile.isDirectory()) { throw new AlertEmailException("target is a directory: " + outFile); }
FileOutputStream fos = new FileOutputStream(outFile); Defensive patterns
Strategy: try-catch
Validate before calling
File out = new File(xlsFilePath, title + ".xlsx");
if (out.isDirectory() || !out.getParentFile().canWrite()) { throw new IllegalStateException("bad excel target: " + out); } Try / catch
try { ExcelUtils.genExcelFile(content, title, xlsFilePath); } catch (AlertEmailException e) { log.error("excel write failed: {}", e.getCause(), e); } Prevention
- Always inspect the chained cause of this generic wrapper
- Ensure the target path is a file path, not a directory
- Keep POI library versions consistent; monitor disk space
When it happens
Trigger: wb.write(fos) fails: the target path exists as a directory, disk is full, the FileOutputStream cannot be opened, or POI throws while processing malformed rows/headers (e.g. null header values).
Common situations: xlsFilePath points to an existing directory so the file cannot be opened for writing; disk full on the alert server; content contains null keys producing null headers.
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
- Create xlsx directory error
- itemsList is null
- Update the resource file from content: {fileAbsolutePath} fa
- Download the resource file: {fileAbsolutePath} failed
- Calculate checksum error.
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/04c5d19b69da10e6.
Report an issue: GitHub.