您的位置:首页 > Web前端 > JavaScript

利用jsp生成excel格式文件

2011-08-02 11:50 302 查看
<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="/WEB-INF/tlds/test.tld" prefix="pig"%>
<%@ page language="java" import="org.etone.fs.market.bean.movie.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  <html>
      <head>
      
        <title>Excel文档</title>
        
      </head>
      <meta http-equiv=Content-Type content="text/html; charset=GB2312">
      <meta name=ProgId content=Excel.Sheet>
      <meta name=Generator content="Microsoft Excel 9">
      <meta http-equiv=Content-Type content="text/html; charset=GB2312">
      <%response.setHeader("Content-disposition","attachment;filename=surveywlan_exportData.xls");%>
      <body>
           <table id="list" width="100%" cellpadding="0" cellspacing="1" class="dg_borderstyle" border="1">
                   	  <tr>
		               <th width="10%" style="background-color:#9FBFE3"><div align="center">记录日期</div></th>
		                <th width="10%" style="background-color:#9FBFE3"><div align="center">热点类型</div></th>
		               <th width="13%" style="background-color:#9FBFE3"><div align="center">上网类型</div></th>
		                <th width="12%" style="background-color:#9FBFE3"><div align="center">手机号码</div></th>
		                <th width="12%" style="background-color:#9FBFE3"><div align="center">地址建议</div></th>			                
		              </tr>
		           <s:iterator value="exportSurveyList" id="dto" status="sta">
	                      <tr  onMouseOver="MOver(this)" onMouseOut="Mout(this)" class="dg_alternatingitemstyle">	                        
	                        <td align="center" class="f">
	                        	${dto.recmakedate}
	                        </td>
	                        <td align="center" class="f">
	                        	${dto.type}
	                        </td>
	                        <td align="center" class="f">
	                        	${dto.onlinetype}
	                        </td>
	                        <td align="center" class="f">
	                        	${dto.mobileno}
	                        </td>
	                        <td align="center" class="f">
	                        	${dto.address}
	                        </td>  
	                      </tr>
                  	  </s:iterator>
      </table>
      </body>
    </html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: