poi导出excel的时候怎么让他选择导出路径
1个回答
展开全部
点导出的时候,把所需要的数据传入导出界面JSP,这是我自己拼接的,代码如下
<%@ page contentType="application/vnd.ms-excel; charset=utf-8" %>
<%@ page language="java" import="java.util.*,com.expect.bean.Admin" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String xlsname = request.getAttribute("xlsname").toString();
String fileName = xlsname+".xls";
byte[] yte = fileName.getBytes("GB2312");
String unicoStr = new String(yte, "ISO-8859-1");
response.setHeader("Content-disposition","attachment;filename="+unicoStr);
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
#tableinfo tr td{
text-align: center;font-size: 13px;border: 1px solid #64ABD6;
}
#tableinfo{width: 100%;border-collapse: collapse;height: 30px;line-height: 30px;}
</style>
</head>
<body >
<table cellspacing="0" id="tableinfo" >
<tr>
<td style="text-align: center;font-size:30px;font-weight: bold;" id="titletd" colspan="8">
<%=xlsname %>电费表<br/>
</td>
</tr>
<tr>
<td style="text-align: center;" id="titletd" colspan="2">
用户名:
</td>
<td style="text-align: center;" id="titletd">
分厂:
</td>
<td style="text-align: center;" id="titletd">
住宅区:
</td>
<td style="text-align: center;" id="titletd" >
楼层:
</td>
<td style="text-align: center;" id="titletd" >
具体住址:
</td>
<td style="text-align: center;" id="titletd" >
上次度数:
</td>
<td style="text-align: center;" id="titletd" >
本次度数:
</td>
<td style="text-align: center;" id="titletd" >
操作时间:
</td>
</tr>
</table>
<%
List list = (List)request.getAttribute("list");
if(list!=null && list.size()>0){
for(int i=0;i<list.size();i++){
Map m = (Map)list.get(i);
String userName = m.get("userName")==null || m.get("userName").equals("") ? "" : m.get("userName").toString();
String branch = m.get("branch")==null || m.get("branch").equals("") ? "" : m.get("branch").toString();
String upTown = m.get("upTown")==null || m.get("upTown").equals("") ? "" : m.get("upTown").toString();
String storey = m.get("storey")==null || m.get("storey").equals("") ? "" : m.get("storey").toString();
String home = m.get("home")==null || m.get("home").equals("") ? "" : m.get("home").toString();
String totalSum = m.get("totalSum")==null || m.get("totalSum").equals("") ? "" : m.get("totalSum").toString();
String enterTime = m.get("enterTime")==null || m.get("enterTime").equals("") ? "" : m.get("enterTime").toString();
String upMonthCount = m.get("upMonthCount")==null || m.get("upMonthCount").equals("") ? "" : m.get("upMonthCount").toString();
%>
<table cellspacing="0" id="tableinfo" >
<tr>
<td style="text-align: center;" id="titletd" colspan="2">
<%=userName %>
</td>
<td style="text-align: center;" id="titletd" >
<%=branch %>
</td>
<td style="text-align: center;" id="titletd" >
<%=upTown %>
</td>
<td style="text-align: center;" id="titletd" >
<%=storey %>
</td>
<td style="text-align: center;" id="titletd" >
<%=home %>
</td>
<td style="text-align: center;" id="titletd" >
<%=totalSum %>
</td>
<td style="text-align: center;" id="titletd" >
<%=upMonthCount %>
</td>
<td style="text-align: center;" id="titletd" >
<%=enterTime %>
</td>
</tr>
</table>
<%
}
}
%>
</body>
</html>
<%@ page contentType="application/vnd.ms-excel; charset=utf-8" %>
<%@ page language="java" import="java.util.*,com.expect.bean.Admin" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String xlsname = request.getAttribute("xlsname").toString();
String fileName = xlsname+".xls";
byte[] yte = fileName.getBytes("GB2312");
String unicoStr = new String(yte, "ISO-8859-1");
response.setHeader("Content-disposition","attachment;filename="+unicoStr);
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
#tableinfo tr td{
text-align: center;font-size: 13px;border: 1px solid #64ABD6;
}
#tableinfo{width: 100%;border-collapse: collapse;height: 30px;line-height: 30px;}
</style>
</head>
<body >
<table cellspacing="0" id="tableinfo" >
<tr>
<td style="text-align: center;font-size:30px;font-weight: bold;" id="titletd" colspan="8">
<%=xlsname %>电费表<br/>
</td>
</tr>
<tr>
<td style="text-align: center;" id="titletd" colspan="2">
用户名:
</td>
<td style="text-align: center;" id="titletd">
分厂:
</td>
<td style="text-align: center;" id="titletd">
住宅区:
</td>
<td style="text-align: center;" id="titletd" >
楼层:
</td>
<td style="text-align: center;" id="titletd" >
具体住址:
</td>
<td style="text-align: center;" id="titletd" >
上次度数:
</td>
<td style="text-align: center;" id="titletd" >
本次度数:
</td>
<td style="text-align: center;" id="titletd" >
操作时间:
</td>
</tr>
</table>
<%
List list = (List)request.getAttribute("list");
if(list!=null && list.size()>0){
for(int i=0;i<list.size();i++){
Map m = (Map)list.get(i);
String userName = m.get("userName")==null || m.get("userName").equals("") ? "" : m.get("userName").toString();
String branch = m.get("branch")==null || m.get("branch").equals("") ? "" : m.get("branch").toString();
String upTown = m.get("upTown")==null || m.get("upTown").equals("") ? "" : m.get("upTown").toString();
String storey = m.get("storey")==null || m.get("storey").equals("") ? "" : m.get("storey").toString();
String home = m.get("home")==null || m.get("home").equals("") ? "" : m.get("home").toString();
String totalSum = m.get("totalSum")==null || m.get("totalSum").equals("") ? "" : m.get("totalSum").toString();
String enterTime = m.get("enterTime")==null || m.get("enterTime").equals("") ? "" : m.get("enterTime").toString();
String upMonthCount = m.get("upMonthCount")==null || m.get("upMonthCount").equals("") ? "" : m.get("upMonthCount").toString();
%>
<table cellspacing="0" id="tableinfo" >
<tr>
<td style="text-align: center;" id="titletd" colspan="2">
<%=userName %>
</td>
<td style="text-align: center;" id="titletd" >
<%=branch %>
</td>
<td style="text-align: center;" id="titletd" >
<%=upTown %>
</td>
<td style="text-align: center;" id="titletd" >
<%=storey %>
</td>
<td style="text-align: center;" id="titletd" >
<%=home %>
</td>
<td style="text-align: center;" id="titletd" >
<%=totalSum %>
</td>
<td style="text-align: center;" id="titletd" >
<%=upMonthCount %>
</td>
<td style="text-align: center;" id="titletd" >
<%=enterTime %>
</td>
</tr>
</table>
<%
}
}
%>
</body>
</html>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询