DataExporter - Customized Documents DataExporter provides easy customization options for the exported document using pre and post processors or ExcelOptions and PDFOptions objects.
IdYearBrandColor
294619f61980FordGreen
7a328e9f1973JaguarWhite
70dfcc401990HondaRed
b790bd231968AudiRed
f5c60c421971VolkswagenBlue
a543eb4f1990JaguarYellow
38077eb82001MercedesGreen
838a345d1999MercedesMaroon
d46ae9d31984RenaultWhite
8578219a1994BMWOrange
IdYearBrandColor
8b3d449e1987RenaultBlack
e33444e91992JaguarMaroon
f5fe58d91961FordMaroon
2c24819a1960VolkswagenBlue
a9339b0b1974VolkswagenWhite
8786a6171964VolkswagenOrange
cf8857b91982FordGreen
63d5dfe52003VolvoRed
2332ef781962AudiGreen
a0c95e581990BMWBlue
<h:form>
    <p:dataTable id="tbl" var="car" value="#{customizedDocumentsView.cars}" 
                 paginator="true" rows="10">
        <p:column>
            <f:facet name="header">
                <h:outputText value="Id" />
            </f:facet>
            <h:outputText value="#{car.id}" />
        </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="Brand" />
            </f:facet>
            <h:outputText value="#{car.brand}" />
        </p:column>

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

    <h:commandLink id="excel">
        <p:graphicImage name="/demo/images/excel.png" />
        <p:dataExporter type="xls" target="tbl" fileName="cars" postProcessor="#{customizedDocumentsView.postProcessXLS}" />
    </h:commandLink>

    <h:commandLink id="pdf">
        <p:graphicImage name="/demo/images/pdf.png" />
        <p:dataExporter type="pdf" target="tbl" fileName="cars" preProcessor="#{customizedDocumentsView.preProcessPDF}" />
    </h:commandLink>

    <p:dataTable id="tbl2" var="car" value="#{customizedDocumentsView.cars2}" 
                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {Exporters}"
                 paginator="true" rows="10" style="margin-top: 25px;">

        <f:facet name="{Exporters}">
            <div style="float:right">
                <h:commandLink>
                    <p:graphicImage name="/demo/images/excel.png" width="24"/>
                    <p:dataExporter type="xls" target="tbl2" fileName="cars" options="#{customizedDocumentsView.excelOpt}" />
                </h:commandLink>

                <h:commandLink>
                    <p:graphicImage name="/demo/images/pdf.png" width="24"/>
                    <p:dataExporter type="pdf" target="tbl2" fileName="cars" options="#{customizedDocumentsView.pdfOpt}" />
                </h:commandLink>
            </div>
        </f:facet>

        <p:column>
            <f:facet name="header">
                <h:outputText value="Id" />
            </f:facet>
            <h:outputText value="#{car.id}" />
        </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="Brand" />
            </f:facet>
            <h:outputText value="#{car.brand}" />
        </p:column>

        <p:column>
            <f:facet name="header">
                <h:outputText value="Color" />
            </f:facet>
            <h:outputText value="#{car.color}" />
        </p:column>
    </p:dataTable>
</h:form>
                
PrimeTek, Copyright © 2017
All rights reserved.
Running PrimeFaces-6.2-SNAPSHOT on Mojarra-2.3.2.