jsp实现 页面excel的导出

本文介绍如何使用Java代码实现数据的导出为Excel文件,并通过设置响应头实现下载功能,包括设置文件名和内容类型。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 

<%@ page contentType="application/vnd.ms-excel;" language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ include file="/common.jsp"%>
<%   response.setHeader("Content-disposition","attachment; filename=数据.xls");%>
  
<html>
<head>
<title> 无</title>
<meta http-equiv="Content-Type" content="application/vnd.ms-excel; charset=GBK">
<style type="text/css">
BODY {
	MARGIN-TOP: 0px
}
td {
	FONT-SIZE: 14px;
	LINE-HEIGHT: 1.8;
}
a:link, a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: underline;
}
a.s1:link, a.s1:visited {
	text-decoration: none;
	color: #000000
}
a.s1:hover {
	text-decoration: underline;
	color: #c00;
}
</style>
</head>
<body topmargin="0">
<center>
<table width="100%" border="0" align="center" cellPadding="0" cellSpacing="1">
    <tbody>                                  
    <tr bgcolor="#FFFFFF">
      <td align="center" valign="top" class="f12"><table width="99%" border="0" cellpadding="1" cellspacing="1" bgcolor="#F0F0F0">
          <tr bgcolor="#F0F0F0">
            <td align="center"><b>&nbsp;姓名</b> </td>
            <td align="center"><b>&nbsp;用户名</b> </td>
            <td align="center"><b>&nbsp;省份</b> </td>
            <td align="center"><b>&nbsp;身份证 </b> </td>
          </tr>
            <tr>
              <td align="center" bgcolor="#FFFFFF"> 123</td>
              <td align="center" bgcolor="#FFFFFF"> 小米</td>
              <td align="center" bgcolor="#FFFFFF"> 黑龙江</td>
              <td align="center" bgcolor="#FFFFFF"> 232101198412003431</td>
             </tr>
           
          </c:if>
        </table>
      </td>
    </tr>	
    </tbody>
</table>	
</center>
</body>
</html>

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值