You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Oytun Emre Yücel <oy...@linxa.com> on 2015/03/17 16:49:32 UTC

Getting image locations in POI

Greetings,

I have been trying to extract image locations from SS (both XSSF and HSSF).
The getAllPictures method works fine, but since I am trying to build
another table from what I'm reading from Excel, I also need to transfer the
Image to this table at the exact cell. The current PictureData class
doesn't include any location specific info as far as I can see.

Thank you in advance

-- 

Oytun Emre Yücel

Re: Getting image locations in POI

Posted by Andreas Beeker <ki...@apache.org>.
Hi,

you'll need to a DrawingPatriarch, something like this to read the location:
XSSFWorkbook wb = new XSSFWorkbook("test.xlsx");
XSSFDrawing dp = wb.getSheetAt(0).createDrawingPatriarch();
List<XSSFShape> pics = dp.getShapes();
for (XSSFShape p : pics) {
   if (p instanceof XSSFPicture) {
      XSSFClientAnchor anchor = ((XSSFPicture)p).getClientAnchor();
   }
}

and to set the location in the destination file, look at
http://poi.apache.org/spreadsheet/quick-guide.html#Images

Of course you'll need to copy the image data itself too, but as you wrote,
you have already the image data.

Best wishes,
Andi


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org