1

i have one form inside the form i have one datatable and one chart so i need to export both in either PDF or excel file, i am using following command for export data

<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>

i have tried above code but not able to export both when i export only datatable then its work properly.

so please help me how can i export chart and datatable into signle file?

thanks in advances.

1 Answer 1

0

You just can't, not without creating a complex custom exporter... Sidenote: I think a real reporting tool is in the end a much better fit...

4
  • Do you have idea how can i create PDF as well as excel file with datatable and chart too gather? Sep 10, 2015 at 12:02
  • can you please suggest me with example? Sep 10, 2015 at 12:12
  • It could be possible to upload the chart image to the server in javascript and then add this image to the PDF in the preProcessPDF listener function of the dataExporter primefaces component? Sep 10, 2015 at 12:19
  • Example: Check here: google.com/search?q=java+reporting+tool @lametaweb: Yes, and that is (part of) creating a complex custom exporter... Don t go there. Use a real reporting tool.
    – Kukeltje
    Sep 10, 2015 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.