org.jeecgframework.poi.excel.annotation.Excel Java Examples
The following examples show how to use
org.jeecgframework.poi.excel.annotation.Excel.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExportBase.java From easypoi with Apache License 2.0 | 6 votes |
/** * 创建导出实体对象 * * @param field * @param targetId * @param pojoClass * @param getMethods * @return * @throws Exception */ private ExcelExportEntity createExcelExportEntity(Field field, String targetId, Class<?> pojoClass, List<Method> getMethods) throws Exception { Excel excel = field.getAnnotation(Excel.class); ExcelExportEntity excelEntity = new ExcelExportEntity(); excelEntity.setType(excel.type()); getExcelField(targetId, field, excelEntity, excel, pojoClass); if (getMethods != null) { List<Method> newMethods = new ArrayList<Method>(); newMethods.addAll(getMethods); newMethods.add(excelEntity.getMethod()); excelEntity.setMethods(newMethods); } return excelEntity; }
Example #2
Source File: ExcelImportUtil.java From jeewx with Apache License 2.0 | 6 votes |
private static void getExcelField(String targetId, Field field, ExcelImportEntity excelEntity, Excel excel, Class<?> pojoClass) throws Exception { excelEntity.setName(getExcelName(excel.exportName(), targetId)); String fieldname = field.getName(); if (excel.importConvertSign() == 1||excel.imExConvert()==1) { StringBuffer getConvertMethodName = new StringBuffer("convertSet"); getConvertMethodName .append(fieldname.substring(0, 1).toUpperCase()); getConvertMethodName.append(fieldname.substring(1)); Method getConvertMethod = pojoClass.getMethod( getConvertMethodName.toString(), new Class[] {field.getType()}); excelEntity.setSetMethod(getConvertMethod); } else { excelEntity.setSetMethod(ExcelPublicUtil.getMethod(fieldname, pojoClass,field.getType())); } if(StringUtils.isEmpty(excel.importFormat())){ excelEntity.setImportFormat(excel.imExFormat()); }else{ excelEntity.setImportFormat(excel.importFormat()); } }
Example #3
Source File: ExcelImportUtil.java From jeewx with Apache License 2.0 | 6 votes |
/** * 把这个注解解析放到类型对象中 * @param targetId * @param field * @param excelEntity * @param excel * @param pojoClass * @param getMethods * @param temp * @throws Exception */ private static void addEntityToMap(String targetId, Field field, ExcelImportEntity excelEntity, Class<?> pojoClass, List<Method> getMethods, Map<String, ExcelImportEntity> temp) throws Exception { Excel excel = field.getAnnotation(Excel.class); excelEntity = new ExcelImportEntity(); excelEntity.setType(excel.exportType()); excelEntity.setSaveUrl(excel.savePath()); excelEntity.setSaveType(excel.imageType()); getExcelField(targetId, field, excelEntity, excel, pojoClass); if (getMethods != null) { List<Method> newMethods = new ArrayList<Method>(); newMethods.addAll(getMethods); newMethods.add(excelEntity.getSetMethod()); excelEntity.setSetMethods(newMethods); } temp.put(excelEntity.getName(), excelEntity); }
Example #4
Source File: ExcelExportOfTemplateUtil.java From jeewx with Apache License 2.0 | 6 votes |
/** * * @param targetId * @param field * @param excelEntity * @param excel * @param pojoClass * @throws Exception */ private static void getExcelField(String targetId, Field field, ExcelExportEntity excelEntity, Excel excel, Class<?> pojoClass) throws Exception { excelEntity.setName(getExcelName(excel.exportName(), targetId)); excelEntity.setWidth(excel.exportFieldWidth()); excelEntity.setHeight(excel.exportFieldHeight()); excelEntity.setNeedMerge(excel.needMerge()); excelEntity.setOrderNum(getCellOrder(excel.orderNum(), targetId)); excelEntity.setWrap(excel.isWrap()); excelEntity.setExportImageType(excel.imageType()); excelEntity.setType(excel.exportType()); excelEntity.setCellFormula(excel.cellFormula()); String fieldname = field.getName(); excelEntity.setGetMethod(ExcelPublicUtil .getMethod(fieldname, pojoClass)); if (excel.exportConvertSign() == 1 || excel.imExConvert() == 1) { StringBuffer getConvertMethodName = new StringBuffer("convertGet"); getConvertMethodName .append(fieldname.substring(0, 1).toUpperCase()); getConvertMethodName.append(fieldname.substring(1)); Method getConvertMethod = pojoClass.getMethod( getConvertMethodName.toString(), new Class[] {}); excelEntity.setGetMethod(getConvertMethod); } }
Example #5
Source File: ExcelPublicUtil.java From jeewx with Apache License 2.0 | 6 votes |
/** * 判断是否不要在这个excel操作中 * @param field * @param targetId * @return */ public static boolean isNotUserExcelUserThis(Field field, String targetId) { boolean boo = true; if(field.getAnnotation(ExcelIgnore.class)!=null){ boo = true; }else if(boo&&field.getAnnotation(ExcelCollection.class)!=null &&isUseInThis(field.getAnnotation(ExcelCollection.class).exportName(),targetId)){ boo = false; }else if(boo&&field.getAnnotation(Excel.class)!=null &&isUseInThis(field.getAnnotation(Excel.class).exportName(),targetId)){ boo = false; }else if(boo&&field.getAnnotation(ExcelEntity.class)!=null &&isUseInThis(field.getAnnotation(ExcelEntity.class).exportName(),targetId)){ boo = false; } return boo; }
Example #6
Source File: ExportBase.java From easypoi with Apache License 2.0 | 6 votes |
/** * 注解到导出对象的转换 * * @param targetId * @param field * @param excelEntity * @param excel * @param pojoClass * @throws Exception */ private void getExcelField(String targetId, Field field, ExcelExportEntity excelEntity, Excel excel, Class<?> pojoClass) throws Exception { excelEntity.setName(getExcelName(excel.name(), targetId)); excelEntity.setWidth(excel.width()); excelEntity.setHeight(excel.height()); excelEntity.setNeedMerge(excel.needMerge()); excelEntity.setMergeVertical(excel.mergeVertical()); excelEntity.setMergeRely(excel.mergeRely()); excelEntity.setReplace(excel.replace()); excelEntity.setOrderNum(getCellOrder(excel.orderNum(), targetId)); excelEntity.setWrap(excel.isWrap()); excelEntity.setExportImageType(excel.imageType()); excelEntity.setSuffix(excel.suffix()); excelEntity.setDatabaseFormat(excel.databaseFormat()); excelEntity.setFormat(StringUtils.isNotEmpty(excel.exportFormat()) ? excel.exportFormat() : excel.format()); excelEntity.setStatistics(excel.isStatistics()); String fieldname = field.getName(); excelEntity.setMethod(PoiPublicUtil.getMethod(fieldname, pojoClass)); }
Example #7
Source File: ImportBaseService.java From jeasypoi with Apache License 2.0 | 5 votes |
public void getExcelField(String targetId, Field field, ExcelImportEntity excelEntity, Excel excel, Class<?> pojoClass) throws Exception { excelEntity.setName(getExcelName(excel.name(), targetId)); String fieldname = field.getName(); excelEntity.setMethod(PoiPublicUtil.getMethod(fieldname, pojoClass, field.getType())); if (StringUtils.isNotEmpty(excel.importFormat())) { excelEntity.setFormat(excel.importFormat()); } else { excelEntity.setFormat(excel.format()); } }
Example #8
Source File: PoiPublicUtil.java From jeasypoi with Apache License 2.0 | 5 votes |
/** * 判断是否不要在这个excel操作中 * * @param * @param field * @param targetId * @return */ public static boolean isNotUserExcelUserThis(List<String> exclusionsList, Field field, String targetId) { boolean boo = true; if (field.getAnnotation(ExcelIgnore.class) != null) { boo = true; } else if (boo && field.getAnnotation(ExcelCollection.class) != null && isUseInThis(field.getAnnotation(ExcelCollection.class).name(), targetId) && (exclusionsList == null || !exclusionsList.contains(field.getAnnotation(ExcelCollection.class).name()))) { boo = false; } else if (boo && field.getAnnotation(Excel.class) != null && isUseInThis(field.getAnnotation(Excel.class).name(), targetId) && (exclusionsList == null || !exclusionsList.contains(field.getAnnotation(Excel.class).name()))) { boo = false; } else if (boo && field.getAnnotation(ExcelEntity.class) != null && isUseInThis(field.getAnnotation(ExcelEntity.class).name(), targetId) && (exclusionsList == null || !exclusionsList.contains(field.getAnnotation(ExcelEntity.class).name()))) { boo = false; } return boo; }
Example #9
Source File: ExportBase.java From autopoi with Apache License 2.0 | 5 votes |
/** * 创建导出实体对象 * * @param field * @param targetId * @param pojoClass * @param getMethods * @return * @throws Exception */ private ExcelExportEntity createExcelExportEntity(Field field, String targetId, Class<?> pojoClass, List<Method> getMethods) throws Exception { Excel excel = field.getAnnotation(Excel.class); ExcelExportEntity excelEntity = new ExcelExportEntity(); excelEntity.setType(excel.type()); getExcelField(targetId, field, excelEntity, excel, pojoClass); if (getMethods != null) { List<Method> newMethods = new ArrayList<Method>(); newMethods.addAll(getMethods); newMethods.add(excelEntity.getMethod()); excelEntity.setMethods(newMethods); } return excelEntity; }
Example #10
Source File: ExportBase.java From jeasypoi with Apache License 2.0 | 5 votes |
/** * 注解到导出对象的转换 * * @param targetId * @param field * @param excelEntity * @param excel * @param pojoClass * @throws Exception */ private void getExcelField(String targetId, Field field, ExcelExportEntity excelEntity, Excel excel, Class<?> pojoClass) throws Exception { excelEntity.setName(getExcelName(excel.name(), targetId)); excelEntity.setWidth(excel.width()); excelEntity.setHeight(excel.height()); excelEntity.setNeedMerge(excel.needMerge()); excelEntity.setMergeVertical(excel.mergeVertical()); excelEntity.setMergeRely(excel.mergeRely()); excelEntity.setReplace(excel.replace()); if(StringUtils.isNotEmpty(excel.dicCode())){ EasypoiDictServiceI jeecgDictService = null; try { jeecgDictService = ApplicationContextUtil.getContext().getBean(EasypoiDictServiceI.class); } catch (Exception e) { } if(jeecgDictService!=null){ String[] dictReplace = jeecgDictService.queryDict(excel.dictTable(), excel.dicCode(), excel.dicText()); if(excelEntity.getReplace()!=null && dictReplace!=null && dictReplace.length!=0){ excelEntity.setReplace(dictReplace); } } } excelEntity.setOrderNum(getCellOrder(excel.orderNum(), targetId)); excelEntity.setWrap(excel.isWrap()); excelEntity.setExportImageType(excel.imageType()); excelEntity.setSuffix(excel.suffix()); excelEntity.setDatabaseFormat(excel.databaseFormat()); excelEntity.setFormat(StringUtils.isNotEmpty(excel.exportFormat()) ? excel.exportFormat() : excel.format()); excelEntity.setStatistics(excel.isStatistics()); String fieldname = field.getName(); excelEntity.setMethod(PoiPublicUtil.getMethod(fieldname, pojoClass)); }
Example #11
Source File: ImportBaseService.java From easypoi with Apache License 2.0 | 5 votes |
public void getExcelField(String targetId, Field field, ExcelImportEntity excelEntity, Excel excel, Class<?> pojoClass) throws Exception { excelEntity.setName(getExcelName(excel.name(), targetId)); String fieldname = field.getName(); excelEntity.setMethod(PoiPublicUtil.getMethod(fieldname, pojoClass, field.getType())); if (StringUtils.isNotEmpty(excel.importFormat())) { excelEntity.setFormat(excel.importFormat()); } else { excelEntity.setFormat(excel.format()); } }
Example #12
Source File: PoiPublicUtil.java From easypoi with Apache License 2.0 | 5 votes |
/** * 判断是否不要在这个excel操作中 * * @param * @param field * @param targetId * @return */ public static boolean isNotUserExcelUserThis(List<String> exclusionsList, Field field, String targetId) { boolean boo = true; if (field.getAnnotation(ExcelIgnore.class) != null) { boo = true; } else if (boo && field.getAnnotation(ExcelCollection.class) != null && isUseInThis(field.getAnnotation(ExcelCollection.class).name(), targetId) && (exclusionsList == null || !exclusionsList.contains(field.getAnnotation( ExcelCollection.class).name()))) { boo = false; } else if (boo && field.getAnnotation(Excel.class) != null && isUseInThis(field.getAnnotation(Excel.class).name(), targetId) && (exclusionsList == null || !exclusionsList.contains(field.getAnnotation( Excel.class).name()))) { boo = false; } else if (boo && field.getAnnotation(ExcelEntity.class) != null && isUseInThis(field.getAnnotation(ExcelEntity.class).name(), targetId) && (exclusionsList == null || !exclusionsList.contains(field.getAnnotation( ExcelEntity.class).name()))) { boo = false; } return boo; }
Example #13
Source File: ExportBase.java From jeasypoi with Apache License 2.0 | 5 votes |
/** * 创建导出实体对象 * * @param field * @param targetId * @param pojoClass * @param getMethods * @return * @throws Exception */ private ExcelExportEntity createExcelExportEntity(Field field, String targetId, Class<?> pojoClass, List<Method> getMethods) throws Exception { Excel excel = field.getAnnotation(Excel.class); ExcelExportEntity excelEntity = new ExcelExportEntity(); excelEntity.setType(excel.type()); getExcelField(targetId, field, excelEntity, excel, pojoClass); if (getMethods != null) { List<Method> newMethods = new ArrayList<Method>(); newMethods.addAll(getMethods); newMethods.add(excelEntity.getMethod()); excelEntity.setMethods(newMethods); } return excelEntity; }
Example #14
Source File: PoiPublicUtil.java From autopoi with Apache License 2.0 | 5 votes |
/** * 判断是否不要在这个excel操作中 * * @param * @param field * @param targetId * @return */ public static boolean isNotUserExcelUserThis(List<String> exclusionsList, Field field, String targetId) { boolean boo = true; if (field.getAnnotation(ExcelIgnore.class) != null) { boo = true; } else if (boo && field.getAnnotation(ExcelCollection.class) != null && isUseInThis(field.getAnnotation(ExcelCollection.class).name(), targetId) && (exclusionsList == null || !exclusionsList.contains(field.getAnnotation(ExcelCollection.class).name()))) { boo = false; } else if (boo && field.getAnnotation(Excel.class) != null && isUseInThis(field.getAnnotation(Excel.class).name(), targetId) && (exclusionsList == null || !exclusionsList.contains(field.getAnnotation(Excel.class).name()))) { boo = false; } else if (boo && field.getAnnotation(ExcelEntity.class) != null && isUseInThis(field.getAnnotation(ExcelEntity.class).name(), targetId) && (exclusionsList == null || !exclusionsList.contains(field.getAnnotation(ExcelEntity.class).name()))) { boo = false; } return boo; }
Example #15
Source File: ExcelExportUtil.java From jeewx with Apache License 2.0 | 5 votes |
/** * * @param targetId * @param field * @param excelEntity * @param excel * @param pojoClass * @throws Exception */ public static void getExcelField(String targetId, Field field, ExcelExportEntity excelEntity, Excel excel, Class<?> pojoClass) throws Exception { excelEntity.setName(getExcelName(excel.exportName(), targetId)); excelEntity.setWidth(excel.exportFieldWidth()); excelEntity.setHeight(excel.exportFieldHeight()); excelEntity.setNeedMerge(excel.needMerge()); excelEntity.setOrderNum(getCellOrder(excel.orderNum(),targetId)); excelEntity.setWrap(excel.isWrap()); excelEntity.setExportImageType(excel.imageType()); excelEntity.setExportFormat(StringUtils.isNotEmpty(excel.exportFormat())? excel.exportFormat():excel.imExFormat()); String fieldname = field.getName(); excelEntity.setGetMethod(ExcelPublicUtil.getMethod(fieldname, pojoClass)); if (excel.exportConvertSign() == 1||excel.imExConvert()==1) { StringBuffer getConvertMethodName = new StringBuffer("convertGet"); getConvertMethodName .append(fieldname.substring(0, 1).toUpperCase()); getConvertMethodName.append(fieldname.substring(1)); Method getConvertMethod = pojoClass.getMethod( getConvertMethodName.toString(), new Class[] {}); excelEntity.setGetMethod(getConvertMethod); if(StringUtils.isNotEmpty(excel.dicCode())){ SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class); List<DictEntity> dictList = systemService.queryDict(excel.dictTable(), excel.dicCode(), excel.dicText()); Map<String,String> dictMap = new HashMap<String,String>(); for (DictEntity dictEntity : dictList) { dictMap.put(dictEntity.getTypecode(), dictEntity.getTypename()); } excelEntity.setDictMap(dictMap); } } }
Example #16
Source File: ImportBaseService.java From autopoi with Apache License 2.0 | 5 votes |
public void getExcelField(String targetId, Field field, ExcelImportEntity excelEntity, Excel excel, Class<?> pojoClass) throws Exception { excelEntity.setName(getExcelName(excel.name(), targetId)); String fieldname = field.getName(); //update-begin-author:taoyan for:TASK #2798 【例子】导入扩展方法,支持自定义导入字段转换规则 excelEntity.setMethod(PoiPublicUtil.getMethod(fieldname, pojoClass, field.getType(),excel.importConvert())); //update-end-author:taoyan for:TASK #2798 【例子】导入扩展方法,支持自定义导入字段转换规则 if (StringUtils.isNotEmpty(excel.importFormat())) { excelEntity.setFormat(excel.importFormat()); } else { excelEntity.setFormat(excel.format()); } }
Example #17
Source File: ExportBase.java From autopoi with Apache License 2.0 | 4 votes |
/** * 注解到导出对象的转换 * * @param targetId * @param field * @param excelEntity * @param excel * @param pojoClass * @throws Exception */ private void getExcelField(String targetId, Field field, ExcelExportEntity excelEntity, Excel excel, Class<?> pojoClass) throws Exception { excelEntity.setName(getExcelName(excel.name(), targetId)); excelEntity.setWidth(excel.width()); excelEntity.setHeight(excel.height()); excelEntity.setNeedMerge(excel.needMerge()); excelEntity.setMergeVertical(excel.mergeVertical()); excelEntity.setMergeRely(excel.mergeRely()); excelEntity.setReplace(excel.replace()); if(StringUtils.isNotEmpty(excel.dicCode())){ AutoPoiDictServiceI jeecgDictService = null; try { jeecgDictService = ApplicationContextUtil.getContext().getBean(AutoPoiDictServiceI.class); } catch (Exception e) { } if(jeecgDictService!=null){ String[] dictReplace = jeecgDictService.queryDict(excel.dictTable(), excel.dicCode(), excel.dicText()); if(excelEntity.getReplace()!=null && dictReplace!=null && dictReplace.length!=0){ excelEntity.setReplace(dictReplace); } } } excelEntity.setOrderNum(getCellOrder(excel.orderNum(), targetId)); excelEntity.setWrap(excel.isWrap()); excelEntity.setExportImageType(excel.imageType()); excelEntity.setSuffix(excel.suffix()); excelEntity.setDatabaseFormat(excel.databaseFormat()); excelEntity.setFormat(StringUtils.isNotEmpty(excel.exportFormat()) ? excel.exportFormat() : excel.format()); excelEntity.setStatistics(excel.isStatistics()); String fieldname = field.getName(); //update-begin-author:taoyan date:20200319 for:autopoi 双表头问题 #862 基于注解的解决方案 excelEntity.setKey(fieldname); //update-end-author:taoyan date:20200319 for:autopoi 双表头问题 #862 基于注解的解决方案 //update-begin-author:taoyan date:20200319 for:Excel注解的numFormat方法似乎未实现 #970 excelEntity.setNumFormat(excel.numFormat()); //update-end-author:taoyan date:20200319 for:Excel注解的numFormat方法似乎未实现 #970 //update-begin-author:taoyan date:20180615 for:TASK #2798 【例子】导入扩展方法,支持自定义导入字段转换规则 excelEntity.setMethod(PoiPublicUtil.getMethod(fieldname, pojoClass,excel.exportConvert())); //update-end-author:taoyan date:20180615 for:TASK #2798 【例子】导入扩展方法,支持自定义导入字段转换规则 //update-begin-author:taoyan date:20180801 for:TASK #3038 【bug】Excel 导出多个值(逗号隔开的情况下,导出字典值是ID值) excelEntity.setMultiReplace(excel.multiReplace()); //update-end-author:taoyan date:20180801 for:TASK #3038 【bug】Excel 导出多个值(逗号隔开的情况下,导出字典值是ID值) //update-begin-author:taoyan date:20200319 for:autopoi 双表头问题 #862 基于实体注解的解决方案 if(StringUtils.isNotEmpty(excel.groupName())){ excelEntity.setGroupName(excel.groupName()); excelEntity.setColspan(true); } //update-end-author:taoyan date:20200319 for:autopoi 双表头问题 #862 基于实体注解的解决方案 }