jsp将页面的响应方式改为excel

4 篇文章 0 订阅
1 篇文章 0 订阅
<%@ page language="java" contentType="application/vnd.ms-excel; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
    <!-- 将页面的响应方式改为excel -->
<%
response.setContentType("application/vnd.ms-excel");
response.addHeader("Content-Disposition", "attachment;filename=" + new String(("客户积分统计表").getBytes("gb2312"),"iso8859-1") + ".xls");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

<table width="800">  
                <tr align="center" style="font: 30px" height="40" bgcolor="red">  
                    <th colspan="6">标题</th>  
                </tr>  
                <tr height="30">  
                    <td>单元:单元值</td>  
                    <td colspan="5" ALIGN="center">单元: 单元值</td>  
                </tr>  
            </table>  
            <table border="1" width="800" style="border-collapse: collapse">  
                <tr height="35" ALIGN="center">  
                    <th width="100">单元</th>  
                    <td colspan="5"><label>&nbsp;</label>单元值</td>  
                </tr>  
                <tr height="35" ALIGN="center">  
                    <th width="100">单元</th>  
                    <td colspan="2">单元值</td>  
                    <th width="150">单元</th>  
                    <td colspan="2">单元值</td>  
                </tr>  
                <tr height="100" ALIGN="center">  
                    <th width="100">单元</th>  
                    <td ALIGN="left" colspan="5"><label>&nbsp;</label>单元值</td>  
                </tr>  
                <tr height="100" ALIGN="center">  
                    <th width="100">单元</th>  
                    <td ALIGN="left" colspan="5"><label>&nbsp;</label>单元值</td>  
                </tr>  
            </table>  

</body>
</html>

说明:

 

只需将数据传进本页面,改写table中的tr、td,相当于excel中的行列,即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值