<%@ page import="java.io.*"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.net.URLEncoder"%>
	<%
		response.setBufferSize(2048);
		response.setCharacterEncoding("utf-8");
		//response.setContentType("application/ms-excel;charset=utf-8");
		response.setHeader("pragma", "no-cache");
		//  response.reset();
		response.setContentType("application/octet-stream;charset=utf8");
		SimpleDateFormat timeFormat = new SimpleDateFormat("yyyyMMddHHmmss");
		String filename = timeFormat.format(new Date());
		String diyname = new String(request.getParameter("txtName")
				.getBytes("ISO-8859-1"), "utf-8");

		//System.out.println(new String(request.getParameter("txtContent").getBytes(
		//	"ISO-8859-1"), "utf-8"));
		response.addHeader("content-disposition", "attachment;filename="
				+ String.valueOf(URLEncoder.encode(diyname, "utf-8"))
				+ filename + ".xls");
		
		PrintWriter a;
		a = response.getWriter();
		a.write("<html>\n<head>\n");
		a.write("<style type=\"text/css\">\n.pb{font-size:13px;border-collapse:collapse;} "
				+ "\n.pb th{font-weight:bold;text-align:center;border:0.5pt solid windowtext;padding:2px;} "
				+ "\n.pb td{border:0.5pt solid windowtext;padding:2px;}\n</style>\n</head>\n");
		a.write("<body>\n"
				+ new String(request.getParameter("txtContent").getBytes(
						"ISO-8859-1"), "utf-8") + "\n</body>\n</html>");
		a.flush();
		a.close();		

		/*
		 SimpleDateFormat timeFormat = new SimpleDateFormat("yyyyMMddHHmmss");  
		 String filename = timeFormat.format(new Date())+".xls";  
		 response.setContentType("application/ms-excel;charset=UTF-8");  
		 response.setHeader("Content-Disposition", "attachment;filename="  
		 .concat(String.valueOf(URLEncoder.encode(filename, "UTF-8"))));  
		 OutputStream out = response.getOutputStream();  
		 ex.exportExcel(hearders, dataset, out);  
		 out.close();  
		 */
	%>
