首先pom文件的依赖导入:
<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all 对象转换--> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.8.7</version> </dependency> <!--lombok依赖pojo用的注解--> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> <version>1.18.22</version> </dependency> <!-- 列表导入导出依赖--> <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-spring-boot-starter</artifactId> <version>4.1.3</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency>
实体类:
导入导出用的实体类:
字段名称要与实体类字段名称一致。
@Excel()
合并单元格、复合表格的关键注解
@ExcelCollection()
一对多实战导出:
controller:
service:
效果:
测试一对多导入:
0条评论
点击登录参与评论