0

Included the following libraries:

..\lib\ooxml-schemas-1.4.jar;..\lib\poi-ooxml-5.0.0.jar;..\lib\poi-5.0.0.jar;..\lib\ooxml-lib\xmlbeans-4.0.0.jar;..\lib\lib\commons-collections4-4.4.jar;..\lib\commons-compress-1.20.jar

I am trying to create and excel file and write into it. It compiles ok. However when I run, get a "No such method error". I notice that CTFont.class exists in ooxml-schemas-1.4.jar. Want to know in which version I can find, CTFont.addNewFamily().

Exception in thread "main" java.lang.NoSuchMethodError: 'org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFontFamily org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont.addNewFamily()'
        at org.apache.poi.xssf.usermodel.XSSFFont.setFamily(XSSFFont.java:635)
        at org.apache.poi.xssf.usermodel.XSSFFont.setFamily(XSSFFont.java:647)
        at org.apache.poi.xssf.model.StylesTable.createDefaultFont(StylesTable.java:765)
        at org.apache.poi.xssf.model.StylesTable.initialize(StylesTable.java:716)
        at org.apache.poi.xssf.model.StylesTable.<init>(StylesTable.java:130)
        at org.apache.poi.ooxml.POIXMLFactory.newDocumentPart(POIXMLFactory.java:94)
        at org.apache.poi.ooxml.POIXMLDocumentPart.createRelationship(POIXMLDocumentPart.java:591)
        at org.apache.poi.ooxml.POIXMLDocumentPart.createRelationship(POIXMLDocumentPart.java:500)
        at org.apache.poi.xssf.usermodel.XSSFWorkbook.onWorkbookCreate(XSSFWorkbook.java:465)
        at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:255)
        at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:249)
        at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:237)
        at WriteDataToExcel.main(WriteDataToExcel.java)
  • When asking a question, people will be better able to provide help if you provide code that they can easily understand and use to reproduce the problem. This is referred to by community members as creating a minimal, reproducible example (reprex), a minimal, complete and verifiable example (mcve), or a minimal, workable example (mwe). https://stackoverflow.com/help/minimal-reproducible-example – noob_nerd May 30 '21 at 12:01

1 Answers1

0

Include poi-ooxml-full-5.0.0.jar and poi-ooxml-lite-5.0.0.jar in the class path and removed ooxml-schemas-1.4.jar.

I got the answer from the following link: java.lang.NoSuchMethodError: org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont.addNewFamily()

As per the above link,

Version 5.0.0 of apache poi cannot use ooxml-schemas-1.4.jar anymore. It needs poi-ooxml-lite...jar or poi-ooxml-full...jar. So make sure there is not ooxml-schemas-1.4.jar in class path when apache poi 5.0.0 is used.