出于某种原因,当我使用DataExporter时,它只打印出最后一列。如果我排除该列,那么它只输出空数据。 PDF和Excel都是一样的。
我已经包含了poi 3.7和itext 2.1.7。 请帮忙!!!
<p:toolbar>
<p:toolbarGroup align="left">
<h:panelGrid columns="8" cellpadding="5" >
<h:outputText value="Log Type:" />
<p:selectOneMenu id="logTypeSelectMessages" value="#{transactionLogBean.mlLogType}" style="width:200px" >
<f:selectItem itemLabel="Select Log Type" itemValue="" />
<f:selectItem itemLabel="All" itemValue="All" />
<f:selectItem itemLabel="Message" itemValue="MESSAGE" />
<f:selectItem itemLabel="Debug" itemValue="DEBUG" />
</p:selectOneMenu>
<h:outputText value="Message Type:" />
<p:selectOneMenu id="reqTypeSelectMessages" value="#{transactionLogBean.reqType}" style="width:200px" >
<f:selectItem itemLabel="Select Log Type" itemValue="" />
<f:selectItem itemLabel="All" itemValue="All" />
<f:selectItem itemLabel="Ext Response" itemValue="EXTRES" />
<f:selectItem itemLabel="Ext Request" itemValue="EXTREQ" />
<f:selectItem itemLabel="Int Response" itemValue="INTRES" />
<f:selectItem itemLabel="Int Request" itemValue="INTREQ" />
</p:selectOneMenu>
<p:commandButton id="refreshBtnMsgLogs" value="Refresh" action="#{transactionLogBean.refreshMessageLogData}"
update=":transactionLogForm:tabViewGrids:messageTable" ajax="true" />
</h:panelGrid>
</p:toolbarGroup>
<p:toolbarGroup align="right">
<h:panelGrid columns="2" cellpadding="8" >
<h:commandLink>
<p:graphicImage value="../resources/excel24.png" />
<p:dataExporter type="xls" target="messageTable" fileName="Message Logs" />
</h:commandLink>
<h:commandLink>
<p:graphicImage value="../resources/pdf24-2.png" />
<p:dataExporter type="pdf" target="messageTable" fileName="Message Logs" />
</h:commandLink>
</h:panelGrid>
</p:toolbarGroup>
</p:toolbar>
<p:spacer width="10" height="10" />
<p:dataTable id="messageTable" value="#{transactionLogBean.mlList}"
var="m" widgetVar="msgTable" rowKey="#{m.recID}"
selectionMode="single" selection="#{transactionLogBean.selectedMessage}"
paginator="true" rows="20" style="font-size:14px"
rowStyleClass="#{m.rowColour}" >
<p:ajax event="rowSelect" update=":transactionLogForm:msg"
oncomplete="logDialog.show()" />
<p:column style="text-align: left; width: 290px">
<f:facet name="header">
Log Id
</f:facet>
#{m.logID}
</p:column>
<p:column style="text-align: left; width: 80px" sortBy="#{m.logType}">
<f:facet name="header">
Log Type
</f:facet>
#{m.logType}
</p:column>
<p:column style="text-align: left; width: 160px" sortBy="#{m.dateTime}">
<f:facet name="header">
DateTime
</f:facet>
#{m.dateTime}
</p:column>
<p:column style="text-align: left; width: 105px" sortBy="#{m.requestType}">
<f:facet name="header">
Request Type
</f:facet>
#{m.requestType}
</p:column>
<p:column style="text-align: left; width: 110px" sortBy="#{m.extIPAddress}">
<f:facet name="header">
Ext IP Address
</f:facet>
#{m.extIPAddress}
</p:column>
<p:column style="text-align: left; width: 130px" sortBy="#{m.serverIPAddress}">
<f:facet name="header">
Server IP Address
</f:facet>
#{m.serverIPAddress}
</p:column>
<p:column style="text-align: left; width: 80px" sortBy="#{m.userID}">
<f:facet name="header">
User ID
</f:facet>
#{m.userID}
</p:column>
<p:column style="text-align: left; width: 80px" sortBy="#{m.retailID}">
<f:facet name="header">
Retail ID
</f:facet>
#{m.retailID}
</p:column>
<p:column style="text-align: left; width: 80px" sortBy="#{m.clientID}">
<f:facet name="header">
Client ID
</f:facet>
#{m.clientID}
</p:column>
<p:column style="text-align: left; width: 110px" sortBy="#{m.application}">
<f:facet name="header">
Application
</f:facet>
#{m.application}
</p:column>
<p:column headerText="Log Message" style="white-space:nowrap; text-overflow: ellipsis; overflow: hidden; text-align: left" exportable="false">
<div style="overflow:hidden; width:300px; float:left; ">
<h:outputText value="#{m.logMessage}"/>
</div>
</p:column>
</p:dataTable>
答案 0 :(得分:1)
尝试使用<h:outputText value="#{m.application}"
代替#{m.application}
(将显示的数据放在h:outputText value
属性中)