【发布时间】:2015-09-10 11:05:55
【问题描述】:
我在表单中有一个表单我有一个数据表和一个图表,所以我需要以 PDF 或 excel 文件导出,我正在使用以下命令导出数据
<h:form id="contenForm">
<!-- chart -->
<p:chart type="bar" model="#{dataModel.barModel}" id="barChart" />
<!-- Datatable -->
<p:dataTable value="#{dataModel.list}" var="loc" width="100%" paginator="true"
id="tableResulta" paginatorPosition="bottom" tableStyle="margin:0 auto; width:100%" rendered="#{not empty dataModel.list}">
<p:column>
<f:facet name="header">
<h:outputText value="Surname" />
</f:facet>
<h:outputText value="#{loc.surname}" />
</p:column>
<!-- and other colume-->
</p:dataTable>
<!-- Export button -->
<h:panelGrid columns="2" rendered="#{not empty dataModel.list}">
<h:commandLink immediate="true">
<p:commandButton value="Export excel" immediate="true" />
<p:dataExporter type="xls" target="barChart,tableResulta" fileName="formInformation" />
</h:commandLink>
<h:commandLink immediate="true">
<p:commandButton value="Export PDF" immediate="true" />
<p:dataExporter type="pdf" target="barChart,tableResulta" fileName="formInformation" />
</h:commandLink>
</h:panelGrid>
</h:form>
我已经尝试了上面的代码,但是当我只导出数据表然后它可以正常工作时,不能同时导出。
那么请帮助我如何将图表和数据表导出到signle文件中?
提前致谢。
【问题讨论】:
标签: jsf jsf-2 primefaces charts export-to-pdf