| | |
| | | import cn.idev.excel.metadata.data.WriteCellData; |
| | | import cn.idev.excel.metadata.property.ExcelContentProperty; |
| | | import com.panzhihua.sangeshenbian.annotation.FastExcel; |
| | | import com.panzhihua.sangeshenbian.annotation.TargetEnum; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.Method; |
| | |
| | | //获取字段属性中的注解 |
| | | Field field = contentProperty.getField(); |
| | | //获取该字段所属枚举 |
| | | FastExcel fastExcel = field.getAnnotation(FastExcel.class); |
| | | TargetEnum targetEnum = field.getAnnotation(TargetEnum.class); |
| | | //获取注解中的枚举信息 |
| | | Class<? extends Enum> type = fastExcel.type(); |
| | | Class<? extends Enum> type = targetEnum.type(); |
| | | //获取枚举类的方法名 “getEnumByCode”就是自己编写的函数,Integer.class 指定入参类型 |
| | | Method codeOf = type.getMethod("getEnumByCode", Integer.class); |
| | | //反射执行方法,此方法得到的是一个枚举实例(具体得到什么,结合自身项目) |