一:注解部分
package com.jianlejun.common.msoffice.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 用于绑定实体属性、Excel列名、Excel列索引之间的关系
* @author allan
*/
@Inherited
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ColField {
public String colName() ;//列名
public String position();//列标
}
二:实体部分
package com.jianlejun.common.msoffice.test;
import java.util.Date;
import com.jianlejun.common.msoffice.annotation.ColField;
public class User {
@ColField(colName = "用户名", position = "0")
private String userName;
@ColField(colName = "年龄", position = "1")
private int age;
@ColField(colName = "地址", position = "3")
private String address;
@ColField(colName = "生日", position = "2")
private Date birthDay;
private String weight;
public User(String userName, int age, Date birthday, String address) {
this.userName = userName;
this.age = age;
this.birthDay = birthday;
this.address = address;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public int getAge() {
return age;
}
public void setAge(int 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;
}
public String getWei