0
votes

We are doing an changes in our application for converting the file extension from xls to xlsx format (2007 and above), while exporting the file from the application.

I have made necessary code changes by adding XSSF intead of HSSF by upgrading to POI 3.9 jar. The previous version of Jar file we used is POI 3.0.

The below jars I have added in the Library folder:

poi-3.9-20121203
poi-examples-3.9-20121203
poi-excelant-3.9-20121203
poi-ooxml-3.9-20121203
poi-ooxml-schemas-3.9-20121203
poi-scratchpad-3.9-20121203
commons-codec-1.5
commons-logging-1.1
junit-3.8.1
dom4j-1.6.1
stax-api-1.0.1
xmlbeans-2.3.0

After upgrading the Jar files, I am getting a page cannot be displayed error when I tried to export files in the application. Below is the exception in console when I click on the Excel icon:

com.sun.faces.lifecycle.InvokeApplicationPhase execute #{customerFinancialReportAction.createReport}: javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError: org.apache.poi.ss.usermodel.Font
                                 javax.faces.FacesException: #{customerFinancialReportAction.createReport}: javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError: org.apache.poi.ss.usermodel.Font
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:79)
    at javax.faces.component.UICommand.broadcast(UICommand.java:312)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:298)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:412)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77)
    at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:220)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:91)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)

We are unsure what is causing the problem here. Please help me to resolve this issue.

1
Are you sure all of those jars are correctly available? And have you removed the old POI 3.0 jars? It looks a lot like you're missing the jars you claim to have is all - Gagravarr

1 Answers

0
votes
    Font font = workBook.createFont();
    font.setFontName(XSSFFont.DEFAULT_FONT_NAME);//Is this way you are creating font
    font.setFontHeightInPoints((short)10);
    return font;