| @@ -4,7 +4,7 @@ | |||||
| <parent> | <parent> | ||||
| <groupId>cn.afterturn</groupId> | <groupId>cn.afterturn</groupId> | ||||
| <artifactId>easypoi</artifactId> | <artifactId>easypoi</artifactId> | ||||
| <version>4.1.3</version> | |||||
| <version>4.1.3.A</version> | |||||
| </parent> | </parent> | ||||
| <artifactId>easypoi-annotation</artifactId> | <artifactId>easypoi-annotation</artifactId> | ||||
| <description>base annotation</description> | <description>base annotation</description> | ||||
| @@ -67,6 +67,11 @@ public @interface Excel { | |||||
| */ | */ | ||||
| public int imageType() default 1; | public int imageType() default 1; | ||||
| /** | |||||
| * 文字前缀,如1234567890112242335 变成`1234567890112242335 | |||||
| */ | |||||
| public String prefix() default ""; | |||||
| /** | /** | ||||
| * 文字后缀,如% 90 变成90% | * 文字后缀,如% 90 变成90% | ||||
| */ | */ | ||||
| @@ -4,7 +4,7 @@ | |||||
| <parent> | <parent> | ||||
| <groupId>cn.afterturn</groupId> | <groupId>cn.afterturn</groupId> | ||||
| <artifactId>easypoi</artifactId> | <artifactId>easypoi</artifactId> | ||||
| <version>4.1.3</version> | |||||
| <version>4.1.3.A</version> | |||||
| </parent> | </parent> | ||||
| <artifactId>easypoi-base</artifactId> | <artifactId>easypoi-base</artifactId> | ||||
| <dependencies> | <dependencies> | ||||
| @@ -84,6 +84,10 @@ public class ExcelExportEntity extends ExcelBaseEntity implements Comparable<Exc | |||||
| * 合并依赖` | * 合并依赖` | ||||
| */ | */ | ||||
| private int[] mergeRely; | private int[] mergeRely; | ||||
| /** | |||||
| * 前缀 | |||||
| */ | |||||
| private String prefix; | |||||
| /** | /** | ||||
| * 后缀 | * 后缀 | ||||
| */ | */ | ||||
| @@ -44,6 +44,10 @@ public class ExcelImportEntity extends ExcelBaseEntity { | |||||
| * 对应exportType | * 对应exportType | ||||
| */ | */ | ||||
| private String classType; | private String classType; | ||||
| /** | |||||
| * 前缀 | |||||
| */ | |||||
| private String prefix; | |||||
| /** | /** | ||||
| * 后缀 | * 后缀 | ||||
| */ | */ | ||||
| @@ -223,6 +223,9 @@ public class ExportCommonService { | |||||
| if (needHandlerList != null && needHandlerList.contains(entity.getName())) { | if (needHandlerList != null && needHandlerList.contains(entity.getName())) { | ||||
| value = dataHandler.exportHandler(obj, entity.getName(), value); | value = dataHandler.exportHandler(obj, entity.getName(), value); | ||||
| } | } | ||||
| if (StringUtils.isNotBlank(entity.getPrefix()) && value != null) { | |||||
| value = entity.getPrefix() + value; | |||||
| } | |||||
| if (StringUtils.isNotEmpty(entity.getSuffix()) && value != null) { | if (StringUtils.isNotEmpty(entity.getSuffix()) && value != null) { | ||||
| value = value + entity.getSuffix(); | value = value + entity.getSuffix(); | ||||
| } | } | ||||
| @@ -262,6 +265,7 @@ public class ExportCommonService { | |||||
| Integer.valueOf(PoiPublicUtil.getValueByTargetId(excel.orderNum(), targetId, "0"))); | Integer.valueOf(PoiPublicUtil.getValueByTargetId(excel.orderNum(), targetId, "0"))); | ||||
| excelEntity.setWrap(excel.isWrap()); | excelEntity.setWrap(excel.isWrap()); | ||||
| excelEntity.setExportImageType(excel.imageType()); | excelEntity.setExportImageType(excel.imageType()); | ||||
| excelEntity.setPrefix(excel.prefix()); | |||||
| excelEntity.setSuffix(excel.suffix()); | excelEntity.setSuffix(excel.suffix()); | ||||
| excelEntity.setDatabaseFormat(excel.databaseFormat()); | excelEntity.setDatabaseFormat(excel.databaseFormat()); | ||||
| excelEntity.setFormat( | excelEntity.setFormat( | ||||
| @@ -227,6 +227,7 @@ public class CellValueService { | |||||
| result = cell; | result = cell; | ||||
| } | } | ||||
| if (entity != null) { | if (entity != null) { | ||||
| result = handlerPrefix(entity.getPrefix(), result); | |||||
| result = handlerSuffix(entity.getSuffix(), result); | result = handlerSuffix(entity.getSuffix(), result); | ||||
| result = replaceValue(entity.getReplace(), result); | result = replaceValue(entity.getReplace(), result); | ||||
| result = replaceValue(entity.getReplace(), result); | result = replaceValue(entity.getReplace(), result); | ||||
| @@ -257,12 +258,29 @@ public class CellValueService { | |||||
| Type[] ts = setMethod.getGenericParameterTypes(); | Type[] ts = setMethod.getGenericParameterTypes(); | ||||
| String classFullName = ts[0].toString(); | String classFullName = ts[0].toString(); | ||||
| Object result = cellEntity.getValue(); | Object result = cellEntity.getValue(); | ||||
| result = handlerPrefix(entity.getPrefix(), result); | |||||
| result = handlerSuffix(entity.getSuffix(), result); | result = handlerSuffix(entity.getSuffix(), result); | ||||
| result = replaceValue(entity.getReplace(), result); | result = replaceValue(entity.getReplace(), result); | ||||
| result = handlerValue(dataHandler, object, result, titleString); | result = handlerValue(dataHandler, object, result, titleString); | ||||
| return getValueByType(classFullName, result, entity, (Class) ts[0]); | return getValueByType(classFullName, result, entity, (Class) ts[0]); | ||||
| } | } | ||||
| /** | |||||
| * 把前缀删除掉 | |||||
| * | |||||
| * @param result | |||||
| * @param prefix | |||||
| * @return | |||||
| */ | |||||
| private Object handlerPrefix(String prefix, Object result) { | |||||
| if (StringUtils.isNotEmpty(prefix) && result != null | |||||
| && result.toString().startsWith(prefix)) { | |||||
| String temp = result.toString(); | |||||
| return temp.substring(prefix.length(), temp.length()); | |||||
| } | |||||
| return result; | |||||
| } | |||||
| /** | /** | ||||
| * 把后缀删除掉 | * 把后缀删除掉 | ||||
| * | * | ||||
| @@ -70,6 +70,7 @@ public class ImportBaseService { | |||||
| excelEntity.setSaveType(excel.imageType()); | excelEntity.setSaveType(excel.imageType()); | ||||
| excelEntity.setReplace(excel.replace()); | excelEntity.setReplace(excel.replace()); | ||||
| excelEntity.setDatabaseFormat(excel.databaseFormat()); | excelEntity.setDatabaseFormat(excel.databaseFormat()); | ||||
| excelEntity.setPrefix(excel.prefix()); | |||||
| excelEntity.setSuffix(excel.suffix()); | excelEntity.setSuffix(excel.suffix()); | ||||
| excelEntity.setImportField(Boolean | excelEntity.setImportField(Boolean | ||||
| .valueOf(PoiPublicUtil.getValueByTargetId(excel.isImportField(), targetId, "false"))); | .valueOf(PoiPublicUtil.getValueByTargetId(excel.isImportField(), targetId, "false"))); | ||||
| @@ -4,7 +4,7 @@ | |||||
| <parent> | <parent> | ||||
| <groupId>cn.afterturn</groupId> | <groupId>cn.afterturn</groupId> | ||||
| <artifactId>easypoi</artifactId> | <artifactId>easypoi</artifactId> | ||||
| <version>4.1.3</version> | |||||
| <version>4.1.3.A</version> | |||||
| </parent> | </parent> | ||||
| <artifactId>easypoi-web</artifactId> | <artifactId>easypoi-web</artifactId> | ||||
| <dependencies> | <dependencies> | ||||
| @@ -3,7 +3,7 @@ | |||||
| <modelVersion>4.0.0</modelVersion> | <modelVersion>4.0.0</modelVersion> | ||||
| <groupId>cn.afterturn</groupId> | <groupId>cn.afterturn</groupId> | ||||
| <artifactId>easypoi</artifactId> | <artifactId>easypoi</artifactId> | ||||
| <version>4.1.3</version> | |||||
| <version>4.1.3.A</version> | |||||
| <packaging>pom</packaging> | <packaging>pom</packaging> | ||||
| <name>easypoi</name> | <name>easypoi</name> | ||||
| <modules> | <modules> | ||||
| @@ -45,7 +45,7 @@ | |||||
| </organization> | </organization> | ||||
| <properties> | <properties> | ||||
| <sub.version>4.1.3</sub.version> | |||||
| <sub.version>4.1.3.A</sub.version> | |||||
| <poi.version>4.1.1</poi.version> | <poi.version>4.1.1</poi.version> | ||||
| <xerces.version>2.9.1</xerces.version> | <xerces.version>2.9.1</xerces.version> | ||||
| <guava.version>16.0.1</guava.version> | <guava.version>16.0.1</guava.version> | ||||