primefaces hide column in excel p: dataExporter

0

I have a table like the following:

<p:dataTable var="car" value="#{dtBasicView.cars}">
    <f:facet name="header">
        <p:outputLabel style="float:left">Resultados de búsqueda</p:outputLabel>
            <p:dataExporter type="xls" target="car" fileName="coches"/>
        </p:outputPanel>                                                          
    </f:facet>
    <p:column headerText="Id">
        <h:outputText value="#{car.id}" />
    </p:column>

    <p:column headerText="Year">
        <h:outputText value="#{car.year}" />
    </p:column>

    <p:column headerText="Brand">
        <h:outputText value="#{car.brand}" />
    </p:column>

    <p:column headerText="Color">
        <h:outputText value="#{car.color}" />
    </p:column>
</p:dataTable>

Now when exporting the excel print me the 4 columns: id - year - brand - color .

How can you hide a column only in the excel, but still be seen on the web?

    
asked by nachfren 17.07.2018 в 14:33
source

1 answer

2

Use exportable="false" in the desired columns. I put your example hidden column year

<p:dataTable var="car" value="#{dtBasicView.cars}">
<f:facet name="header">
    <p:outputLabel style="float:left">Resultados de búsqueda</p:outputLabel>
        <p:dataExporter type="xls" target="car" fileName="coches"/>
    </p:outputPanel>                                                          
</f:facet>
<p:column headerText="Id">
    <h:outputText value="#{car.id}" />
</p:column>

<p:column headerText="Year" exportable="false">
    <h:outputText value="#{car.year}" />
</p:column>

<p:column headerText="Brand">
    <h:outputText value="#{car.brand}" />
</p:column>

<p:column headerText="Color">
    <h:outputText value="#{car.color}" />
</p:column>

Official Documentation

    
answered by 17.07.2018 / 14:37
source