Reputation: 10083
I tried to use the data exporter control of PrimeFaces 3.2. Following is the code:
<p:commandLink value="export" ajax="false">
<p:dataExporter type="xls" target="dtable" fileName="myfile" />
</p:commandLink>
<p:datatable id="dtable" .../>
When I click on export link, I get the following error:
java.lang.NoClassDefFoundError: com/lowagie/text/phrase
I downloaded itext jar 5.2.1 and included it in my application, still I get the same error. How do I solve it?
Upvotes: 3
Views: 18751
Reputation: 1
Copy this code to your pom.xml
file:
<dependency>
<groupId>org.eclipse.birt.runtime.3_7_1</groupId>
<artifactId>com.lowagie.text</artifactId>
<version>2.1.7</version>
</dependency>
And this is what the XHTML should be:
<h:commandLink>
<img src="/img/icones/excel.png"/>
<p:dataExporter type="xlsx" target="tbl" fileName="#{relatorioController.relatorio.nome}" />
</h:commandLink>
<p:spacer width="10"/>
<h:commandLink>
<img src="/img/icones/pdf.png"/>
<p:dataExporter type="pdf" target="tbl" fileName="#{relatorioController.relatorio.nome}"/>
</h:commandLink>
Upvotes: 0
Reputation: 169
Just add the following dependency
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
</dependency>
Upvotes: -1
Reputation: 1
I was having the same problem, but when i downloaded the jars it doesn't worked.
Then I noticed I was using <p:commandLink>
, the correct is to use <h:commandLink>
for some reason <p:commandLink>
won't work.
Don't use:
<p:commandLink >
<p:graphicImage value="images/excel.png" width="48"/>
<p:dataExporter type="xls" target="table" fileName="tablexls" encoding="UTF-8" />
</p:commandLink>
instead use:
<h:commandLink >
<p:graphicImage value="images/custom/excel.png" width="48"/>
<p:dataExporter type="xls" target="table" fileName="tablexls" encoding="UTF-8" />
</h:commandLink>
Upvotes: -3
Reputation: 7
Go to netbeans, on your project dependency add a new dependency. Type Query type iText 2.1.7 then choose com.lowagie:itext. you should be able to download with dpf :D
Upvotes: 0
Reputation: 1480
Try iText 2.1.7 not 5.2.1. http://olex.openlogic.com/packages/itext/2.1.7
I think there are licence conflicts. So primefaces uses 2.1.7
For Excel Export you need Apache POI. Try 3.7: http://archive.apache.org/dist/poi/release/bin/
Edit
(you need only the poi-3.7*.jar
and poi-ooxml-3.7*.jar
)
Upvotes: 17