java直接输出Excel 页面实现下载
2012-12-17 11:56
555 查看
public String excelDomnload() throws Exception{ try{ /* String path = GlobalKeys.getFunctionConfig("user_attach_save","/opt/tmp/"); RegUser ru = ((RegUserLoginInfo) request.getSession().getAttribute(GlobalKeys.REG_USER_IN_SESSION_NAME)).getRegUser(); String tmpPath = File.separator + "import" + File.separator + ru.getName() + File.separator; File targetFolder = new File(path, tmpPath);//合并两个路经 String fName = request.getParameter("fName"); */ response.setContentType("application/msexcel;"); response.setHeader("Content-Disposition", new String(("attachment;filename="+"error.xls").getBytes("GB2312"), "UTF-8")); File f = new File("d:/20121211165820140_err.xls"); //File f = new File(targetFolder.getPath()+File.separator+fName); FileInputStream in = new FileInputStream(f); byte b[] = new byte[1024]; int i = 0; ServletOutputStream out = response.getOutputStream(); while((i=in.read(b))!= -1){ out.write(b, 0, i); } out.flush(); out.close(); in.close(); }catch(Exception e){ e.printStackTrace(); } return null; }
相关文章推荐
- java直接输出Excel 页面实现下载
- jsp页面导出用jxl方式导出数据到excel表格并下载保存(第二种直接用java类实现)
- Java导出页面数据或数据库数据至Excel文件并下载,采用JXL技术,小demo(servlet实现)
- java导出Excel文件,直接可以下载,然后更新状态,刷新页面
- WEB页面同时实现两种打印(下载Excel,页面直接打印)
- Java通用的Excel文件生成工具类,支持生成文件和浏览器直接下载
- SpringMVC实现页面和java模型的数据交互以及文件上传下载和数据校验
- JAVA 实现下载功能 保存为EXCEL格式
- 在java中生成二维码,并直接输出到jsp页面
- java 实现Gzip 压缩字符及字节流输出到页面显示
- 如何通过Java实现生成excel并通过流的方式返回,提供下载!!
- Java POI 导出EXCEL经典实现 Java导出Excel弹出下载框 【不定期更新】
- jsp页面点击下载文件 java方式(服务器上带路径文件 以文件流输出)
- java实时向zip中写excel文件并通过浏览器实现下载
- Java实现前台页面下载方法
- Java 实现将日志输出到文件并下载日志文件
- Java实现读取Excel并按条件输出TXT
- JAVA通过访问页面中的URL实现Http文件下载到本地
- 在java中生成二维码,并直接输出到jsp页面
- 实现页面中excel,word,pdf下载链接,而不使用浏览器打开