Jsp作为模板导出excel

package com.bi.wms.rpt.report.web;


/**
 * 产品维护汇总统计表
 * @author Administrator
 *
 */
public class RptProUpdateRecordAction extends AbstractWmsAction {

    private String dqStartDt;
    private String dqEndDt;
    private String fxStartDt;
    private String fxEndtDt;
    private String startDt;
    private String endDt;
    private String acctypeCode;
    private String pfcat_code;
    private String maintain_rate;//维护率
    private List<ProPfcats> proPfcatsList;
    private List<String> pfcat_codes=new ArrayList<String>();
    private List<ReportNewPro> reportNewProList;
    private List<ReportNewProDetails> reportNewProDetails;//明细
    private String print_dt = DateUtil.defaultDateFormater(new Date());
   
    @Resource(name = "pro.common.proPfcatsManager")
    private ProPfcatsManager proPfcatsManager;
   
    @Resource(name = "rpt.report.reportManager")
    private ReportManager reportManager;

        //导出excel报表
    public String toDetailsReport() {
        reportNewProDetails = reportManager.getNewProUnModify(pfcat_code, startDt, endDt);
        return "detailsReport";
     }


    //getter & setter ...
   
}

struts配置:
    <!-- 产品维护汇总统计表 -->
    <action name="rpt.report.rptProUpdateRecord" class="rpt.report.rptProUpdateRecordAction">
        <result name="detailsReport">/jsp/rpt/report/prorecord/reportProUpdateRecordDetails_excel.jsp</result>
    </action>


Jsp页面:

<%@ page contentType="application/msexcel" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sb" uri="/struts-bi-tags" %>
<%
   response.setHeader("Content-disposition","attachment; filename=" + java.net.URLEncoder.encode("未维护产品明细报表.xls", "UTF-8"));
%>
<html>
<head>
    <title><s:property value="title11"/></title> 
</head>
<body>
  <table width="100%" border="1" class="tableHorizontal3">
   <tr>
    <th height="40" bgcolor="#9D9D9D" align="center" colspan="4">
     <h3>产品明细报表(<s:property value="print_dt"/>)</h3>
    </th>
   </tr>
   <tr>
     <th width="10%" >产品代码</th>
     <th width="20%" >产品名称</th>
     <th width="15%" >维护责任人</th>
   </tr>
<s:if test="reportNewProDetails!=null && reportNewProDetails.size()>0">
 <s:iterator value="reportNewProDetails" status="rowstatus">
   <tr>
     <td><s:property value="pro_code"/></td>
     <td><s:property value="pro_name"/></td>
     <td><s:property value="adm_users"/></td>
   </tr>
 </s:iterator>
</s:if>
</table>
</body>
</html>

猜你喜欢

转载自premier9527.iteye.com/blog/1605522
今日推荐