2014-01-16 57 views
0

我有一個應用程序,我有一個表格,該表格正在將其數據轉換爲pdf文件,它在sturts中並且工作正常。但是我必須添加此功能的另一個應用程序也有一個表與數據庫中的數據。我張貼我的工作代碼,也是我想要添加此功能的代碼片段.... 這是從哪裏我的頁面正在導出數據到file.i在我的表來實現這個PDF文件,但是當我當我在導出爲PDF選項單擊表點擊在struts中獲取表格以將其數據轉換爲pdf格式

<display:table class="tableData context-menu-one" name="sessionScope.DetailsFormBean.listOfUser" requestURI="/search.do" id="tableData" pagesize="10" style="overflow-x: scroll" export="true"> 
        <thead> 
         <tr style="font-size: 14px;" > 
          <th align="left"> <display:column title="Favourites"/></th> 
          <th align="left"> <display:column property="call_type" title="CALL_TYPE"/></th> 
          <th align="left"> <display:column property="a_no" title="A_NO"/></th> 
          <th align="left"> <display:column property="b_no" title="B_NO"/></th> 
          <th align="left"> <display:column property="call_duration" title="CALL_DURATION"/></th> 
          <th align="left"> <display:column property="start_day" title="START_DAY"/></th> 
          <th align="left"> <display:column property="end_day" title="END_DAY"/></th> 
          <th align="left"> <display:column property="a_home_circle" title="A_HOME_CIRCLE"/></th> 
          <th align="left"> <display:column property="a_rome_circle" title="A_ROME_CIRCLE"/></th> 
          <th align="left"> <display:column property="a_imei" title="A_IMEI"/></th> 
          <th align="left"> <display:column property="a_imsi" title="A_IMSI"/></th> 

          <display:setProperty name="export.excel.filename" value="ActorDetails.xls"/> 
          <display:setProperty name="export.pdf.filename" value="ActorDetails.pdf"/> 
          <display:setProperty name="export.pdf" value="true" /> 
         </display:table> 




    <action input="/" name="DetailsFormBean" path="/search" scope="session" type="com.homeland.action.HomeLandPersonalAction" parameter="search"> 
     <forward name="found" path="/searchpage.jsp"/> 
    </action> 

表自敗....請人幫忙

回答

0

導出爲pdf,csv & xml是從struts-displaytag屬性。您必須在JSP頁面中使用displaytag,然後使用列表actorList

它不依賴於數據庫。一旦列表獲得值(來自數據庫或其他方式 - 也就是硬編碼),您可以使用displaytag屬性在JSP中顯示它。並且它會顯示出口選項,只要您將其設置爲true即可。

這看起來像你的問題一樣。

<display:table id="data" name="sessionScope.UserForm.actorList" requestURI="/userAction.do" pagesize="10" export="true"> 
     <display:column property="tvShow" title="TV Show" sortable="true" media="html" group="1" /> 
     <display:column property="userName" title="User Name" sortable="true" /> 
     <display:column property="emailId" title="Email Id" sortable="true" /> 
     <display:setProperty name="export.excel.filename" value="ActorDetails.xls"/> 
     <display:setProperty name="export.pdf.filename" value="ActorDetails.pdf"/> 
     <display:setProperty name="export.pdf" value="true" /> 
    </display:table> 
+0

它的工作對我來說,我已經發布的代碼,但我需要的功能在我的表 – lucifer

+0

感謝您YOUE幫助其工作now..can你解釋一件事是什麼是<顯示:的setProperty名稱=」 export.excel.filename「value =」ActorDetails.xls「/> 事情我不明白,如果這件事你可以解釋我會妥善解決它 – lucifer

+0

歡迎。請接受答案。請通過http://www.displaytag.org/10/tagreference-displaytag-12.html –