List of usage examples for org.apache.poi.xssf.usermodel XSSFClientAnchor getCol1
public short getCol1()
From source file:nc.noumea.mairie.appock.services.impl.ImportExcelServiceImpl.java
License:Open Source License
private PhotoArticleCatalogue recuperePhotoArticleCatalogue(XSSFSheet firstSheet, String nomFichier, int numRow, String reference) throws IOException, ImportExcelException { Stream<XSSFShape> shapeStream = firstSheet.getDrawingPatriarch().getShapes().stream() // .filter(shape -> {// w ww .jav a 2s.c om if (!(shape instanceof XSSFPicture)) { return false; } XSSFPicture picture = (XSSFPicture) shape; XSSFClientAnchor anchor = (XSSFClientAnchor) picture.getAnchor(); XSSFRow pictureRow = firstSheet.getRow(anchor.getRow1()); return (anchor.getCol1() == IMPORT_EXCEL_COLONNE_PHOTO && pictureRow != null && pictureRow.getRowNum() == numRow); }); List<XSSFShape> listeShape = shapeStream.collect(Collectors.toList()); if (listeShape.isEmpty()) { throw new ImportExcelException(numRow + 1, reference, "Aucune image n'a t trouve"); } else if (listeShape.size() > 1) { throw new ImportExcelException(numRow + 1, reference, "Plusieurs images ont t trouves"); } XSSFPicture picture = (XSSFPicture) listeShape.get(0); byte[] content = picture.getPictureData().getData(); content = AppockUtil.scale(content, 80, 80); if (content == null) { throw new ImportExcelException(numRow + 1, reference, "Aucune image n'a t trouve"); } return catalogueService.savePhotoArticleCatalogue(content, nomFichier); }