页面下载Excel的Zip文件:
//获取生成好的Excel文件
List<HSSFWorkbook> wbLst = ×××××××;
// 设定responseHeader
response.setHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(DateUtils.toDate(new Date(), "yyyyMMddHHmmss") + ".gz", "UTF-8"));
// 把Excel扔到ZIp中
OutputStream out = null;
try {
out = response.getOutputStream();
ZipOutputStream zip = new ZipOutputStream(out);
for (HSSFWorkbook workbook : wbLst) {
ZipEntry entry = new ZipEntry(DateUtils.getCurTime3()+ ".xls");
zip.putNextEntry(entry);
workbook.write(zip);
}
zip.flush();
zip.close();
} catch (IOException e) {
LOG.error(e.getMessage(), e);
throw new RuntimeException(e);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
}
}
}