在JavaWeb中Excel文件如何使用POI实现导出-创新互联

在Java Web中Excel文件如何使用POI实现导出?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

成都创新互联长期为千余家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为玄武企业提供专业的成都网站制作、做网站,玄武网站改版等技术服务。拥有十年丰富建站经验和众多成功案例,为您定制开发。

采用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。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都定制网站网页设计