<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import="javax.servlet.ServletOutputStream"%>
<%@page import="jxl.*"%>这个地方要下载jxl的jar包
<%@page import="jxl.write.*"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
response.setContentType("application/download");
response.setHeader("Content-Disposition","attachment;filename=totalExcel.xls");
ServletOutputStream sos = response.getOutputStream();
WritableWorkbook wwb=null;
wwb = Workbook.createWorkbook(sos);
WritableCellFormat contentFromart = new WritableCellFormat(NumberFormats.TEXT);
for(int i=1;i<4;i++)
{
WritableSheet ws = wwb.createSheet("xxsheet"+i, 0);
WritableCellFormat cellFormat=new WritableCellFormat();
cellFormat.setAlignment(jxl.format.Alignment.LEFT);
cellFormat.setWrap(true);
Label lab = new Label(0, 0, "id");
ws.addCell(lab);
lab = new Label(1, 0, "姓名",contentFromart);
ws.addCell(lab);
lab = new Label(2, 0, "性别");
ws.addCell(lab);
lab = new Label(3, 0, "年龄");
ws.addCell(lab);
lab = new Label(4, 0, "生日");
ws.addCell(lab);
lab = new Label(5, 0, "工资");
ws.addCell(lab);
lab = new Label(6, 0, "部门");
ws.addCell(lab);
lab = new Label(7, 0, "填表人");
ws.addCell(lab);
lab = new Label(8, 0, "备注");
ws.addCell(lab);
}
wwb.write();
wwb.close();
sos.flush();
sos.close();
out.clear();
out = pageContext.pushBody();
%>
</body>
</html>
pageEncoding="UTF-8"%>
<%@page import="javax.servlet.ServletOutputStream"%>
<%@page import="jxl.*"%>这个地方要下载jxl的jar包
<%@page import="jxl.write.*"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
response.setContentType("application/download");
response.setHeader("Content-Disposition","attachment;filename=totalExcel.xls");
ServletOutputStream sos = response.getOutputStream();
WritableWorkbook wwb=null;
wwb = Workbook.createWorkbook(sos);
WritableCellFormat contentFromart = new WritableCellFormat(NumberFormats.TEXT);
for(int i=1;i<4;i++)
{
WritableSheet ws = wwb.createSheet("xxsheet"+i, 0);
WritableCellFormat cellFormat=new WritableCellFormat();
cellFormat.setAlignment(jxl.format.Alignment.LEFT);
cellFormat.setWrap(true);
Label lab = new Label(0, 0, "id");
ws.addCell(lab);
lab = new Label(1, 0, "姓名",contentFromart);
ws.addCell(lab);
lab = new Label(2, 0, "性别");
ws.addCell(lab);
lab = new Label(3, 0, "年龄");
ws.addCell(lab);
lab = new Label(4, 0, "生日");
ws.addCell(lab);
lab = new Label(5, 0, "工资");
ws.addCell(lab);
lab = new Label(6, 0, "部门");
ws.addCell(lab);
lab = new Label(7, 0, "填表人");
ws.addCell(lab);
lab = new Label(8, 0, "备注");
ws.addCell(lab);
}
wwb.write();
wwb.close();
sos.flush();
sos.close();
out.clear();
out = pageContext.pushBody();
%>
</body>
</html>