正在显示
1 个修改的文件
包含
14 行增加
和
10 行删除
| @@ -8,7 +8,6 @@ import java.io.OutputStream; | @@ -8,7 +8,6 @@ import java.io.OutputStream; | ||
| 8 | import java.lang.reflect.Field; | 8 | import java.lang.reflect.Field; |
| 9 | import java.lang.reflect.Method; | 9 | import java.lang.reflect.Method; |
| 10 | import java.math.BigDecimal; | 10 | import java.math.BigDecimal; |
| 11 | -import java.text.DecimalFormat; | ||
| 12 | import java.util.ArrayList; | 11 | import java.util.ArrayList; |
| 13 | import java.util.Arrays; | 12 | import java.util.Arrays; |
| 14 | import java.util.Comparator; | 13 | import java.util.Comparator; |
| @@ -18,6 +17,7 @@ import java.util.List; | @@ -18,6 +17,7 @@ import java.util.List; | ||
| 18 | import java.util.Map; | 17 | import java.util.Map; |
| 19 | import java.util.UUID; | 18 | import java.util.UUID; |
| 20 | import java.util.stream.Collectors; | 19 | import java.util.stream.Collectors; |
| 20 | + | ||
| 21 | import org.apache.poi.hssf.usermodel.HSSFDateUtil; | 21 | import org.apache.poi.hssf.usermodel.HSSFDateUtil; |
| 22 | import org.apache.poi.ss.usermodel.BorderStyle; | 22 | import org.apache.poi.ss.usermodel.BorderStyle; |
| 23 | import org.apache.poi.ss.usermodel.Cell; | 23 | import org.apache.poi.ss.usermodel.Cell; |
| @@ -41,6 +41,7 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook; | @@ -41,6 +41,7 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook; | ||
| 41 | import org.apache.poi.xssf.usermodel.XSSFDataValidation; | 41 | import org.apache.poi.xssf.usermodel.XSSFDataValidation; |
| 42 | import org.slf4j.Logger; | 42 | import org.slf4j.Logger; |
| 43 | import org.slf4j.LoggerFactory; | 43 | import org.slf4j.LoggerFactory; |
| 44 | + | ||
| 44 | import com.ruoyi.common.annotation.Excel; | 45 | import com.ruoyi.common.annotation.Excel; |
| 45 | import com.ruoyi.common.annotation.Excel.ColumnType; | 46 | import com.ruoyi.common.annotation.Excel.ColumnType; |
| 46 | import com.ruoyi.common.annotation.Excel.Type; | 47 | import com.ruoyi.common.annotation.Excel.Type; |
| @@ -200,7 +201,9 @@ public class ExcelUtil<T> | @@ -200,7 +201,9 @@ public class ExcelUtil<T> | ||
| 200 | // 设置类的私有字段属性可访问. | 201 | // 设置类的私有字段属性可访问. |
| 201 | field.setAccessible(true); | 202 | field.setAccessible(true); |
| 202 | Integer column = cellMap.get(attr.name()); | 203 | Integer column = cellMap.get(attr.name()); |
| 203 | - fieldsMap.put(column, field); | 204 | + if(column !=null ) { // 字段在excel 中没有,那么就不需要设置值 |
| 205 | + fieldsMap.put(column, field); | ||
| 206 | + } | ||
| 204 | } | 207 | } |
| 205 | } | 208 | } |
| 206 | for (int i = 1; i < rows; i++) | 209 | for (int i = 1; i < rows; i++) |
| @@ -875,14 +878,15 @@ public class ExcelUtil<T> | @@ -875,14 +878,15 @@ public class ExcelUtil<T> | ||
| 875 | } | 878 | } |
| 876 | else | 879 | else |
| 877 | { | 880 | { |
| 878 | - if ((Double) val % 1 > 0) | ||
| 879 | - { | ||
| 880 | - val = new DecimalFormat("0.00").format(val); | ||
| 881 | - } | ||
| 882 | - else | ||
| 883 | - { | ||
| 884 | - val = new DecimalFormat("0").format(val); | ||
| 885 | - } | 881 | + /* if ((Double) val % 1 > 0) |
| 882 | + { | ||
| 883 | + val = new DecimalFormat("0.00").format(val); | ||
| 884 | + } | ||
| 885 | + else | ||
| 886 | + { | ||
| 887 | + val = new DecimalFormat("0").format(val); | ||
| 888 | + }*/ | ||
| 889 | + val = new BigDecimal(val.toString()); // 导入的数据保证原汁原味,不做处理 | ||
| 886 | } | 890 | } |
| 887 | } | 891 | } |
| 888 | else if (cell.getCellTypeEnum() == CellType.STRING) | 892 | else if (cell.getCellTypeEnum() == CellType.STRING) |
-
请 注册 或 登录 后发表评论