mirror of
https://gitee.com/myxzgzs/boyue-vue-pro.git
synced 2025-08-08 16:32:46 +08:00
Excel导出时,下拉选择列错位问题修改 #853
This commit is contained in:
parent
4dca326081
commit
62e83eaef5
@ -3,6 +3,7 @@ package cn.iocoder.yudao.framework.excel.core.handler;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.hutool.poi.excel.ExcelUtil;
|
import cn.hutool.poi.excel.ExcelUtil;
|
||||||
@ -61,15 +62,18 @@ public class SelectSheetWriteHandler implements SheetWriteHandler {
|
|||||||
int colIndex = 0;
|
int colIndex = 0;
|
||||||
boolean ignoreUnannotated = head.isAnnotationPresent(ExcelIgnoreUnannotated.class);
|
boolean ignoreUnannotated = head.isAnnotationPresent(ExcelIgnoreUnannotated.class);
|
||||||
for (Field field : head.getDeclaredFields()) {
|
for (Field field : head.getDeclaredFields()) {
|
||||||
// 忽略 static final 或 transient 的字段
|
// 关联 https://github.com/YunaiV/ruoyi-vue-pro/pull/853
|
||||||
|
// 1.1 忽略 static final 或 transient 的字段
|
||||||
if (isStaticFinalOrTransient(field) ) {
|
if (isStaticFinalOrTransient(field) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 忽略的字段跳过
|
// 1.2 忽略的字段跳过
|
||||||
if ((ignoreUnannotated && !field.isAnnotationPresent(ExcelProperty.class))
|
if ((ignoreUnannotated && !field.isAnnotationPresent(ExcelProperty.class))
|
||||||
|| field.isAnnotationPresent(ExcelIgnore.class)) {
|
|| field.isAnnotationPresent(ExcelIgnore.class)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2. 核心:处理有 ExcelColumnSelect 注解的字段
|
||||||
if (field.isAnnotationPresent(ExcelColumnSelect.class)) {
|
if (field.isAnnotationPresent(ExcelColumnSelect.class)) {
|
||||||
ExcelProperty excelProperty = field.getAnnotation(ExcelProperty.class);
|
ExcelProperty excelProperty = field.getAnnotation(ExcelProperty.class);
|
||||||
if (excelProperty != null && excelProperty.index() != -1) {
|
if (excelProperty != null && excelProperty.index() != -1) {
|
||||||
@ -83,7 +87,8 @@ public class SelectSheetWriteHandler implements SheetWriteHandler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断字段是否是静态的、最终的、 transient 的
|
* 判断字段是否是静态的、最终的、 transient 的
|
||||||
* EasyExcel 默认是忽略 static final 或 transient 的字段,所以需要判断
|
* 原因:EasyExcel 默认是忽略 static final 或 transient 的字段,所以需要判断
|
||||||
|
*
|
||||||
* @param field 字段
|
* @param field 字段
|
||||||
* @return 是否是静态的、最终的、transient 的
|
* @return 是否是静态的、最终的、transient 的
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user