mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add BigDecimal support
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
* 【core】 增强日期工具类(pr#455@Github)
|
||||
* 【setting】 构造Setting增加默认字符编码
|
||||
* 【extra】 ServletUtil增加getHeaderMap方法
|
||||
* 【poi】 CellUtil改进数字支持,解决空指针问题(pr#489@Github)
|
||||
|
||||
### Bug修复
|
||||
* 【cache】 修复missCount规则(issue#465@Github)
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package cn.hutool.poi.excel.cell;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -120,6 +121,7 @@ public class CellUtil {
|
||||
* @param isHeader 是否为标题单元格
|
||||
*/
|
||||
public static void setCellValue(Cell cell, Object value, StyleSet styleSet, boolean isHeader) {
|
||||
if(null != styleSet) {
|
||||
final CellStyle headCellStyle = styleSet.getHeadCellStyle();
|
||||
final CellStyle cellStyle = styleSet.getCellStyle();
|
||||
if (isHeader && null != headCellStyle) {
|
||||
@@ -127,6 +129,7 @@ public class CellUtil {
|
||||
} else if (null != cellStyle) {
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
}
|
||||
|
||||
if (null == value) {
|
||||
cell.setCellValue(StrUtil.EMPTY);
|
||||
@@ -145,7 +148,7 @@ public class CellUtil {
|
||||
} else if (value instanceof RichTextString) {
|
||||
cell.setCellValue((RichTextString) value);
|
||||
} else if (value instanceof Number) {
|
||||
if ((value instanceof Double || value instanceof Float) && null != styleSet && null != styleSet.getCellStyleForNumber()) {
|
||||
if ((value instanceof Double || value instanceof Float || value instanceof BigDecimal) && null != styleSet && null != styleSet.getCellStyleForNumber()) {
|
||||
cell.setCellStyle(styleSet.getCellStyleForNumber());
|
||||
}
|
||||
cell.setCellValue(((Number) value).doubleValue());
|
||||
|
Reference in New Issue
Block a user