Java org.apache.poi.ss.usermodel.Cell.getCellType()Lorg/apache/poi/ss/usermodel/CellType问题解决

问题描述:

org.springframework.web.util.NestedServletException: Handler dispatch failed;

nested exception is java.lang.NoSuchMethodError: org.apache.poi.ss.usermodel.Cell.getCellType()Lorg/apache/poi/ss/usermodel/CellType;

问题分析:

1、使用Hutool工具包的ExcelReader.read()方法报错,因为poi3.17版本的Cell.getCellType()返回int而不是org.apache.poi.ss.usermodel.CellType。

    public List<List<Object>> readData(MultipartFile file) {
        List<List<Object>> resultList = new ArrayList<>();
        try {
            //读取数据
            ExcelReader reader = ExcelUtil.getReader(file.getInputStream());
            resultList = reader.read();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return resultList;
    }

解决办法:

加入Poi4.0.0依赖即可。

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>4.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>4.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
            <version>4.0.0</version>
        </dependency>

旭东怪的个人空间-旭东怪个人主页-哔哩哔哩视频哔哩哔哩旭东怪的个人空间,提供旭东怪分享的视频、音频、文章、动态、收藏等内容,关注旭东怪账号,第一时间了解UP注动态。人生低谷不可怕,可怕的是坚持不到人生转折点的那一天https://space.bilibili.com/484264966?spm_id_from=333.1007.0.0

  • 17
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值