⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 download.jsp

📁 java高级引用管理综合朝鲜经java高级引用管理综合朝鲜经java高级引用管理综合朝鲜经java高级引用管理综合朝鲜经
💻 JSP
字号:
<%@ page language="java" import="java.util.*,java.io.OutputStream,com.model.*"
	pageEncoding="gbk"%>
<%@ page
	import="jxl.*,jxl.format.Alignment,jxl.write.*,jxl.format.VerticalAlignment,jxl.write.WritableCellFormat"%>
<%
	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>
		<base href="<%=basePath%>">

		<title>My JSP 'download.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

	</head>

	<body>
		<%
		   java.text.Format format = new java.text.SimpleDateFormat("yyyy-MM-dd");
			List<PersonAsses> list = (List) session.getAttribute("datas");
			out.println(list.size());
			OutputStream os = response.getOutputStream();//取得输出流		    		    
			response.reset();//清空输出流
			response.setHeader("Content-disposition", "attachment; filename="
					+ new String("数据信息.xls".getBytes(), "iso-8859-1"));//设定输出文件头
			response.setContentType("application/msexcel");

			jxl.write.WritableWorkbook workbook = Workbook.createWorkbook(os); //建立excel文件
			WritableSheet sheet1 = workbook.createSheet("sheet1", 0);//创建sheet
	
			sheet1.setColumnView(0, 15);
			sheet1.setColumnView(1, 10);
			sheet1.setColumnView(2, 15);
			sheet1.setColumnView(3, 40);


			WritableCellFormat totalx2Format = new WritableCellFormat();

			totalx2Format.setVerticalAlignment(VerticalAlignment.CENTRE); //垂直居中 
			totalx2Format.setAlignment(Alignment.CENTRE);//水平居中
			sheet1.addCell(new jxl.write.Label(0, 0, "姓名", totalx2Format));
			sheet1.addCell(new jxl.write.Label(1, 0, "加减分",totalx2Format));
			sheet1.addCell(new jxl.write.Label(2, 0, "考核人", totalx2Format));
			sheet1.addCell(new jxl.write.Label(3, 0, "考核日期", totalx2Format));
             int i=1;
             for(PersonAsses data:list){
              sheet1.addCell(new jxl.write.Label(0,  i,data.getPerson_name(),totalx2Format));
		      sheet1.addCell(new jxl.write.Label(1,  i, data.getSs_point(),totalx2Format));
		      sheet1.addCell(new jxl.write.Label(2,  i, data.getAsses_person(),totalx2Format));
		      sheet1.addCell(new jxl.write.Label(3,  i, format.format(data.getAsses_date()),totalx2Format));
		      i++;
             }
			workbook.write();
			workbook.close();
			os.close();
		%>
		<br>
	</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -