100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > excel中图片导入mysql_把Excel的数据(文字 图片)导入MySQL数据库

excel中图片导入mysql_把Excel的数据(文字 图片)导入MySQL数据库

时间:2024-07-26 02:30:36

相关推荐

excel中图片导入mysql_把Excel的数据(文字 图片)导入MySQL数据库

//查看读取的数据内容

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("操作成功!!");

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。