码迷,mamicode.com
首页 > 其他好文 > 详细

EL表达式查询出来的数据,下载成excel表格,很实用的

时间:2016-05-08 15:11:23      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="application/vnd.ms-excel; charset=gbk" %>
<%@page import="java.text.SimpleDateFormat"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddkkmmssSSS");
String filename = new String(("文件名字-"+sf.format(new Date())).getBytes("gbk"),"ISO-8859-1");
response.addHeader("Content-Disposition", "filename=" + filename + ".xls");
%>
<%@ page isELIgnored="false"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>XX信息</title>
<link href="<%=basePath%>pages/packageInfo/css/table.css" rel="stylesheet" type="text/css" />

</head>

<body>
<div class="boderBG">
<table id="hacker" width="98%" border="0" cellspacing="1" cellpadding="0" class="dataTable">
<thead><tr>
<th width="11%" height="23" align="center">XX</th>
<th width="11%" align="center">XX</th>
<th width="10%" align="center">XX</th>
<th width="11%" align="center">XX</th>
<th width="11%" align="center">XX</th>
<th width="11%" align="center">XX</th>
<th width="11%" align="center">XX</th>
<th width="11%" align="center">XX</th>
<th width="11%" align="center">XX</th>
</tr>
</thead>
<c:forEach var="calRecordList" items="${calRecordList}" >
<tr>
<td height="23" >${calRecordList.callnum}</td>
<td >${calRecordList.toCallnum}</td>
<td><fmt:formatDate value="${calRecordList.begintime}" pattern="yyyy年MM月dd HH:mm:ss" /></td>
<td align="center"><fmt:formatDate value="${calRecordList.endtime}" pattern="yyyy年MM月dd HH:mm:ss" /></td>
<td align="center">${calRecordList.calltype}</td>
<td align="center">${calRecordList.talktime}</td>
<td align="center">${calRecordList.billtime}</td>
<td align="center">${calRecordList.fee}</td>
<td align="center">${calRecordList.groupid}</td>
</tr>
</c:forEach>
</table>
</div>
</body>
</html>

EL表达式查询出来的数据,下载成excel表格,很实用的

标签:

原文地址:http://www.cnblogs.com/zhangliang88/p/5470515.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!