2

I used the same sample code Primefaces has in its web page:

<h:commandLink value="Excel">                     
  <p:dataExporter type="xls" target="dataTable" fileName="boo" pageOnly="true"/>  
</h:commandLink>

But does not work. In Internet Explorer browser gives the following message:

Details of the errors of the web page Message: Unexpected call to method or property access.

Nothing ever happens in Mozilla Firefox.

What might be happening?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Deb
  • 431
  • 4
  • 12
  • 26
  • What version of primefaces are you on? – kolossus Nov 08 '12 at 16:58
  • The error message in IE is by the way a JS/jQuery-specific error (and thus not JSF-specific). You might want to check the properness of your JS code first (onload handlers, event listeners, etc). As to lack of feedback in Firefox, did you check its JS console as well? – BalusC Nov 08 '12 at 17:00
  • Also check if you aren't nesting forms; a JSF+PrimeFaces oriented question about exactly the same IE error message has been asked before, but then with a much better SSCCE: http://stackoverflow.com/questions/9501448/jsf2-0-primefaces-3-0-1-jquery-1-6-4-pcommandlink-ie8-throws-unexpected, the cause turns out to be nested forms. – BalusC Nov 08 '12 at 17:05
  • @kolossus primefaces version 3.4 – Deb Nov 08 '12 at 17:07
  • By the way... CSV is not the same as XLS. – BalusC Nov 08 '12 at 17:12
  • @BalusC you are correct, accurate for both types. :) – Deb Nov 08 '12 at 17:15
  • @BalusC I moved and now is giving execeção this: javax.servlet.ServletException: org/apache/poi/ss/usermodel/RichTextString – Deb Nov 09 '12 at 11:50
  • The call is to export the datatable in the same form. – Deb Nov 09 '12 at 11:51
  • I managed to export to pdf and csv, but xls still giving execption that says there is a class of poi. – Deb Nov 09 '12 at 12:16

2 Answers2

7
javax.servlet.ServletException: org/apache/poi/ss/usermodel/RichTextString

Look further down in the stacktrace. I bet that the root cause is either a NoClassDefFoundError or ClassNotFoundException? In that case, this just means that you forgot to install Apache POI.

Download this Apache POI zip file, extract it, put poi-3.8-20120326.jar in /WEB-INF/lib folder and rebuild/redeploy/restart the webapp.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I downloaded the full package poi. My Excel 2003, that is trying to generate the xlsx and so is giving error? Well from what I read in the http://poi.apache.org/ poi3.8 versions should work for both Excel 2003 and for 2007 and 2010. – Deb Nov 09 '12 at 12:30
  • I added the libraries poi 3.8 and now is giving the following exception: javax.servlet.ServletException: Class Does Not Implement org.apache.poi.hssf.usermodel.HSSFWorkbook the requested interface org.apache.poi.ss.usermodel.Workbook . Any idea of what can be? – Deb Nov 09 '12 at 15:21
  • Apparently you've also installed JExcelAPI for some reason and imported `Workbook` from the wrong package. Make sure that it's the `org.apache.poi.ss.usermodel.Workbook` one and remove JExcelAPI if you aren't using it at all. – BalusC Nov 09 '12 at 15:33
  • I didn't find apiapi to manipulate Excel. Nor have JExcelAPI. I honestly don't know how to solve it. – Deb Nov 09 '12 at 16:45
  • Okay. Maybe you have multiple Apache POI libraries of possibly different versions in your webapp's runtime classpath? That could also be a cause. Cleanup the webapp's runtime classpath so that you end up with only one right version of POI. – BalusC Nov 09 '12 at 16:46
  • I got excluding all other versions of poi from my folder. Even not being on the classpath of the project, was giving conflicting. – Deb Nov 09 '12 at 17:59
  • @BalusC: I am using primefaces 4.0 and in my WEB-INF/lib folder i have poi-9.0.jar. Still i am getting the "javax.servlet.ServletException: org/apache/poi/ss/usermodel/RichTextString" error. Is there any problem with the version? – JPS Feb 23 '14 at 10:39
0

Try to to put this jar file.I show the link,because i solved this problem.

http://apache.mirrors.pair.com/poi/release/bin/poi-bin-3.9-20121203.zip