|
|
@ -22,6 +22,7 @@ import java.util.Set; |
|
|
|
import java.util.UUID; |
|
|
|
import java.util.UUID; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
import org.apache.commons.lang3.ArrayUtils; |
|
|
|
import org.apache.commons.lang3.RegExUtils; |
|
|
|
import org.apache.commons.lang3.RegExUtils; |
|
|
|
import org.apache.poi.hssf.usermodel.HSSFClientAnchor; |
|
|
|
import org.apache.poi.hssf.usermodel.HSSFClientAnchor; |
|
|
|
import org.apache.poi.hssf.usermodel.HSSFPicture; |
|
|
|
import org.apache.poi.hssf.usermodel.HSSFPicture; |
|
|
@ -163,11 +164,27 @@ public class ExcelUtil<T> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Class<T> clazz; |
|
|
|
public Class<T> clazz; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 需要排除列属性 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public String[] excludeFields; |
|
|
|
|
|
|
|
|
|
|
|
public ExcelUtil(Class<T> clazz) |
|
|
|
public ExcelUtil(Class<T> clazz) |
|
|
|
{ |
|
|
|
{ |
|
|
|
this.clazz = clazz; |
|
|
|
this.clazz = clazz; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 隐藏Excel中列属性 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param fields 列属性名 示例[单个"name"/多个"id","name"] |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void hideColumn(String... fields) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
this.excludeFields = fields; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void init(List<T> list, String sheetName, String title, Type type) |
|
|
|
public void init(List<T> list, String sheetName, String title, Type type) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (list == null) |
|
|
|
if (list == null) |
|
|
@ -1201,6 +1218,8 @@ public class ExcelUtil<T> |
|
|
|
tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields())); |
|
|
|
tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields())); |
|
|
|
tempFields.addAll(Arrays.asList(clazz.getDeclaredFields())); |
|
|
|
tempFields.addAll(Arrays.asList(clazz.getDeclaredFields())); |
|
|
|
for (Field field : tempFields) |
|
|
|
for (Field field : tempFields) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!ArrayUtils.contains(this.excludeFields, field.getName())) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// 单注解
|
|
|
|
// 单注解
|
|
|
|
if (field.isAnnotationPresent(Excel.class)) |
|
|
|
if (field.isAnnotationPresent(Excel.class)) |
|
|
@ -1228,6 +1247,7 @@ public class ExcelUtil<T> |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return fields; |
|
|
|
return fields; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|