在Java Web中Excel文件如何使用POI实现导出?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
采用Spring mvc架构:
Controller层代码如下
@Controller public class StudentExportController{ @Autowired private StudentExportService studentExportService; @RequestMapping(value = "/excel/export") public void exportExcel(HttpServletRequest request, HttpServletResponse response) throws Exception { List<Student> list = new ArrayList<Student>(); list.add(new Student(1000,"zhangsan","20")); list.add(new Student(1001,"lisi","23")); list.add(new Student(1002,"wangwu","25")); HSSFWorkbook wb = studentExportService.export(list); response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-disposition", "attachment;filename=student.xls"); OutputStream ouputStream = response.getOutputStream(); wb.write(ouputStream); ouputStream.flush(); ouputStream.close(); } }
新闻标题:在JavaWeb中Excel文件如何使用POI实现导出-创新互联
本文网址:https://www.cdcxhl.com/article40/cedjeo.html
成都网站建设公司_创新互联,为您提供App设计、定制开发、网站导航、品牌网站设计、网站策划、虚拟主机
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联