mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix code
This commit is contained in:
parent
8ea3748b6f
commit
458c38e421
@ -44,9 +44,13 @@ import java.io.InputStream;
|
||||
*/
|
||||
public class ExcelSaxUtil {
|
||||
|
||||
// 填充字符串
|
||||
/**
|
||||
* 填充字符串
|
||||
*/
|
||||
public static final char CELL_FILL_CHAR = '@';
|
||||
// 列的最大位数
|
||||
/**
|
||||
* 列的最大位数
|
||||
*/
|
||||
public static final int MAX_CELL_BIT = 3;
|
||||
|
||||
/**
|
||||
@ -103,13 +107,6 @@ public class ExcelSaxUtil {
|
||||
result = value;
|
||||
}
|
||||
break;
|
||||
case NUMBER:
|
||||
try {
|
||||
result = getNumberValue(value, numFmtString);
|
||||
} catch (final NumberFormatException e) {
|
||||
result = value;
|
||||
}
|
||||
break;
|
||||
case DATE:
|
||||
try {
|
||||
result = getDateValue(value);
|
||||
@ -118,7 +115,11 @@ public class ExcelSaxUtil {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
result = value;
|
||||
try {
|
||||
result = getNumberValue(value, numFmtString);
|
||||
} catch (final NumberFormatException e) {
|
||||
result = value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
|
@ -267,6 +267,7 @@ public class SheetDataSaxHandler extends DefaultHandler {
|
||||
value = new FormulaCellValue(StrUtil.trim(lastFormula),
|
||||
ExcelSaxUtil.getDataValue(this.cellDataType, contentStr, this.sharedStrings, this.numFmtString));
|
||||
}else{
|
||||
// since 6.0.0,默认的cellDataType是NULL而非NUMBER
|
||||
value = ExcelSaxUtil.getDataValue(this.cellDataType, contentStr, this.sharedStrings, this.numFmtString);
|
||||
}
|
||||
addCellValue(curCell++, value);
|
||||
|
@ -204,7 +204,7 @@ public class ExcelSaxReadTest {
|
||||
// 非日期格式不做转换
|
||||
Assertions.assertEquals("112233", rows.get(2));
|
||||
// 读取实际值,而非带有格式处理过的值
|
||||
Assertions.assertEquals("1000", rows.get(3));
|
||||
Assertions.assertEquals("1000.0", rows.get(3));
|
||||
Assertions.assertEquals("2012-12-21 00:00:00", rows.get(4));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user