@Slf4j
public class ReadExcelData {
public static XSSFWorkbook getWorkbook(String filePath) {
XSSFWorkbook wb = null;
try{
wb = new XSSFWorkbook(new FileInputStream(filePath));
}catch(Exception e){
e.printStackTrace();
}
return wb;
}
public static XSSFSheet getSheet(String filePath,int sheetIndex){
XSSFSheet sheet = null;
try{
sheet = getWorkbook(filePath).getSheetAt(sheetIndex);
}catch(Exception e){
e.printStackTrace();
}
return sheet;
}
public static XSSFCell getCell(String filePath,int sheetIndex,int rowIndex,int cellNum){
XSSFCell cell = null;
try{
cell = getWorkbook(filePath).getSheetAt(sheetIndex)
.getRow(rowIndex).getCell(cellNum);
}catch(Exception e){
e.printStackTrace();
}
return cell;
}
public static Object getCellValueFromCellType(XSSFCell cell){
int cellType = cell.getCellType();
Object cellValue = null;
switch (cellType) {
case 0:
cellValue = cell.getNumericCellValue();
break;
case 1:
cellValue = ce
读Excel获取List<Map<String, Object>>2
最新推荐文章于 2024-07-20 16:40:31 发布