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

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("");

 

}

你可能感兴趣的:(以流的形式将文件写入页面,直接下载)