mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +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 class ExcelSaxUtil {
|
||||||
|
|
||||||
// 填充字符串
|
/**
|
||||||
|
* 填充字符串
|
||||||
|
*/
|
||||||
public static final char CELL_FILL_CHAR = '@';
|
public static final char CELL_FILL_CHAR = '@';
|
||||||
// 列的最大位数
|
/**
|
||||||
|
* 列的最大位数
|
||||||
|
*/
|
||||||
public static final int MAX_CELL_BIT = 3;
|
public static final int MAX_CELL_BIT = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,13 +107,6 @@ public class ExcelSaxUtil {
|
|||||||
result = value;
|
result = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NUMBER:
|
|
||||||
try {
|
|
||||||
result = getNumberValue(value, numFmtString);
|
|
||||||
} catch (final NumberFormatException e) {
|
|
||||||
result = value;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DATE:
|
case DATE:
|
||||||
try {
|
try {
|
||||||
result = getDateValue(value);
|
result = getDateValue(value);
|
||||||
@ -118,7 +115,11 @@ public class ExcelSaxUtil {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
try {
|
||||||
|
result = getNumberValue(value, numFmtString);
|
||||||
|
} catch (final NumberFormatException e) {
|
||||||
result = value;
|
result = value;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -267,6 +267,7 @@ public class SheetDataSaxHandler extends DefaultHandler {
|
|||||||
value = new FormulaCellValue(StrUtil.trim(lastFormula),
|
value = new FormulaCellValue(StrUtil.trim(lastFormula),
|
||||||
ExcelSaxUtil.getDataValue(this.cellDataType, contentStr, this.sharedStrings, this.numFmtString));
|
ExcelSaxUtil.getDataValue(this.cellDataType, contentStr, this.sharedStrings, this.numFmtString));
|
||||||
}else{
|
}else{
|
||||||
|
// since 6.0.0,默认的cellDataType是NULL而非NUMBER
|
||||||
value = ExcelSaxUtil.getDataValue(this.cellDataType, contentStr, this.sharedStrings, this.numFmtString);
|
value = ExcelSaxUtil.getDataValue(this.cellDataType, contentStr, this.sharedStrings, this.numFmtString);
|
||||||
}
|
}
|
||||||
addCellValue(curCell++, value);
|
addCellValue(curCell++, value);
|
||||||
|
@ -204,7 +204,7 @@ public class ExcelSaxReadTest {
|
|||||||
// 非日期格式不做转换
|
// 非日期格式不做转换
|
||||||
Assertions.assertEquals("112233", rows.get(2));
|
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));
|
Assertions.assertEquals("2012-12-21 00:00:00", rows.get(4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user