Jsf primefaces数据导出器XLS仅导出标题而不导出行
我的问题是,当我单击按钮导出数据表时,它只导出列标题,而生成的excel文件没有行Jsf primefaces数据导出器XLS仅导出标题而不导出行,jsf,primefaces,data-export,Jsf,Primefaces,Data Export,我的问题是,当我单击按钮导出数据表时,它只导出列标题,而生成的excel文件没有行 <h:form> <p:dataTable id="cteTable" var="cte" emptyMessage="Nenhum Registro Localizado" reflow="true" value="#{extratorBean.ctes}" paginatorTemplate="{CurrentPageReport} {Firs
<h:form>
<p:dataTable id="cteTable" var="cte"
emptyMessage="Nenhum Registro Localizado"
reflow="true" value="#{extratorBean.ctes}" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {Exporters}"
style="margin-top: 10px" paginator="true" rows="100" scrollable="true" scrollWidth="1024px">
<f:facet name="{Exporters}">
<h:commandLink>
<p:graphicImage name="images/excel.png" width="24" library="samsung" />
<p:dataExporter type="xls" target="cteTable" fileName="cte-s" />
</h:commandLink>
</f:facet>
<p:column headerText="CNPJ Emissor" width="150" style="text-align: center">
<h:outputText value="#{cte.EMIT_CNPJ}"/>
</p:column>
<p:column headerText="Serie" width="60" style="text-align: center">
<h:outputText value="#{cte.IDE_SERIE}"/>
</p:column>
<p:column headerText="N° CT-e" width="90" style="text-align: center">
<h:outputText value="#{cte.IDE_NCT}"/>
</p:column>
<p:column headerText="Dt. Emissão" width="150" style="text-align: center">
<h:outputText value="#{cte.IDE_DHEMI}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
</p:column>
<p:column headerText="Total Frete" width="80" style="text-align: center">
<h:outputText value="#{cte.VPREST_VTPREST}">
<f:convertNumber type="currency" />
</h:outputText>
</p:column>
<p:column headerText="ICMS" width="80" style="text-align: center">
<h:outputText value="#{cte.ICMS_VICMS}">
<f:convertNumber type="currency" />
</h:outputText>
</p:column>
<p:column headerText="% ICMS" width="80" style="text-align: center">
<h:outputText value="#{cte.ICMS_PICMS}">
<f:convertNumber minFractionDigits="2" />
</h:outputText>
</p:column>
<p:column headerText="Nat. Op." width="350" style="text-align: center">
<h:outputText value="#{cte.IDE_NATOP}"/>
</p:column>
<p:column headerText="CNPJ Tomador" width="150" style="text-align: center">
<h:outputText value="#{cte.TOMADOR}"/>
</p:column>
<p:column headerText="Chave Acesso" width="350" style="text-align: center">
<h:outputText value="#{cte.TRANSACTIONID}"/>
</p:column>
<p:column headerText="Dt. Criação" width="120" style="text-align: center">
<h:outputText value="#{cte.IDE_TIMESTAMP}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
</p:column>
<p:column headerText="N° Protocolo" width="120" style="text-align: center">
<h:outputText value="#{cte.IDE_AUTHCODESEFAZ}"/>
</p:column>
</p:dataTable>
</h:form>
我使用的是primefaces 5.3,并尝试使用ApachePOI3.8和3.10-FINAL,但两者都不起作用
在日志中我没有任何错误
编辑:我已经知道发生了什么。
问题是,当我的表被加载时,它是空的,但看起来像是将其导出到excel的按钮,使表保持某种缓存为空,甚至在我将数据加载到表中之后,按钮仍将excel导出为空。
现在,我不知道如何解决这个问题。在p:column之后添加f:facet标题
<p:column>
<f:facet name="header">
<h:outputText value="CNPJ Emissor"/>
</f:facet>
<h:outputText value="#{cte.EMIT_CNPJ}"/>
</p:column>
好吧,如果有人遇到这个问题,下面是我的答案: 我的托管bean的作用域是请求。但是当我点击按钮导出excel时,它向maneged bean发出了一个新的请求。在这个请求中,我的列表是空的。我通过在getList方法中放置断点来检查这一点。
因此,我只需将托管bean的作用域从请求作用域更改为查看作用域,即可正常工作。导出器似乎对过滤数据使用了该属性,因此在第一次时,由于过滤数据为空,您只会得到标题。我建议尝试将数据添加到页面加载的过滤数据中。您的“附加说明”文本似乎已被截断。请随意编辑您的帖子以添加更多内容!谢谢,但我完全忘了我要说什么。请为你的回复创建一个链接,但我已经知道发生了什么。问题是,当我的表被加载时,它是空的,但看起来像是将其导出到excel的按钮,使表保持某种缓存为空,甚至在我将数据加载到表中之后,按钮仍将excel导出为空。现在,我不知道如何解决这个问题。谢谢你的回复,但我已经知道发生了什么。问题是,当我的表被加载时,它是空的,但看起来像是将其导出到excel的按钮,使表保持某种缓存为空,甚至在我将数据加载到表中之后,按钮仍将excel导出为空。现在,我不知道如何解决这个问题。你是说你的桌子空了,你想导出吗?或者当按下“导出”按钮时,您的表变空了?如果您的情况不是2,请尝试将ManageBean范围更改为@viewscope。