由于公司业务需求,需要批量导出Excel到Zip中,导出Excel使用的技术是Jxls
在此不做jxls的讲解,如有需要看大神的专业讲解:https://www.cnblogs.com/foxlee1024/p/7616987.html
附上一个小型Demo:
明确一件事情:response目前主要是输出zip的内容
@GetMapping(value = "/export/purchaseOrders")
public void purchaseAcceptExports(HttpServletRequest request,
HttpServletResponse response) {
List<User> list = new ArrayList<>();
list.add(new User(1L,"张三","123456"));
list.add(new User(2L,"李四","123456"));
list.add(new User(3L,"王五","123456"));
list.add(new User(4L,"赵六","123456"));
try (ServletOutputStream bos = response.getOutputStream();
//定义个zip输出流
ZipOutputStream zos