首页>代码>java servlet页面表格导出Excel(csv格式和xls格式都可以)>/Dom2Table/src/com/zhangjun/edu/exportExcel/DownloadServlet.java
package com.zhangjun.edu.exportExcel;

import java.io.IOException;
import java.util.Date;
import java.util.Hashtable;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.w3c.dom.Document;
/**
 * <p>Description:下载生成EXCEL入口</p>
 * @author 张军
 * @version 1.0
 * @date 2012-10-02
 */
@SuppressWarnings("serial")
public class DownloadServlet extends HttpServlet {

	
	@SuppressWarnings("unchecked")
	public void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		request.setCharacterEncoding("gbk");
		response.setContentType("text/html;charset=gbk");
		HttpSession session = request.getSession();
		String status  = request.getParameter("status");
		status = status == null ? "" : status.trim(); 
		Document dom = null;
		dom = (Document)session.getAttribute("domList");
		session.setAttribute("download",dom);
		session.setAttribute("sname","download");
		Hashtable hsjxl=new Hashtable();
	    hsjxl.put("title",new Date().getTime()); 
	    session.setAttribute("header",hsjxl); 
		session.setAttribute("para","header");
		response.sendRedirect(request.getContextPath()+"/Dom2Csv");	
	}
}
最近下载更多
一直都会顺利的小吴  LV5 2022年2月16日
无名氏111  LV32 2021年9月14日
缘------  LV9 2021年6月28日
能不能不存在  LV13 2021年1月15日
amour1  LV11 2020年12月13日
EdgarLi  LV14 2020年8月6日
soscat2000  LV3 2020年7月6日
谁打我多多  LV6 2020年6月10日
yezhi123  LV4 2020年5月28日
sunlea  LV17 2020年4月26日
最近浏览更多
cz8857216  LV4 3月8日
fesfefe  LV13 1月26日
uni-code_0123  LV1 2023年11月11日
EFWAGGFAWGR 2023年10月19日
暂无贡献等级
微信网友_6467077197238272  LV1 2023年5月8日
lironggang  LV38 2023年3月28日
zjc010726 2023年3月15日
暂无贡献等级
qwqw900619  LV4 2022年7月16日
nbzhou2013  LV14 2022年4月4日
一直都会顺利的小吴  LV5 2022年2月16日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友