3

我尝试使用 primefaces 3.2 的数据导出器控件。以下是代码:

<p:commandLink value="export" ajax="false">
        <p:dataExporter type="xls" target="dtable" fileName="myfile" />  
    </p:commandLink>
<p:datatable id="dtable" ........../>

当我单击导出链接时,出现以下错误:

java.lang.NoClassDefFoundError: com/lowagie/text/phrase

我下载了 itext jar 5.2.1 并将其包含在我的应用程序中,但仍然出现相同的错误。我该如何解决?

4

4 回答 4

17

尝试 iText 2.1.7 而不是 5.2.1。 http://olex.openlogic.com/packages/itext/2.1.7

我认为存在许可证冲突。所以 primefaces 使用 2.1.7

对于 Excel 导出,您需要 Apache POI。尝试 3.7: http: //archive.apache.org/dist/poi/release/bin/

编辑

(你只需要poi-3.7*.jarand poi-ooxml-3.7*.jar

于 2012-06-05T14:44:22.033 回答
0

转到 netbeans,在您的项目依赖项上添加一个新的依赖项。键入查询类型 iText 2.1.7,然后选择 com.lowagie:itext。你应该可以用 dpf 下载:D

于 2014-04-22T09:32:20.550 回答
-1

只需添加以下依赖项

    <dependency>
        <groupId>com.lowagie</groupId>
        <artifactId>itext</artifactId>
        <version>2.1.7</version>
    </dependency>
于 2017-11-05T21:42:46.810 回答
-3

我遇到了同样的问题,但是当我下载jar时它不起作用。然后我注意到我在使用<p:commandLink>,正确的是<h:commandLink>由于某种原因使用<p:commandLink>不起作用。

不要使用:

<p:commandLink > <p:graphicImage value="images/excel.png" width="48"/> <p:dataExporter type="xls" target="table" fileName="tablexls" encoding="UTF-8" /> </p:commandLink>

改为使用:

<h:commandLink > <p:graphicImage value="images/custom/excel.png" width="48"/> <p:dataExporter type="xls" target="table" fileName="tablexls" encoding="UTF-8" /> </h:commandLink>

于 2015-12-07T20:15:43.977 回答