1.代码实现
ObjectMapper objectMapper = new ObjectMapper();
String rootPath = System.getProperty("user.dir");
String name = "hello.xlsx";
File file = new File(rootPath + File.separator+"file"+File.separator+name);
ImportParams params = new ImportParams();
params.setTitleRows(1);
params.setHeadRows(1);
List result = ExcelImportUtil.importExcel(file, ExcelItem.class, params);
List<ExcelItem> list = new ArrayList<>();
for (Object obj : result) {
list.add(objectMapper.convertValue(obj, ExcelItem.class));
}
System.out.println(list);
System.out.println(list.size());