爱意满满的作品展示区。
gaobing

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

  •  
  •   gaobing ·
    gaoice · Nov 25, 2020 · 3459 views
    This topic created in 2008 days ago, the information mentioned may be changed or developed.

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

    7 replies    2020-11-28 21:00:21 +08:00
    ychost
        1
    ychost  
       Nov 25, 2020
    赞!!
    fd7917931e
        2
    fd7917931e  
       Nov 26, 2020
    这个不错!
    shuige
        3
    shuige  
       Nov 26, 2020
    2.0 哪里下载?
    zsl199512101234
        4
    zsl199512101234  
       Nov 26, 2020
    赞,一开始以为啥 Alibaba 的那个 easyexcel 呢
    2han9wen71an
        5
    2han9wen71an  
       Nov 26, 2020
    请问只能在 spring 上用吗?我们平常使用的 resteasy 加 guice 来开发能使用吗?
    gaobing
        6
    gaobing  
    OP
       Nov 26, 2020
    zm8m93Q1e5otOC69
        7
    zm8m93Q1e5otOC69  
       Nov 28, 2020
    支持
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1638 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 55ms · UTC 16:26 · PVG 00:26 · LAX 09:26 · JFK 12:26
    ♥ Do have faith in what you're doing.