Compare commits

...

2 Commits

Author SHA1 Message Date
  winter b46040c855 fix bug 3 years ago
  Stormeye Wu 09f323cc30 支持前缀 4 years ago
10 changed files with 40 additions and 4 deletions
Split View
  1. +1
    -1
      easypoi-annotation/pom.xml
  2. +5
    -0
      easypoi-annotation/src/main/java/cn/afterturn/easypoi/excel/annotation/Excel.java
  3. +1
    -1
      easypoi-base/pom.xml
  4. +4
    -0
      easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelExportEntity.java
  5. +4
    -0
      easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelImportEntity.java
  6. +4
    -0
      easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/ExportCommonService.java
  7. +18
    -0
      easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/CellValueService.java
  8. +1
    -0
      easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/base/ImportBaseService.java
  9. +1
    -1
      easypoi-web/pom.xml
  10. +1
    -1
      pom.xml

+ 1
- 1
easypoi-annotation/pom.xml View File

@@ -4,7 +4,7 @@
<parent>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi</artifactId>
<version>4.2.0</version>
<version>4.2.0.A</version>
</parent>
<artifactId>easypoi-annotation</artifactId>
<description>base annotation</description>

+ 5
- 0
easypoi-annotation/src/main/java/cn/afterturn/easypoi/excel/annotation/Excel.java View File

@@ -67,6 +67,11 @@ public @interface Excel {
*/
public int imageType() default 1;
/**
* 文字前缀,如1234567890112242335 变成`1234567890112242335
*/
public String prefix() default "";
/**
* 文字后缀,如% 90 变成90%
*/


+ 1
- 1
easypoi-base/pom.xml View File

@@ -4,7 +4,7 @@
<parent>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi</artifactId>
<version>4.2.0</version>
<version>4.2.0.A</version>
</parent>
<artifactId>easypoi-base</artifactId>
<dependencies>


+ 4
- 0
easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelExportEntity.java View File

@@ -84,6 +84,10 @@ public class ExcelExportEntity extends ExcelBaseEntity implements Comparable<Exc
* 合并依赖`
*/
private int[] mergeRely;
/**
* 前缀
*/
private String prefix;
/**
* 后缀
*/


+ 4
- 0
easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelImportEntity.java View File

@@ -44,6 +44,10 @@ public class ExcelImportEntity extends ExcelBaseEntity {
* 对应exportType
*/
private String classType;
/**
* 前缀
*/
private String prefix;
/**
* 后缀
*/


+ 4
- 0
easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/ExportCommonService.java View File

@@ -223,6 +223,9 @@ public class ExportCommonService {
if (needHandlerList != null && needHandlerList.contains(entity.getName())) {
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) {
value = value + entity.getSuffix();
}
@@ -262,6 +265,7 @@ public class ExportCommonService {
Integer.valueOf(PoiPublicUtil.getValueByTargetId(excel.orderNum(), targetId, "0")));
excelEntity.setWrap(excel.isWrap());
excelEntity.setExportImageType(excel.imageType());
excelEntity.setPrefix(excel.prefix());
excelEntity.setSuffix(excel.suffix());
excelEntity.setDatabaseFormat(excel.databaseFormat());
excelEntity.setFormat(


+ 18
- 0
easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/CellValueService.java View File

@@ -227,6 +227,7 @@ public class CellValueService {
result = cell;
}
if (entity != null) {
result = handlerPrefix(entity.getPrefix(), result);
result = handlerSuffix(entity.getSuffix(), result);
result = replaceValue(entity.getReplace(), result);
result = replaceValue(entity.getReplace(), result);
@@ -257,12 +258,29 @@ public class CellValueService {
Type[] ts = setMethod.getGenericParameterTypes();
String classFullName = ts[0].toString();
Object result = cellEntity.getValue();
result = handlerPrefix(entity.getPrefix(), result);
result = handlerSuffix(entity.getSuffix(), result);
result = replaceValue(entity.getReplace(), result);
result = handlerValue(dataHandler, object, result, titleString);
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;
}

/**
* 把后缀删除掉
*


+ 1
- 0
easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/base/ImportBaseService.java View File

@@ -70,6 +70,7 @@ public class ImportBaseService {
excelEntity.setSaveType(excel.imageType());
excelEntity.setReplace(excel.replace());
excelEntity.setDatabaseFormat(excel.databaseFormat());
excelEntity.setPrefix(excel.prefix());
excelEntity.setSuffix(excel.suffix());
excelEntity.setImportField(Boolean
.valueOf(PoiPublicUtil.getValueByTargetId(excel.isImportField(), targetId, "false")));


+ 1
- 1
easypoi-web/pom.xml View File

@@ -4,7 +4,7 @@
<parent>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi</artifactId>
<version>4.2.0</version>
<version>4.2.0.A</version>
</parent>
<artifactId>easypoi-web</artifactId>
<dependencies>


+ 1
- 1
pom.xml View File

@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi</artifactId>
<version>4.2.0</version>
<version>4.2.0.A</version>
<packaging>pom</packaging>
<name>easypoi</name>
<modules>


Loading…
Cancel
Save