Open yilan0916 opened 2 years ago
package com.zk.dto;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.format.DateTimeFormat; import com.alibaba.excel.annotation.format.NumberFormat;
import java.util.Date;
/**
@ExcelProperty: 这个注解的作用是描述设置Excel表格的头(起名字) */ public class User {
@ExcelProperty(value = "用户编号", index = 0) private Integer userId; @ExcelProperty(value = "姓名", index = 1) private String userName; @ExcelProperty(value = "性别", index = 3) private String gender; @NumberFormat("#.##") @ExcelProperty(value = "工资", index = 2) private Double salary; @DateTimeFormat("yyyy年MM月dd日") @ExcelProperty(value = "入职时间", index = 4) private Date hireDate;
public User() { }
public User(Integer userId, String userName, String gender, Double salary, Date hireDate) { this.userId = userId; this.userName = userName; this.gender = gender; this.salary = salary; this.hireDate = hireDate; } public User(Integer userId) { this.userId = userId; }
public Integer getUserId() { return userId; }
public void setUserId(Integer userId) { this.userId = userId; }
public String getUserName() { return userName; }
public void setUserName(String userName) { this.userName = userName; }
public String getGender() { return gender; }
public void setGender(String gender) { this.gender = gender; }
public Double getSalary() { return salary; }
public void setSalary(Double salary) { this.salary = salary; }
public Date getHireDate() { return hireDate; }
public void setHireDate(Date hireDate) { this.hireDate = hireDate; }
@Override public String toString() { return "User{" + "userId=" + userId + ", userName='" + userName + '\'' + ", gender='" + gender + '\'' + ", salary=" + salary + ", hireDate=" + hireDate + '}'; } }
public class WriteTest {