You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicStringBufferformat(Objectnumber, StringBuffertoAppendTo, FieldPositionpos) {
finaldoublevalue;
if (numberinstanceofNumber) {
value = ((Number) number).doubleValue();
if (Double.isInfinite(value) || Double.isNaN(value)) {
returnintegerFormat.format(number, toAppendTo, pos);
}
} else {
// testBug54786 gets here with a date, so retain previous behaviourreturnintegerFormat.format(number, toAppendTo, pos);
}
finaldoubleabs = Math.abs(value);
if (abs >= 1E11 || (abs <= 1E-10 && abs > 0)) {
returnscientificFormat.format(number, toAppendTo, pos);
} elseif (Math.floor(value) == value || abs >= 1E10) {
// integer, or integer portion uses all 11 allowed digitsreturnintegerFormat.format(number, toAppendTo, pos);
}
// Non-integers of non-scientific magnitude are formatted as "up to 11// numeric characters, with the decimal point counting as a numeric// character". We know there is a decimal point, so limit to 10 digits.// https://support.microsoft.com/en-us/kb/65903finaldoublerounded = newBigDecimal(value).round(TO_10_SF).doubleValue();
returndecimalFormat.format(rounded, toAppendTo, pos);
}
最主要是这一行导致的bug
final double rounded = new BigDecimal(value).round(TO_10_SF).doubleValue();
// Non-integers of non-scientific magnitude are formatted as "up to 11
// numeric characters, with the decimal point counting as a numeric
// character". We know there is a decimal point, so limit to 10 digits.
// https://support.microsoft.com/en-us/kb/65903
建议先去看文档
快速开始 、常见问题
触发场景描述
单元格填了个值 666666.10001,number类型,读取出来结果是666666.1
触发Bug的代码
com.alibaba.excel.metadata.format.ExcelGeneralNumberFormat#format
最主要是这一行导致的bug
final double rounded = new BigDecimal(value).round(TO_10_SF).doubleValue();
提示的异常或者没有达到的效果
大家尽量把问题一次性描述清楚,然后贴上全部异常,这样方便把问题一次性解决掉。
至少大家要符合一个原则就是,能让其他人复现出这个问题,如果无法复现,肯定无法解决。
The text was updated successfully, but these errors were encountered: