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 it prints the 4 columns: id - year - brand - color
.
How can you hide a column only in excel, but still see it on the web?
Use
exportable="false"
in the desired columns. I put your example hidden the year columnOfficial Documentation