Map<String, Method> fieldSetConvertMap = new HashMap<String, Method>();
// 循环读取所有字段
for (int i = 0; i < filed.length; i++) {
Field f = filed[i];
// 得到单个字段上的Annotation
Excel excel = f.getAnnotation(Excel.class);
// 如果标识了Annotationd的话
if (excel != null) {
// 构造设置了Annotation的字段的Setter方法
String fieldname = f.getName();
String setMethodName = "set" + fieldname.substring(0, 1).toUpperCase() + fieldname.substring(1);
// 构造调用的method,
Method setMethod = pojoClass.getMethod(setMethodName, new Class[] { f.getType() });
// 将这个method以Annotaion的名字为key来存入。
// 对于重名将导致 覆盖 失败,对于此处的限制需要
fieldSetMap.put(excel.exportName(), setMethod);
if (excel.importConvertSign() == 1) {
//----------------------------------------------------------------
//update-begin--Author:Quainty Date:20130524 for:[8]excel导出时间问题
// 用get/setXxxxConvert方法名的话, 由于直接使用了数据库绑定的Entity对象,注入会有冲突
StringBuffer setConvertMethodName = new StringBuffer("convertSet");
setConvertMethodName.append(fieldname.substring(0, 1).toUpperCase());
setConvertMethodName.append(fieldname.substring(1));
//update-end--Author:Quainty Date:20130524 for:[8]excel导出时间问题
//----------------------------------------------------------------
Method getConvertMethod = pojoClass.getMethod(setConvertMethodName.toString(), new Class[] { String.class });
fieldSetConvertMap.put(excel.exportName(), getConvertMethod);
}
}
}
// 将传入的File构造为FileInputStream;
// // 得到工作表