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

  1. Inspect the chained cause exception in the logs for the true root cause.
  2. Ensure xlsFilePath is a writable file path, not a directory, and the disk has free space.
  3. Upgrade/verify Apache POI dependencies are consistent on the classpath.
  4. 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

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


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/04c5d19b69da10e6. Report an issue: GitHub.