PageBean p) {
List list =queryGrxxList(grxx, p);
try {
// String targetfile =getServlet().getServletContext().getRealPath(
// "/companymanage")
// + "/grxxlistxls.xls";
// Method 1:创建可写入的Excel工作薄
// jxl.write.WritableWorkbook wwb =Workbook.createWorkbook(new
// File(
// targetfile));
// Method 2:将WritableWorkbook直接写入到输出流
OutputStream os = response.getOutputStream();
String fs = "个人信息表";
fs = new String(fs.getBytes("gb2312"), "iso8859-1");
response.reset();// 清空输出流
response.setContentType("application/msexcel");// 定义输出类型
response.setHeader("Content-disposition", "attachment;filename="
+ fs + ".xls");// 设定输出文件头
jxl.write.WritableWorkbook wwb = Workbook.createWorkbook(os);
// 创建Excel工作表
jxl.write.WritableSheet ws = wwb.createSheet("个人信息表1", 0);
int charTitle = 10;// 标题字体大小
int charNormal = 10;// 标题字体大小
// 添加带有字型Formatting的对象
// 用于标题
jxl.write.WritableFont titleFont = newjxl.write.WritableFont(
WritableFont.createFont("宋体"), charTitle, WritableFont.BOLD);
jxl.write.WritableCellFormat titleFormat = newjxl.write.WritableCellFormat(
titleFont);
titleFormat.setBorder(Border.ALL, BorderLineStyle.THIN); //线条
titleFormat.setVerticalAlignment(VerticalAlignment.CENTRE); //垂直对齐
titleFormat.setAlignment(Alignment.CENTRE); // 水平对齐
titleFormat.setWrap(true); // 是否换行
titleFormat.setBackground(Colour.GRAY_25);// 背景色暗灰-25%
// 用于正文
WritableFont normalFont = new WritableFont(WritableFont
.createFont("宋体"), charNormal);
jxl.write.WritableCellFormat normalFormat = newjxl.write.WritableCellFormat(
normalFont);
normalFormat.setBorder(Border.ALL, BorderLineStyle.THIN); //线条
normalFormat.setVerticalAlignment(VerticalAlignment.CENTRE); //垂直对齐
normalFormat.setAlignment(Alignment.CENTRE);// 水平对齐
normalFormat.setWrap(true); // 是否换行
// 用于带有formatting的Number对象
WritableFont nf = new WritableFont(WritableFont
.createFont("Times New Roman"), charNormal);
// jxl.write.NumberFormat nf = newjxl.write.NumberFormat("#.##");
jxl.write.WritableCellFormat wcfN = newjxl.write.WritableCellFormat(
nf);
wcfN.setBorder(Border.ALL, BorderLineStyle.THIN); // 线条
wcfN.setVerticalAlignment(VerticalAlignment.CENTRE); // 垂直对齐
wcfN.setAlignment(Alignment.CENTRE);// 水平对齐
wcfN.setWrap(true); // 是否换行
// 第一行
ws.mergeCells(14, 0, 18, 0); // 合并单元格,
ws.mergeCells(10, 0, 13, 0); // 合并单元格,
ws.mergeCells(0, 0, 0, 1); // 合并单元格,序号
ws.setColumnView(0, 6); // 设置列宽,第1列
ws.mergeCells(1, 0, 1, 1); // 合并单元格,公民身份证号
ws.setColumnView(1, 9); // 设置列宽,第2列
ws.mergeCells(2, 0, 2, 1); // 合并单元格,电脑序号
ws.setColumnView(2, 6); // 设置列宽,第3列
ws.mergeCells(3, 0, 3, 1); // 合并单元格,四险姓名
ws.setColumnView(3, 6); // 设置列宽,第4列
ws.mergeCells(4, 0, 4, 1); // 合并单元格,医疗姓名
ws.setColumnView(4, 6); // 设置列宽,第5列
ws.mergeCells(5, 0, 5, 1); // 合并单元格,医疗保险手册号
ws.setColumnView(5, 9); // 设置列宽,第6列
ws.mergeCells(6, 0, 6, 1); // 合并单元格,四险缴费人员类别
ws.setColumnView(6, 9); // 设置列宽,第7列
ws.mergeCells(7, 0, 7, 1); // 合并单元格,医疗缴费人员类别
ws.setColumnView(7, 9); // 设置列宽,第8列
ws.mergeCells(8, 0, 8, 1); // 合并单元格,医疗参保人员类别
ws.setColumnView(8, 9); // 设置列宽,第9列
ws.mergeCells(9, 0, 9, 1); // 合并单元格,医疗参保状态
ws.setColumnView(9, 7); // 设置列宽,第10列
ws.setColumnView(10, 6); // 设置列宽,第11列
ws.setColumnView(11, 6); // 设置列宽,第12列
ws.setColumnView(12, 6); // 设置列宽,第13列
ws.setColumnView(13, 6); // 设置列宽,第14列
ws.setColumnView(14, 6); // 设置列宽,第15列
ws.setColumnView(15, 6); // 设置列宽,第16列
ws.setColumnView(16, 6); // 设置列宽,第17列
ws.setColumnView(17, 6); // 设置列宽,第18列
ws.setColumnView(18, 6); // 设置列宽,第19列
jxl.write.Label tit00 = new jxl.write.Label(0, 0, "序号",titleFormat);
ws.addCell(tit00);
jxl.write.Label tit10 = new jxl.write.Label(1, 0, "公民身份证号",
titleFormat);
ws.addCell(tit10);
jxl.write.Label tit20 = new jxl.write.Label(2, 0, "电脑序号",
titleFormat);
ws.addCell(tit20);
jxl.write.Label tit30 = new jxl.write.Label(3, 0, "四险姓名",
titleFormat);