Exporting data in various formats
The dataExporter
component allows exporting the content of the table into various formats such as XLS/XLSX, PDF, CSV, and XML. It also supports exporting the current data on a page and also only the selected data on the table by providing the ability to exclude particular columns and manipulating the exported data with pre and post processors.
How to do it...
A basic definition for having data-exporting ability with a command link that encapsulates a PDF icon would be as follows:
<h:commandLink> <p:graphicImage value="/resources/images/export/pdf.png" /> <p:dataExporter type="pdf" target="countriesTable" fileName="countries" /> </h:commandLink>
How it works...
In the previous definition, target
defines the server-side ID of the table whose data will be exported. The table needs to be a PrimeFaces dataTable
component. The type
attribute defines the export type. The values can be xls
, pdf
, csv
, or xml
. The fileName
attribute defines the...