WritableWorkbook workBook = null;
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("application/vnd.ms-excel");
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
String excelName = "yuyueliebiao" + format.format(new Date());
response.setHeader("Content-Disposition", "attachment; filename=\"" + excelName + ".xls\"");
response.setHeader("Cache-Control", "private");
response.setHeader("Pragma", "");
workBook = Workbook.createWorkbook(response.getOutputStream());
WritableSheet sheet = workBook.createSheet("sheet", 0);
Label label;
for (int i = 0; i < infs.size(); i++) {
HashMap inf = (HashMap) infs.get(i);
int j = 0;
label = new Label(j++, i, (String) inf.get("djlx"));
sheet.addCell(label);
label = new Label(j++, i, (String) inf.get("zch"));
sheet.addCell(label);
label = new Label(j++, i, (String) inf.get("qylx"));
sheet.addCell(label);
label = new Label(j++, i, (String) inf.get("qymc"));
sheet.addCell(label);
label = new Label(j++, i, (String) inf.get("yyrq"));
sheet.addCell(label);
label = new Label(j++, i, (String) inf.get("sqr"));
sheet.addCell(label);
label = new Label(j++, i, (String) inf.get("djjg"));
sheet.addCell(label);
}
workBook.write();
response.getOutputStream().flush();
response.getOutputStream().close();