做成了 Spring Boot Starter 的模式,不便引入应用。
下载示例,相似于 @ResponseBody
:
@RequestMapping("/download")@ResponseExcel({"name", "book.name", "book.author"})public List<Character> download() { return listCharacters();}
上传示例,相似于 @RequestParam
:
@RequestMapping("/upload")@ResponseBodypublic 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