我正在尝试使用 Primefaces 的 dataExporter 组件将值从 dataTable 导出到 Excel。
我正在使用 primefaces 3.5 和 jsf 2.2;
我的数据表和命令链接如下:
<p:dataTable id="tableTemp" binding="#{ledgerComplMB.tableTemp}" value="#{ledgerComplMB.listaTemp}"
var="q" emptyMessage="No Registry" paginator="true" rows="10"
rowsPerPageTemplate="10,50,200,500"
paginatorTemplate=" {CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
scrollable="true" scrollWidth="100%" scrollRows="10"
filteredValue="#{ledgerComplMB.listaTempFilter}"
filterDelay="1500" resizableColumns="true" editable="true">
<f:facet name="header">
<p:commandButton id="btGravar" icon="ui-icon-disk"
value="Write data" actionListener="#{ledgerComplMB.gravar}"
disabled="${empty ledgerComplMB.listaTemp}" style="width:200px;" />
<p:commandButton id="btLimpar" value="Clean data"
actionListener="#{ledgerComplMB.limpar}" icon="ui-icon-trash"
disabled="${empty ledgerComplMB.listaTemp}"
style="width:200px;font-weight: bold;margin-left: 20px"/>
<br />
<h:outputText
value="Total: #{fn:length(ledgerComplMB.listaTemp)}"
rendered="#{not empty ledgerComplMB.listaTemp}" />
</f:facet>
<p:ajax event="rowEdit"
oncomplete="dlgConfirma.show()" update=":form:dialogConfirmacao" />
<p:column exportable="false" style="width:30px">
<p:rowEditor />
</p:column>
<p:column filterBy="#{q.ledger.accountNumber}" filterMatchMode="exact" style="width:100px">
<f:facet name="header">AccountNumber</f:facet>
<h:outputText value="#{q.ledger.accountNumber}" />
</p:column>
<p:column filterBy="#{q.ledger.vendor}" filterMatchMode="exact" style="width:100px">
<f:facet name="header">Vendor</f:facet>
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{q.ledger.vendor}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{q.ledger.vendor}" />
</f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
<p:commandLink id="exp1" ajax="false">
<p:graphicImage library="img" name="pdf.png" />
<p:dataExporter type="xlsx" target="tableTemp" fileName="#{ledgerComplMB.retornaDataExport}" />
当我请求导出时,只会出现标题值。