我是靠谱客的博主 虚心小蘑菇,这篇文章主要介绍java easyExcel导出多个sheet页java easyExcel导出多个sheet页,现在分享给大家,希望可以做个参考。

java easyExcel导出多个sheet页

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
public void export(StudentVO studentVO, PageQuery query, HttpServletResponse response){ // 先查询要导出的页面,这里就查询导出两个sheet IPage<StudentVO> pageOne = studentService .selectExportPageOne(Condition.getPage(query), studentVO); // 第二个 IPage<StudentVO> pageTwo = studentService .selectExportPageTwo(Condition.getPage(query), studentVO); // 用StudentWrapper中的listExcel()方法将每个数据赋给StudentOneExcel,StudentTwoExcel // 存在map中 Map<String, List<? extends Serializable>> data = new HashMap<>(); data.put ("sheetOne", StudentWrapper.build().listOneExcel(pageOne.getRecords())); data.put ("sheetTow", StudentWrapper.build().listTwoExcel(pageTwo.getRecords())); // 再用map存要导出的class Map<String, Class<?>> classes = new HashMap<>(); classes.put("sheetOne", StudentOneExcel.class); classes.put("sheetTow", OrderTwoExcel.class); // 组合后导出 new MultiExcelUtil(data, classes, "学生信息").download(response); }
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
public class StudentWrapper extends BaseEntityWrapper<Student, StudentVO> { public static StudentWrapper build() { return new StudentWrapper(); } public List<StudentOneExcel> listOneExcel(List<StudentVO> list) { return list.stream().map(one -> BeanUtil.copy(one, StudentOneExcel.class)) .collect(Collectors.toList()); } public List<StudentTwoExcel> listTwoExcel(List<StudentVO> list) { return list.stream().map(two -> BeanUtil.copy(two, StudentTwoExcel.class)) .collect(Collectors.toList()); } }
复制代码
1
2
3
4
5
6
7
public class StudentOneExcel implements Serializable { private static final long serialVersionUID = 1L; @ExcelProperty(value = "名字") @ColumnWidth(30) private String name;

最后

以上就是虚心小蘑菇最近收集整理的关于java easyExcel导出多个sheet页java easyExcel导出多个sheet页的全部内容,更多相关java内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(86)

评论列表共有 0 条评论

立即
投稿
返回
顶部