5
触发场景描述
读取Excel,内容中有Double列,内容为3.12345678912345
共14位小数 , 但实际读到的为3.123456789
为9位,丢失了5位
EasyExcel版本为3.3.2
package com.di1shuai.easyexcel;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import java.io.InputStream;
import java.util.LinkedHashMap;
/**
* @author shea
* @since 2023/6/25
*/
public class Main {
public static void main(String[] args) {
String fileName = "time_problem.xlsx";
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
int skipHeaderNumber = 1;
String sheetName = null;
EasyExcel.read(
in,
null,
new ReadListener() {
@Override
public void invoke(Object data, AnalysisContext context) {
LinkedHashMap<Integer, Object> dataMap = (LinkedHashMap) data;
dataMap.entrySet()
.forEach(
dataE -> {
System.out.println(dataE.getKey() + " -> " + dataE.getValue());
});
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
System.out.println("读取成功");
}
})
.sheet(sheetName)
.headRowNumber((int) skipHeaderNumber)
.doRead();
}
}
输出为
0 -> 3
1 -> 2
2 -> 3
3 -> 4
4 -> 5
5 -> 9223372036854780
6 -> -1.123456
7 -> 3.123456789
8 -> 6.123456
9 -> 9:59:52
10 -> 2022/11/28
11 -> 2022/11/28 10:05:45
12 -> 2022/11/28 10:05:48
13 -> a
14 -> bdds
15 -> 长文本数据0-65 535 bytes
16 -> 中等文本数据0-16 777 215 bytes
17 -> 极大文本数据0-4 294 967 295 bytesLONGTEXT
0 -> 3
1 -> 2
2 -> 3
3 -> 4
4 -> 5
5 -> 9223372036854780
6 -> -1.123456
7 -> -2.1245
8 -> 6.123456
9 -> 9:59:52
10 -> 2022/11/28
11 -> 2022/11/28 10:05:45
12 -> 2022/11/28 10:05:48
13 -> a
14 -> bdds
15 -> 长文本数据0-65 535 bytes
16 -> 中等文本数据0-16 777 215 bytes
17 -> 极大文本数据0-4 294 967 295 bytesLONGTEXT
读取成功
提示的异常或者没有达到的效果
没有抛出异常,期望能够正确获取到Excel中的Double内容,如3.12345678912345
相关代码已贴在GIthub -> https://github.com/BestBurning/EasyExcelProblem
clone后为Maven项目,仅依赖了EasyExcel,Excel也放在了Resource目录,可直接运行
相关Excel文件已贴在Github -> https://github.com/BestBurning/EasyExcelProblem/blob/main/src/main/resources/time_problem.xlsx
因为动态场景问题,无法定义特定的BeanClass,期望能用map去接收