org.jeecgframework.dict.service.AutoPoiDictServiceI Java Examples

The following examples show how to use org.jeecgframework.dict.service.AutoPoiDictServiceI. 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 autopoi with Apache License 2.0 4 votes vote down vote up
/**
 * 注解到导出对象的转换
 * 
 * @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 基于实体注解的解决方案
}