Workbook excelWB = null;
excelWB = new XSSFWorkbook(excelFile);
oneSheet = excelWB.getSheetAt(0);
oneRow = oneSheet.getRow(rowNum);
if (oneRow == null) {
continue;
}// 获取第几列对象
oneCell = oneRow.getCell(1);
if (oneCell == null) {
continue;
}
switch (oneCell.getCellType()) {
case HSSFCell.CELL_TYPE_STRING:
System.out.println(oneCell.getStringCellValue());
break;
case HSSFCell.CELL_TYPE_FORMULA:
System.out.println(oneCell.getCellFormula());
break;
case HSSFCell.CELL_TYPE_NUMERIC:
HSSFDataFormatter dataFormatter = new HSSFDataFormatter();
String cellFormatted = dataFormatter.formatCellValue(oneCell);
System.out.println( cellFormatted );
break;
case HSSFCell.CELL_TYPE_ERROR:
break;
}
将读取到的value处理下insert到表中即可