easyexcel导入时读不到数据_EasyExcel简单使用--导入excel数据

读Excel

1、依赖包

com.alibaba

easyexcel

2.0.5

2、代码import java.io.File;

import com.alibaba.excel.EasyExcel;

public class Demo7 {

public static void main(String[] args) {

String fileName = "D:" + File.separator + "001.xlsx";

// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭

EasyExcel.read(fileName, User.class, new UserListener()).sheet().doRead();

//EasyExcel.read(InputStream in, User.class, new UserListener()).sheet().doRead();

}

}

3、实体类import java.util.Date;

import com.alibaba.excel.annotation.ExcelProperty;

/**

*/

/**

* @author Martin

* @Date 2019年11月1日 下午11:36:58

* @Desc

*/

public class User {

/**

* value-->表头 index-->列(从0开始)

*/

@ExcelProperty(index = 0)

private String uid;

@ExcelProperty(index = 1, value = "姓名")

private String name;

@ExcelProperty(index = 2)

private Integer age;

@ExcelProperty(index = 3)

private String address;

// converter 格式转换类

@ExcelProperty(index = 4, converter = DateStringConverter.class)

private Date birthday;

public User() {

}

public User(String uid, String name, Integer age, String address) {

this.uid = uid;

this.name = name;

this.age = age;

this.addr

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值