Java - 使用 @RequestExcel 和 @ResponseExcel 注解轻松上传和下载 Excel 文件

2020-11-25 19:39:47 +08:00
 gaobing

做成了 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>

欢迎使用和 Star ^_^

GitHub: https://github.com/gaoice/easyexcel-spring-boot-starter

2553 次点击
所在节点    分享创造
7 条回复
ychost
2020-11-25 20:48:35 +08:00
赞!!
fd7917931e
2020-11-26 13:58:47 +08:00
这个不错!
shuige
2020-11-26 15:52:24 +08:00
2.0 哪里下载?
zsl199512101234
2020-11-26 16:20:42 +08:00
赞,一开始以为啥 Alibaba 的那个 easyexcel 呢
2han9wen71an
2020-11-26 16:26:31 +08:00
请问只能在 spring 上用吗?我们平常使用的 resteasy 加 guice 来开发能使用吗?
gaobing
2020-11-26 18:45:55 +08:00
uselessVisitor
2020-11-28 21:00:21 +08:00
支持

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/729234

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX