jsp中将数据转成excel

Posted on 2011-12-13 18:50  无忧consume  阅读(169)  评论(0编辑  收藏  举报

http://blog.csdn.net/sdrzths/article/details/4238687

<%@ page contentType="application/vnd.ms-excel;charset=GBK" %> 
<% 
response.setHeader("Content-Disposition", "attachment;filename=query.xls"); 
%> 
<%@ taglib prefix="s" uri="/struts-tags" %>  
<html> 
<body> 
<s:form name="accident" action="" 
id="frm"> 
<table width="100%" border="0" align="center" cellpadding="3" 
cellspacing="1" bgcolor="A4C2E8" > 
<tr><td colspan="14"><div align="center"><b>安全主任列表</b></div></td></tr> 
<tr bgcolor="#FFFFFF"> 
<td width="3%"><div align="center">序号</div></td> 
<td width="6%"><div align="center">姓名</div></td> 
<td width="2%"><div align="center">性别</div></td> 
<td width="2%"><div align="center">年龄</div></td> 
<td width="10%"><div align="center">学历</div></td> 
<td width="15%"><div align="center">工作单位</div></td> 
<td width="10%"><div align="center">身份证号</div></td> 
<td width="8%"><div align="center">手机</div></td> 
<td width="3%"><div align="center">从事安全年限</div></td> 
<td width="2%"><div align="center">成绩</div></td> 
<td width="10%"><div align="center">证书号</div></td> 
<td width="10%"><div align="center">注册编号</div></td> 
<td width="10%"><div align="center">注册单位</div></td> 
<td width="9%"><div align="center">注册时间</div></td> 
</tr> 
<s:iterator value="list" status="status"> 
<tr bgcolor="#FFFFFF"> 
<td><div align="center">87967</div></td> 
<td><div align="center">43535</div></td> 
<td><div align="center">${sex }</div></td> 
<td><div align="center">${age}</div></td> 
<td><div align="center">${culture}</div></td> 
<td><div align="center">${entpName}</div></td> 
<td><div align="center">${idcard}</div></td> 
<td><div align="center">${tel}</div></td> 
<td><div align="center">${yearOfSecurity}</div></td> 
<td><div align="center">${theoryScore}</div></td> 
<td><div align="center">${masterNo}</div></td> 
<td><div align="center">${registerNo}</div></td> 
<td><div align="center">${handlePerson}</div></td> 
<td><div align="center">${registerTime}</div></td> 
</tr> 
</s:iterator> 
</table> 
</s:form> 
</body> 
</html> 

<!--说明:红色部分表示服务器响应给客户端的格式,绿色部分设置Excel的格式-->

Copyright © 2024 无忧consume
Powered by .NET 9.0 on Kubernetes