海云 2020-11-13 12:58 采纳率: 0%
浏览 311

easyexcel报错,jdk1.8

easyexcel报错:java.lang.ExceptionInInitializerError,java.lang.IllegalArgumentExcep
代码:
[code=java]public static List<User> data(){
        List<User> list = new ArrayList<User>() ;
         
        for(int i = 1 ; i< 11 ;i ++){
            User user = new User() ;
            user.setUid("100"+i);
            user.setName("name_"+i);
            user.setAge(10 + i);
            user.setAddress("address_"+ i);
            list.add(user) ;
        }
        return list ;
    }
    
    public static void main(String[] args) {
        String fileName = "d:/101.xlsx" ;
        EasyExcel.write(fileName, User.class).sheet("模板").doWrite(data());
    }[/code]

User类:
[code=java]public class User {
 
    /**
     * value-->表头 index-->列(从0开始)
     */
    @ExcelProperty(index = 0, value = "序号")
    private String uid;
 
    @ExcelProperty(index = 1, value = "姓名")
    private String name;
 
    @ExcelProperty(index = 2, value = "年龄")
    private Integer age;
 
    @ExcelProperty(index = 3, value = "地址")
    private String address;
 
    // converter 格式转换类
    @ExcelProperty(index = 4, value = "日期")
    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.address = address;
    }
 
    public String getUid() {
        return uid;
    }
 
    public void setUid(String uid) {
        this.uid = uid;
    }
 
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public Integer getAge() {
        return age;
    }
 
    public void setAge(Integer age) {
        this.age = age;
    }
 
    public String getAddress() {
        return address;
    }
 
    public void setAddress(String address) {
        this.address = address;
    }
 
    public Date getBirthday() {
        return birthday;
    }
 
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
 
    @Override
    public String toString() {
        return "User [name=" + name + ", uid=" + uid + ", address=" + address + ", age=" + age + ", birthday="
                + birthday + "]";
    }
 
}[/code]

报错:
[img=https://img-bbs.csdn.net/upload/202011/13/1605243366_922152.png][/img]

  • 写回答

5条回答 默认 最新

  • 真-酸辣土豆丝 2020-11-13 15:46
    关注

    详细错误呢?报错在哪一行

    评论

报告相同问题?

悬赏问题

  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?