xiatian 12 ore în urmă
părinte
comite
dbe27bab63

+ 3 - 1
stmms-web/src/main/java/cn/com/qmth/stmms/admin/utils/ExportStudentExcel.java

@@ -32,6 +32,7 @@ import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
 import org.apache.poi.xssf.usermodel.XSSFRichTextString;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.util.CollectionUtils;
 
 import com.google.common.collect.Lists;
 
@@ -106,7 +107,8 @@ public class ExportStudentExcel {
         Field[] fs = cls.getDeclaredFields();
         for (Field f : fs) {
             ExcelField ef = f.getAnnotation(ExcelField.class);
-            if (ef != null && (ef.type() == 0 || ef.type() == type) && (cols == null || cols.contains(f.getName()))) {
+            if (ef != null && (ef.type() == 0 || ef.type() == type)
+                    && (CollectionUtils.isEmpty(cols) || cols.contains(f.getName()))) {
                 if (groups != null && groups.length > 0) {
                     boolean inGroup = false;
                     for (int g : groups) {

+ 2 - 1
stmms-web/src/main/java/cn/com/qmth/stmms/common/utils/ExportExcelByCols.java

@@ -32,6 +32,7 @@ import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
 import org.apache.poi.xssf.usermodel.XSSFRichTextString;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.util.CollectionUtils;
 
 import com.google.common.collect.Lists;
 
@@ -95,7 +96,7 @@ public class ExportExcelByCols {
         Field[] fs = cls.getDeclaredFields();
         for (Field f : fs) {
             ExcelField ef = f.getAnnotation(ExcelField.class);
-            if (ef != null && cols.contains(f.getName())) {
+            if (ef != null && (CollectionUtils.isEmpty(cols) || cols.contains(f.getName()))) {
                 annotationList.add(new Object[] { ef, f });
             }
         }