我怎样才能find一个单元格,其中包含在apache poi中的图片

我尝试在xls文档中循环显示图像。 我写下一个代码:

HSSFPatriarch patriarch = sheet.getDrawingPatriarch(); if (patriarch != null) { // Loop through the objects for (HSSFShape shape : patriarch.getChildren()) { if (shape instanceof HSSFPicture) { HSSFPicture picture = (HSSFPicture) shape; if (picture.getShapeType() == HSSFSimpleShape.OBJECT_TYPE_PICTURE){ if (picture.getImageDimension() != null) { // how to get cell, which contains this picture } } } } } 

如何在一张表中find每张图片的单元格?

更新 ,现在我写下一个工作代码:

 HSSFPatriarch patriarch = sheet.getDrawingPatriarch(); if (patriarch != null) { // Loop through the objects for (HSSFShape shape : patriarch.getChildren()) { if (shape instanceof HSSFPicture) { HSSFPicture picture = (HSSFPicture) shape; if (picture.getShapeType() == HSSFSimpleShape.OBJECT_TYPE_PICTURE){ if (picture.getImageDimension() != null) { // how to get cell, which contains this picture if (picture.getImageDimension() != null) { Row row = sheet.getRow(picture.getPreferredSize().getRow1()); if (row != null) { Cell cell = row.getCell(picture.getPreferredSize().getCol1()); HSSFPictureData pictureData = picture.getPictureData(); byte[] data = pictureData.getData(); File file = new File(PATH + picture.getFileName() + "." + pictureData.suggestFileExtension()); try (FileOutputStream fop = new FileOutputStream(file)) { if (!file.exists()) { file.createNewFile(); } fop.write(data); fop.flush(); fop.close(); } catch (IOException e) { e.printStackTrace(); } } } } } } } } 

如果你像我一样需要将图片与一个单元格相分离,请尝试使用HashMap()。

有人可以写这个任务的例子吗? 我想find单元格,在excel表单中包含一张图片。 诀窍在于,什么画面不是细胞的价值。