Data Exporter

ModelYearManufacturerColor
5ba84fc01994AudiBrown
ece1b9281975JaguarBrown
892a3a8c1969OpelBlue
6ee5ec1e2002HondaBrown
c2ad1dc11995AudiRed
02111fea1984FordOrange
580d15801985OpelWhite
d739bc3e1991VolkswagenSilver
97220b811961AudiBlue
093205c32005BMWOrange

Export All Data
Export Page Data

Source

<p:dataTable id="tbl" var="car" value="#{tableBean.cars}" paginator="true" rows="10">
	<p:column>
		<f:facet name="header">
			<h:outputText value="Model" />
		</f:facet>
		<h:outputText value="#{car.model}" />
	</p:column>

	<p:column>
		<f:facet name="header">
			<h:outputText value="Year" />
		</f:facet>
		<h:outputText value="#{car.year}"/>
	</p:column>

	<p:column>
		<f:facet name="header">
			<h:outputText value="Manufacturer" />
		</f:facet>
		<h:outputText value="#{car.manufacturer}" />
	</p:column>

	<p:column>
		<f:facet name="header">
			<h:outputText value="Color" />
		</f:facet>
		<h:outputText value="#{car.color}" />
	</p:column>
</p:dataTable>
	
<h:panelGrid columns="2">
	<p:panel header="Export All Data">
		<h:commandLink>
			<p:graphicImage value="/images/excel.png" />
			<p:dataExporter type="xls" target="tbl" fileName="cars" />
		</h:commandLink>

		<h:commandLink>
			<p:graphicImage value="/images/pdf.png" />
			<p:dataExporter type="pdf" target="tbl" fileName="cars"/>
		</h:commandLink>
		
		<h:commandLink>
			<p:graphicImage value="/images/csv.png" />
			<p:dataExporter type="csv" target="tbl" fileName="cars" />
		</h:commandLink>
		
		<h:commandLink>
			<p:graphicImage value="/images/xml.png" />
			<p:dataExporter type="xml" target="tbl" fileName="cars" />
		</h:commandLink>
	</p:panel>
	
	<p:panel header="Export Page Data">
		<h:commandLink>
			<p:graphicImage value="/images/excel.png" />
			<p:dataExporter type="xls" target="tbl" fileName="cars" pageOnly="true"/>
		</h:commandLink>

		<h:commandLink>
			<p:graphicImage value="/images/pdf.png" />
			<p:dataExporter type="pdf" target="tbl" fileName="cars" pageOnly="true"/>
		</h:commandLink>
		
		<h:commandLink>
			<p:graphicImage value="/images/csv.png" />
			<p:dataExporter type="csv" target="tbl" fileName="cars" pageOnly="true"/>
		</h:commandLink>
		
		<h:commandLink>
			<p:graphicImage value="/images/xml.png" />
			<p:dataExporter type="xml" target="tbl" fileName="cars" pageOnly="true"/>
		</h:commandLink>
	</p:panel>
</h:panelGrid>