java直接输出Excel 页面实现下载
2015-04-22 14:57
477 查看
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类实现)
- WEB页面同时实现两种打印(下载Excel,页面直接打印)
- Java导出页面数据或数据库数据至Excel文件并下载,采用JXL技术,小demo(servlet实现)
- java导出Excel文件,直接可以下载,然后更新状态,刷新页面
- Java通用的Excel文件生成工具类,支持生成文件和浏览器直接下载
- Java通用的Excel文件生成工具类,支持生成文件和浏览器直接下载(未测试)
- Java用webSocket实现tomcat的日志实时输出到web页面
- Java 实现将日志输出到文件并下载日志文件
- 在java中生成二维码,并直接输出到jsp页面
- java输出流实现文件下载
- JAVA 实现下载功能 保存为EXCEL格式
- java 使用POI输出Excel时打印页面的设置
- Java POI导出EXCEL经典实现 Java导出Excel弹出下载框
- 在java中生成二维码,并直接输出到jsp页面
- WEB实现Excel下载的一种方式--JAVA EXCEL
- JAVA中的FtpClient与FTPClient,并实现jsp页面下载ftp服务器上的文件
- java 实现Gzip 压缩字符及字节流输出到页面显示
- Java POI 导出EXCEL经典实现 Java导出Excel弹出下载框 【不定期更新】
- java和Android文件下载断点续传和图片下载代码实现,可直接复制简单实现