2014-01-16 41 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 –