jsp页面导出当前list数据列表 excel
来源:互联网 发布:淘宝主板可靠 编辑:程序博客网 时间:2024/04/29 10:05
项目中经常遇到导出的页面,之前公司有封装好的方法可以调用
目前的公司没有封装的方法,完全凭借自己去发挥
网上可以搜索出很多的方法去实现
个人认为如下的方式比较方便快捷
具体做法如下,仅供参考:
1.在需要被导出的页面做个功能按钮,跳转到对应的Java类
2.将已经显示出来的数据的主键id拼接起来作为参数传到Java类里面
3.根据主键查询出数据列表,这个操作会影响到效率问题,因为重新请求了数据库
4.查询出来的结果,return到一个页面
页面头的写法就是导出的方法:
<%@ page contentType="application/msexcel;charset=GBK" %>
<%
response.setHeader("Content-disposition","attachment; filename=download.xls");
response.setHeader("Pragma", "");
response.setHeader("Cache-Control", "");
%>
注意:filename不能是中文
页面头的下方正常写需要导出那个页面的代码
例如:
<%@ page contentType="application/msexcel;charset=GBK" %>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
response.setHeader("Content-disposition","attachment; filename=download.xls");
response.setHeader("Pragma", "");
response.setHeader("Cache-Control", "");
%>
<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<link rel="StyleSheet" href="<s:url value='/skin!loadCss.do?id=blue'/>" type="text/css" />
<script type="text/javascript" src="<s:url value='/skin!loadJs.do?id=tdcolor'/>"></script>
</head>
<body>
<table>
<tr>
<th nowrap>产品名称</th>
<th nowrap>生产企业</th>
<th nowrap>注销日期</th>
</tr>
<s:iterator value="qbpropr.data">
<tr>
<td align="center"><s:property value="genericName" /></td>
<td align="center"><s:property value="entName" /></td>
<td><s:date name="proStatusDate" format="yyyy-MM-dd" /></td>
</tr>
</s:iterator>
</table>
</body>
</html>
- jsp页面导出当前list数据列表 excel
- jsp页面将数据导出到Excel
- jsp页面表格数据导出到excel
- jsp页面将数据导出到Excel
- jsp页面导出excel,部分数据乱码
- jsp页面导出excel
- excel导出列表数据
- List导出数据Excel
- List导出数据Excel
- jsp导出数据(excel)
- jsp数据导出excel
- 将页面的列表数据导出到excel文件中
- 导出页面数据Excel
- 页面数据导出Excel
- [转载]jsp页面显示数据导出到excel表中
- jsp页面显示数据导出到excel表中
- jsp页面显示数据导出到excel表中
- jsp页面查询的数据导出到excel(二)
- poj1190生日蛋糕
- Windows 8.1 新安全时代的到来
- hive udf上传
- DM8148学习历程(1)
- findbugs相关知识
- jsp页面导出当前list数据列表 excel
- Eclipse快捷键大全
- POJ 3449 Geometric Shapes
- Tinifile的使用
- vs2010 directX winnt.h错误
- linux gdb的使用方法.
- Unable to open log device ‘/dev/log/main’: No such file or directory
- 很有用的linux命令
- timerTask与Timer