EasyExcel 使用

同步读

java 复制代码
String fileName = "C:\\Users\\31094\\Desktop\\副本电压电流曲线.xlsx";
List<IndexOrNameData> list = EasyExcel.read(fileName)
        .head(IndexOrNameData.class)
        .sheet(0)
        .headRowNumber(0) // 第0行就是数据
        // 添加时间转换器
        .registerConverter(new Converter<LocalDateTime>() {
            @Override
            public Class<?> supportJavaTypeKey() {
                return LocalDateTime.class;
            }

            // 遇到String 可以进行转换
            @Override
            public CellDataTypeEnum supportExcelTypeKey() {
                return CellDataTypeEnum.STRING;
            }
            // 转换的目标对象是 LocalDateTime
            @Override
            public LocalDateTime convertToJavaData(ReadCellData<?> cellData,
                                                   ExcelContentProperty contentProperty,
                                                   GlobalConfiguration globalConfiguration) {
                String stringValue = cellData.getStringValue();
                DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-M-d HH:mm");
                return LocalDateTime.parse(stringValue, dateTimeFormatter);
            }
        }).doReadSync();
相关推荐
编码忘我6 分钟前
java多线程安全集合
java
悟空码字11 分钟前
滑块拼图验证:SpringBoot完整实现+轨迹验证+Redis分布式方案
java·spring boot·后端
编码忘我12 分钟前
java类加载器及tomcat为什么不用双亲委派
java
MegaDataFlowers1 小时前
快速上手Spring
java·后端·spring
小江的记录本1 小时前
【MyBatis-Plus】Spring Boot + MyBatis-Plus 进行各种数据库操作(附完整 CRUD 项目代码示例)
java·前端·数据库·spring boot·后端·sql·mybatis
左左右右左右摇晃1 小时前
Java 笔记--OOM产生原因以及解决方法
java·笔记
大傻^1 小时前
Spring AI Alibaba Function Calling:外部工具集成与业务函数注册
java·人工智能·后端·spring·springai·springaialibaba
傻啦嘿哟1 小时前
Python 操作 Excel 条件格式指南
开发语言·python·excel
逆境不可逃1 小时前
LeetCode 热题 100 之 33. 搜索旋转排序数组 153. 寻找旋转排序数组中的最小值 4. 寻找两个正序数组的中位数
java·开发语言·数据结构·算法·leetcode·职场和发展
码界奇点1 小时前
基于Spring Boot的医院药品管理系统设计与实现
java·spring boot·后端·车载系统·毕业设计·源代码管理