springboot导入多sheet,获取sheet名称
/**
* 获取Excel中的sheet
* @param file
* @return
* @throws IOException
*/
public static Workbook getWorkBook(MultipartFile file) throws IOException {
//这样写excel能兼容03和07
InputStream is = file.getInputStream();
Workbook hssfWorkbook = null;
try {
hssfWorkbook = new HSSFWorkbook(is);
} catch (Exception ex) {
is =file.getInputStream();
hssfWorkbook = new XSSFWorkbook(is);
}
return hssfWorkbook;
}
可在导入的方法中调用该方法,通过workbook.getSheetName(i)
,获取sheet名称