把数据量大导出 放入多个excel 然后压缩成zip文件,导出

前台页面:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.pactera.com/powerweb" prefix="p"%>









	


后台action

WriteExcelToZip wetz = new WriteExcelToZip();
		Date date = new Date();
		SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
		String f = "SJDZSY-" + format.format(date);
		wetz.setResponseHeader(f, response);
		OutputStream out = null;
		try {
			out = response.getOutputStream();
			String bclientopendate = commStaffclientLogVo.getBclientopendate();
			String eclientopendate = commStaffclientLogVo.getEclientopendate();
			if (bclientopendate == null || "".equals(bclientopendate)) {
				commStaffclientLogVo.setBclientopendate("0");
				commStaffclientLogVo.setEclientopendate("99999999");
			} else {
				bclientopendate = bclientopendate.replaceAll("-", "");
				eclientopendate = eclientopendate.replaceAll("-", "");
				commStaffclientLogVo.setBclientopendate(bclientopendate);
				commStaffclientLogVo.setEclientopendate(eclientopendate);

			}
			String staffno = commStaffclientLogVo.getStaffno();
			if (staffno == null || "".equals(staffno)) {
				staffno = null;
			}
			String fundid = commStaffclientLogVo.getFundid();
			if (fundid == null || "".equals(fundid)) {
				fundid = null;
			}
			String orgid = commStaffclientLogVo.getJgjc();
			if (orgid == null || "".equals(orgid)) {
				orgid = null;
			}
			String opflag = commStaffclientLogVo.getOpflag();
			if (opflag == null || "".equals(opflag)) {
				opflag = null;
			}
			String systag = commStaffclientLogVo.getSystag();
			if (systag == null || "".equals(systag)) {
				systag = null;
			}
			List list = wetz.querySqlRun("{call commision.[dbo].p_comm_staffclient_get_export(" + commStaffclientLogVo.getBclientopendate() + "," + commStaffclientLogVo.getEclientopendate() + "," + staffno + "," + fundid + "," + orgid + "," + opflag
					+ "," + systag + ",'staffclient_fgs','" + getSessionObject().getSysUser().getUserId() + "')}", request);
			System.out.println(list.size());
			wetz.toExcel(list, request, 50000, f, out);



调用工具类。工具l类可以去我共享资源下载,谢谢


你可能感兴趣的:(java)