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>
新聞熱點
疑難解答