JSP生成Excel报表

JSP代码
 1 <%@ page contentType="text/html; charset=UTF-8" %>
 2 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 3 <% response.setContentType("application/vnd.ms-excel;charset=UTF-8"); %>
 4 <!-- 设置下载文件的文件名 -->
 5 <!-- 设置excel为显示模式 -->
 6 <!-- <% response.setHeader("Content-disposition","inline; filename=test.xls"); %> -->
 7 <!-- 设置excel为下载模式 -->
 8 <% response.setHeader("Content-disposition","attachment; filename=test.xls"); %>
 9 <html>
10 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
11 <head>
12 <title>报表</title> 
13 </head>
14 <body>
15 <CENTER>
16 <table cellpadding="1" cellspacing="1" border="1">
17 <tr>
18 <td colspan="5" align="center">报表</td>
19 </tr>
20 <tr class="dan_tr">
21 <th>使用时间</th>
22 <th>使用者</th>
23 <th>传播者</th>
24 <th>使用地点</th>
25 <th>消耗积分</th>
26 </tr>
27 <c:forEach var="list" items="${list}">
28 <tr align="center">
29 <td width="135">${list.userDate}</td>
30 <td width="100">${list.userName}</td>
31 <td width="100">${list.puserName}</td>
32 <td width="350">${list.userCorp}</td>
33 <td>${list.integral}分</td>
34 </tr>
35 </c:forEach>
36 </table>
37 </CENTER>
38 </body>
39 </html>

 

posted @ 2017-01-17 14:56  ﹏Memory°鑫  阅读(157)  评论(0编辑  收藏  举报