Excel工具优化BigDecimal类型

This commit is contained in:
thinkgem
2020-02-24 12:23:23 +08:00
parent d5f63c480f
commit f974d058d1
2 changed files with 4 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
@@ -466,6 +467,8 @@ public class ExcelExport implements Closeable{
}else if(val instanceof Float) { }else if(val instanceof Float) {
cell.setCellValue((Float) val); cell.setCellValue((Float) val);
defaultDataFormat = "0.00"; defaultDataFormat = "0.00";
}else if(val instanceof BigDecimal) {
cell.setCellValue(((BigDecimal)val).doubleValue());
}else if(val instanceof Date) { }else if(val instanceof Date) {
cell.setCellValue((Date) val); cell.setCellValue((Date) val);
defaultDataFormat = "yyyy-MM-dd HH:mm"; defaultDataFormat = "yyyy-MM-dd HH:mm";

View File

@@ -82,7 +82,7 @@ public @interface ExcelField {
Class<?> fieldType() default Class.class; Class<?> fieldType() default Class.class;
/** /**
* 数值格式例如0.00yyyy-MM-dd * 数值格式(例如:数值:0.00;日期:yyyy-MM-dd;金额:¥#,##0.00
*/ */
String dataFormat() default "@"; String dataFormat() default "@";