zoukankan      html  css  js  c++  java
  • 使用postman上传excel文件测试导入excel

    今日思语:城市的生活很快,有时学会让自己慢下来,慢慢来

    对于做一些文件上传操作时,一般我们是直接在前端页面加入类型为file的input标签,也可以使用postman来进行文件的上传测试,如下:

    postman下载地址:https://www.getpostman.com/downloads/ ,下载完之后进行安装即可。

    demo信息表.xls如下:

    此处以解析excel文件为例:

     对应后台实现,此处用easypoi处理,需要引入easypoi相关依赖:

            <!--easypoi-->
            <dependency>
                <groupId>cn.afterturn</groupId>
                <artifactId>easypoi-base</artifactId>
                <version>${easypoi.version}</version>
            </dependency>
            <dependency>
                <groupId>cn.afterturn</groupId>
                <artifactId>easypoi-annotation</artifactId>
                <version>${easypoi.version}</version>
            </dependency>
            <dependency>
                <groupId>cn.afterturn</groupId>
                <artifactId>easypoi-web</artifactId>
                <version>${easypoi.version}</version>
            </dependency>

    调用接口实现

    @RestController
    @RequestMapping("/easypoi")
    public class EasyPoiExcelController {
    
        @PostMapping("/importExcel")
        public List<BrandInfo> importExcel(@RequestParam("file") MultipartFile file) throws Exception {     
            List<BrandInfo> BrandInfos = ExcelImportUtil
                    .importExcel(file.getInputStream(), BrandInfo.class, new ImportParams());
            return BrandInfos;
        }
    }

    源码参照:easypoi实现excel导入

  • 相关阅读:
    【转】C++11优化使用emplace,emplace_back
    面试经历总结
    Hive常用函数
    股票指标
    Visual Studio Code 可以翻盘成功主要是因为什么?
    openpyxl模块操作Excel
    JavaScript(二)
    前端之CSS
    ps导出ICO格式
    Qt 所有版本官方下载地址
  • 原文地址:https://www.cnblogs.com/kingsonfu/p/11658695.html
Copyright © 2011-2022 走看看