JSP生成Excel报表

  JSP实现报表下载

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<% response.setContentType("application/vnd.ms-excel;charset=UTF-8"); %>
<!-- 设置下载文件的文件名 -->
<!-- 设置excel为显示模式 -->
<!-- <% response.setHeader("Content-disposition","inline; filename=test.xls"); %> -->
<!-- 设置excel为下载模式 -->
<% response.setHeader("Content-disposition","attachment; filename=test.xls"); %>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<head>
<title>报表</title>    
</head>
<body>
    <CENTER>
         <table cellpadding="1" cellspacing="1"  border="1">
              <tr>
                      <td colspan="5" align="center">报表</td>
              </tr>
                <tr class="dan_tr">
                       <th>使用时间</th>
                       <th>使用者</th>
                       <th>传播者</th>
                       <th>使用地点</th>
                       <th>消耗积分</th>
                </tr>
          <c:forEach var="list" items="${list}">
              <tr align="center">
                   <td width="135">${list.userDate}</td>
                   <td width="100">${list.userName}</td>
                   <td width="100">${list.puserName}</td>
                   <td width="350">${list.userCorp}</td>
                   <td>${list.integral}分</td>
              </tr>
          </c:forEach>
         </table>
    </CENTER>
</body>
</html>

 

posted @ 2015-12-06 21:43  小破孩123  阅读(1259)  评论(0编辑  收藏  举报