java.lang.NoSuchMethodError: org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont.addNewFamily()

java.lang.NoSuchMethodError: org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont.addNewFamily()

已将 poi 升级到版本并添加了来自 apache 站点的 jar 包。但是低于错误:

 java.lang.NoSuchMethodError: org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont.addNewFamily()

但是已验证 JAR 在项目中可用并且也可以通过代码访问。

根据@axel 的有效评论,将其发布为答案以获得更好的覆盖面。

apache poi 的 5.0.0 版本不能再使用 ooxml-schemas-1.4.jar

需要poi-ooxml-lite...jarpoi-ooxml-full...jar。因此,当使用 apache poi 5.0.0 时,请确保 class 路径中没有 ooxml-schemas-1.4.jar