Backend Development 11 min read

Why Did My Excel Export Suddenly Fail? Debugging EasyPOI & Apache POI Version Conflicts

A Java developer recounts how an unexpected Excel export failure was traced to mismatched EasyPOI and Apache POI versions, the impact of Maven's -U flag, and the step‑by‑step resolution involving dependency alignment and careful version selection.

JD Cloud Developers
JD Cloud Developers
JD Cloud Developers
Why Did My Excel Export Suddenly Fail? Debugging EasyPOI & Apache POI Version Conflicts

Background

After taking over the development and maintenance of the Insurance "One‑Line Voice" platform, the first issue encountered was that the event‑to‑Excel export feature stopped working after a recent deployment.

Problem Description

The platform uses

easypoi

together with

apache‑poi

to generate Excel files. The feature worked until tasks created after 2024‑04‑12 12:04:39 began failing.

Investigation

3.1 Investigation Process

The failure appeared shortly after a deployment, suggesting the new code caused the issue. However, the changed code had nothing to do with the Excel export logic.

Log inspection revealed an exception:

<code>cn.afterturn.easypoi.exception.excel.ExcelExportException: Excel导出错误
    at cn.afterturn.easypoi.excel.export.ExcelExportService.createSheet(ExcelExportService.java:118)
    ...
Caused by: java.lang.NoSuchMethodError: org.apache.poi.ss.usermodel.CellStyle.setAlignment(S)V
    at cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerDefaultImpl.stringNoneStyle(ExcelExportStylerDefaultImpl.java:69)
    ...</code>

3.2 Dependency Details

The project uses the following Maven dependencies:

<code>&lt;dependency&gt;
  &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
  &lt;artifactId&gt;poi&lt;/artifactId&gt;
  &lt;version&gt;4.0.1&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
  &lt;artifactId&gt;poi-ooxml&lt;/artifactId&gt;
  &lt;version&gt;4.0.1&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;cn.afterturn&lt;/groupId&gt;
  &lt;artifactId&gt;easypoi-spring-boot-starter&lt;/artifactId&gt;
  &lt;version&gt;4.0.0&lt;/version&gt;
  &lt;exclusions&gt;
    &lt;exclusion&gt;
      &lt;artifactId&gt;guava&lt;/artifactId&gt;
      &lt;groupId&gt;com.google.guava&lt;/groupId&gt;
    &lt;/exclusion&gt;
  &lt;/exclusions&gt;
&lt;/dependency&gt;</code>

A transitive dependency forced

easypoi-base

to version 3.2, which contains code that expects older POI constants that were removed in newer POI releases.

The root cause was identified as a Maven build command using the

-U

flag, which forces snapshot dependencies to be refreshed, unintentionally pulling in newer POI artifacts that lacked the expected constants.

Resolution

4.1 First Upgrade Attempt

Attempting to downgrade POI caused additional compatibility problems, so the team upgraded to

easypoi 4.5.0

and

apache‑poi 5.0.0

. This introduced a new set of errors.

4.2 Second Failure

After the upgrade, intermittent tasks hung and logs showed another

NoSuchMethodError

related to

CTFont.addNewFamily()

:

<code>2024-06-25 20:38:04.730 ERROR ... java.lang.NoSuchMethodError: org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont.addNewFamily()Lorg/openxmlformats/schemas/spreadsheetml/x2006/main/CTFontFamily;
    at org.apache.poi.xssf.usermodel.XSSFFont.setFamily(XSSFFont.java:635)
    ...</code>

The conflict stemmed from two POI artifacts:

poi‑ooxml‑lite:5.0.0

and

poi‑ooxml‑schemas:4.1.1

. The method exists only in the newer artifact, causing inconsistent behavior between local and production environments.

By forcing the application to use the

poi‑ooxml‑schemas

version locally, the error could be reproduced, confirming the dependency clash.

4.3 Final Fix

The solution was to align all POI‑related dependencies to compatible versions. Referring to the official

easypoi 4.5.0

POM, the team settled on

easypoi 4.5.0

together with

apache‑poi 4.1.1

, ensuring that the transitive POI libraries matched the expected API.

After updating the

pom.xml

with these versions and redeploying, the Excel export functionality worked reliably.

javaMavenExcel ExportApache POIEasyPOIDependency Conflict
JD Cloud Developers
Written by

JD Cloud Developers

JD Cloud Developers (Developer of JD Technology) is a JD Technology Group platform offering technical sharing and communication for AI, cloud computing, IoT and related developers. It publishes JD product technical information, industry content, and tech event news. Embrace technology and partner with developers to envision the future.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.