public List<Student> importTemplate(MultipartFile file) throws Exception {
List<Student> studentList = new ArrayList<>();
//获取sheet页的数量
Workbook hssfWorkbook = new HSSFWorkbook(file.getInputStream());
int sheetNum = hssfWorkbook.getNumberOfSheets();
for (int sheetIndex = 0; sheetIndex < sheetNum; sheetIndex++) {
ImportParams param = new ImportParams();
//标题行数
param.setTitleRows(0);
//表头行数
param.setHeadRows(1);
//读取第几个sheet页
param.setStartSheetIndex(sheetIndex);
List<Student> students = ExcelImportUtil.importExcel(file.getInputStream(), Student.class, param);
studentList.addAll(students);
}
return studentList;
}
【easypoi多sheet页导入】
于 2023-06-13 09:43:52 首次发布