使用 @RequestExcel 和 @ResponseExcel 注解轻松上传和下载 Excel 文件
文章目录
做成了 Spring Boot Starter 的形式,方便引入使用。
下载示例,类似于 @ResponseBody :
@RequestMapping("/download")
@ResponseExcel({"name", "book.name", "book.author"})
public List<Character> download() {
return listCharacters();
} 上传示例,类似于 @RequestParam :
@RequestMapping("/upload")
@ResponseBody
public List<Character> upload(@RequestExcel(value = "excel", targetClass = Character.class,
fieldNames = {"name", "book.name", "book.author"})
List<Character> characters) {
return characters;
} 已提交至 Maven 中央仓库。
<dependency>
<groupId>com.gaoice</groupId>
<artifactId>easyexcel-spring-boot-starter</artifactId>
<version>2.0</version>
</dependency> GitHub: https://github.com/gaoice/easyexcel-spring-boot-starter

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论