进度条的实现
<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%>
<%@page import="java.io.File"%>
<%@ include file="initTable.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>Insert title here</title>
</head>
<body>
<%
//String deptid =request.getParameter("deptID");
//String date=request.getParameter("date").trim();
//int deptID =Integer.parseInt(deptid.trim());
//response.setContentType("application/vnd.ms-excel");
//String fileName ="财分数据统计报表.xls";
//fileName = new String(fileName.getBytes("GBK"), "ISO8859-1");
//response.setHeader("Content-disposition", "attachment;filename= "+fileName );
String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
String []time_temp=today.split("-");
int year =Integer.parseInt(time_temp[0].trim());
int month=Integer.parseInt(time_temp[1].trim());
int day =Integer.parseInt(time_temp[2].trim());
String root ="E:\\KingTop2.0\\财务报表\\";
String path =year+"年\\"+month+"月\\"+day+"日\\"+"财分表\\";
File directory= new File(root+path);
if(!directory.exists()){
directory.mkdirs();
}
List<Integer> depts= new ArrayList<Integer>();
depts.add(175);
depts.add(179);
depts.add(180);
depts.add(181);
depts.add(182);
depts.add(186);
depts.add(184);
out.print(" <table style='margin:200px 0px 300px 0px;width: 660px;height:50px;border-collapse:collapse'>");
out.print(" <tr >");
out.print(" <td colspan='2' style='text-align: center'><h2>正在生成报表请稍后</h2></td>");
out.print(" </tr>");
out.print(" <tr>");
out.print(" <td style='border :1px solid red;width:20px;background-color:green;height:20px'> </td>");
out.print(" <td style='height:20px;border-right:1px solid red;border-bottom:1px solid red;border-top:1px solid red;width:640px'> </td>");
out.print(" </tr>");
out.print(" </table>");
out.print("<script>");
out.print("window.onload=setInterval('a()',10);");
out.print(" var radio=0;;var width=0;var size=0;function a(){ var inputs =document.getElementsByTagName('input');if(inputs.length>0){ size=inputs[0].value;window.setInterval('b()',10);}}");
out.print("function b(){ var inputs =document.getElementsByTagName('input');" );
out.print(" radio=660/size;width=radio*(inputs.length-1);var td1=document.getElementsByTagName('td')[1];");
out.print(" var td2=document.getElementsByTagName('td')[2];");
out.print("");
out.print("td1.style.width=width+'px';");
out.print("td2.style.width=(660-width)+'px' ;");
out.print("if(inputs.length==(parseInt(size)+1)){window.opener.location.reload();confirm('successful');window.close();window.clearInterval();}}");
out.print("</script>");
out.flush();
out.flush();
out.print("<input type='hidden' value="+depts.size()+" /> ");
for(Integer deptID:depts){
HSSFWorkbook book =new HSSFWorkbook();
String deptName= getWorkBookBySaleMan(book, "业务员",deptID,today);
getWorkBookByDep(book, "部门统计",deptID,today);
FileOutputStream ofw =new FileOutputStream(new File(directory.getPath()+"/"+today+"_"+deptName+"_财分表.xls"));
book.write(ofw);
ofw.close();
out.print("<input type='hidden'/> ");
out.flush();
}
//ServletOutputStream ofw =response.getOutputStream();
// book.write(ofw);
// ofw.close();
// out.clear();
// out = pageContext.pushBody();
%>
</body>
</html>