//查看读取的数据内容
Cell cell =row.getCell(s);//}
switch(cell.getCellType()) {caseCell.CELL_TYPE_STRING:
System.out.print(cell.getRichStringCellValue().getString());//根据s判断它读的是一行内的第几个单元格//N行的第一个单元格
if (s == 0) {
crops.setId(AutoIdHelper.getId());
crops.setFarmName(cell.getRichStringCellValue().getString());
}else if (s == 1) {//N行的第2个单元格
crops.setFarmCrops(cell.getRichStringCellValue().getString());
}else if (s == 2) {//N行的第3个单元格
crops.setGatherTime(cell.getRichStringCellValue().getString());
}else if (s == 3) {//N行的第4个单元格
crops.setNongYuanBaoId(cell.getRichStringCellValue().getString());
}
System.out.print("|");break;caseCell.CELL_TYPE_NUMERIC:if(DateUtil.isCellDateFormatted(cell)) {
System.out.print(String.valueOf(cell.getDateCellValue()));
}else{
System.out.print(cell.getNumericCellValue());
}
System.out.print("|");break;caseCell.CELL_TYPE_BOOLEAN:
System.out.print(cell.getBooleanCellValue());
System.out.print("|");break;default:
}
}//读取图片代码(是一行一行读的)
XSSFPictureData pictureData =pictures.get(i);byte[] data =pictureData.getData();if (data==null) {
crops.setImage(null);
}else{
crops.setImage(newString(Base64.encodeBase64(data)));
}
System.out.println(newString(Base64.encodeBase64(data)));//把图片和文字添加到数据库
crops.save();
System.out.println();
}
System.out.println(wb.getSheetName(0));
renderSuccess("操作成功!!");
}
}