以流的形式将文件写入页面,直接下载

try {

OutputStream out = response.getOutputStream();

response.reset();

response.setHeader("content-disposition",

"attachment;filename="+java.net.URLEncoder.encode(reportName,"UTF-8")+".xls");

response.setContentType("APPLICATION/msexcel");

wb.write(out);

out.close();

} catch (FileNotFoundException e) {

throw new DAOException("");

} catch (IOException e) {

throw new DAOException("");

 

}

posted @ 2015-03-10 13:36  明天-星空  阅读(499)  评论(0编辑  收藏  举报