利用POI包读取excel,不分excel文件格式

File file = new File(filePath);
InputStream io = new FilePathStream(file);
Workbook wb = WorkbookFactory.create(io);
//获取第一个sheet
Sheet sheet = wb.getSheetAt(0);
//获取第一行
Row rowline = sheet.getRow(0);
//获取第一个字段,需要先用getCellType()判断字段类型,如果是字符串,则用getStringCellValue()取值,如果是数字,则用getNumericCellValue()取值
String col = rowline.getCell(0).getStringCellValue();

猜你喜欢

转载自blog.csdn.net/daijiguo/article/details/81808704