Primefaces数据导出器在Excel中导出空值
我试图从数据库中导出一些数据 使用下面的代码,导出的文件在所有列中显示空值,尽管我的变量Primefaces数据导出器在Excel中导出空值,excel,jsf-2,primefaces,export,Excel,Jsf 2,Primefaces,Export,我试图从数据库中导出一些数据 使用下面的代码,导出的文件在所有列中显示空值,尽管我的变量marchebean.selectedmarche.marchetraveau包含值 我的代码有什么错误吗 我正在使用PrimeFaces4.0,这是我的xhtml页面 <h:form id="form"> <p:tabView> <p:tab title="Visualiser "> <p:
marchebean.selectedmarche.marchetraveau
包含值
我的代码有什么错误吗
我正在使用PrimeFaces4.0,这是我的xhtml页面
<h:form id="form">
<p:tabView>
<p:tab title="Visualiser ">
<p:panel>
<h:commandLink >
<p:commandButton value="exporter" />
<p:dataExporter type="xls" target="crs" fileName="prixde" pageOnly="true" />
</h:commandLink>
<p:dataTable id="crs" var="marche" value="#{marchebean.selectedmarche.marchetraveau}" >
<f:facet name="header">
Tbaleau des travaux
</f:facet>
<f:facet name="footer">
<h3> Total HTVA = #{marchebean.calculdetotaltravhtva()}</h3>
<h3> Total TTC = #{marchebean.calculdetotaltravttc()} </h3>
</f:facet>
<p:column headerText="article" width="10%" >
<h:outputText value="#{marche.traveaux.article}"/>
</p:column>
<p:column headerText="Désignation des traveaux" width="40%" >
<h:outputText value="#{marche.traveaux.designation}"/>
<h:outputText value="#{marche.traveaux.paragraph}"/>
</p:column>
<p:column headerText="Unité">
<h:outputText value="#{marche.traveaux.unite}"/>
</p:column>
<p:column headerText="PUHTVA">
<h:outputText value="#{marche.prixunitaire}"/>
</p:column>
<p:column headerText="PUTTC">
<h:outputText value="#{marchebean.calcultva(marche.prixunitaire)}" />
</p:column>
<p:column headerText="Qtt">
<h:outputText value="#{marche.quantite}"/>
</p:column>
<p:column headerText="MHTVA">
<h:outputText value="#{marchebean.calculmonthtva(marche.prixunitaire ,marche.quantite)}" />
</p:column>
<p:column headerText="MTTC">
<h:outputText value="#{marchebean.calculmontttc(marche.prixunitaire ,marche.quantite)}" />
</p:column>
</p:dataTable>
</p:panel>
</p:tab>
</p:tabView>
</h:form>
特巴劳德特拉沃酒店
Total HTVA=#{marchebean.calculdetottaltravhtva()}
Total TTC=#{marchebean.calculdetotaltravttc()}
我们需要提供
<f:facet name="header>
<h:outputText value="aricle"/>
</f:facet>
这对我很有用。也许它需要验证,这就是为什么它最后是空的。添加immediate=“true”将跳过验证
<h:form id="confColaForm" .....>
<p:dataTable id="tablacolas" ... >
<f:facet name="header">
<h:commandLink id="exportar" update=":confColaForm:tablacolas" style="align:right;" immediate="true" >
<h:graphicImage library="images" name="iconexcel.png" style="width:30px;height:30px; "
title="Exportar" />
<p:dataExporter type="xls" target="tablacolas" fileName="ConfiguracionColas" />
</h:commandLink>
</f:facet>
...(columns here)
</p:dataTable/>
</h:form>
…(此处列)
可能的原因可能是“managedbean范围”。。。
1) 将范围更改为“视图”
2) 序列化managedbean
这对我很有效可能重复@EmilKaminski:谢谢你的回答我的问题不同,我的exel文件中有空列,尽管我将值更改为列,但相同的错误仍然存在!!设法缩小问题的范围。创建一个简单的datatable,在任何面板和选项卡外有一列,看看它是否有效?如果是,请添加更多列。。。如果它仍然有效,试着继续工作直到你发现问题。请通过解释什么是不同的和不同的来改进你的答案why@Kukeltje树有点不同,请尝试添加immediate=“true”。它可能会失败,因为它需要一些验证,而这会跳过它。我将把这一点添加到我的主要评论中。
<h:form id="confColaForm" .....>
<p:dataTable id="tablacolas" ... >
<f:facet name="header">
<h:commandLink id="exportar" update=":confColaForm:tablacolas" style="align:right;" immediate="true" >
<h:graphicImage library="images" name="iconexcel.png" style="width:30px;height:30px; "
title="Exportar" />
<p:dataExporter type="xls" target="tablacolas" fileName="ConfiguracionColas" />
</h:commandLink>
</f:facet>
...(columns here)
</p:dataTable/>
</h:form>