作者:cndz 围观群众:1991 更新于 2023-11-28 16:43:08 标签:easyExcelspring boot
最近在做个excel上传功能,模板包含10左右个sheet页,想着通过sheet_no来读取的话,如果有增加修改sheet页的情况,不太好修改,所以使用sheet名来读取,期间判断某sheet名是否存在。
import com.alibaba.excel.EasyExcel; public class ExcelUtil { public static boolean isSheetExist(String filePath, String sheetName) { boolean isExist = false; EasyExcel.read(filePath).build().excelExecutor().sheetList().stream() .filter(sheet -> sheet.getSheetName().equalsIgnoreCase(sheetName)) .findFirst() .ifPresent(sheet -> isExist = true); return isExist; } }