You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Toni Helenius <To...@syncrontech.com> on 2012/07/18 15:02:57 UTC
Extracting images from XSSF, no anchors
Hello,
I'm converting some HSSF specific code to use the generic SS one. I keep getting NPEs from XSSFPicture functions (using the Interface, Picture) since they don't contain anchors. Anchors are null. This generic code works just fine on HSSF.
I also need the locations of the images, so the getAllImages() just doesn't cut it.
XSSFDrawing drawing = ((XSSFSheet)sheet).createDrawingPatriarch();
// Get the shapes
for (XSSFShape shape : drawing.getShapes()) {
if (shape instanceof Picture) {
ClientAnchor anchor = picture.getPreferredSize(); //Fails on XSSF
}
}
I found something here, possibly some coordinates that I need to convert but this seems very ugly. If it even works...
((XSSFPicture)picture).getCTPicture().getSpPr().getXfrm().getOff();
Can somebody help me please?
--
Toni Helenius
Syncron Tech Oy
FIN-53850 LAPPEENRANTA
Street address: Laserkatu 6
Mobile: +358 (0) 400 213 218
Tel: +358 (0) 102176908
Fax: +358 (0) 102176907
www.syncrontech.com
toni.helenius@syncrontech.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
RE: Extracting images from XSSF, no anchors
Posted by Toni Helenius <To...@syncrontech.com>.
Hello,
Thanks for the quick reply. Here:
https://issues.apache.org/bugzilla/show_bug.cgi?id=53568
-----Original Message-----
From: Yegor Kozlov [mailto:yegor.kozlov@dinom.ru]
Sent: 18. heinäkuuta 2012 18:53
To: POI Users List
Subject: Re: Extracting images from XSSF, no anchors
I confirmed the problem: shape.getAnchor() returns null when reading shapes from worksheet.
Can you create a new bug in Bugzilla and attach sample Java code that demonstrates the problem and the .xlsx file you are reading.
Yegor
On Wed, Jul 18, 2012 at 5:02 PM, Toni Helenius <To...@syncrontech.com> wrote:
> Hello,
>
> I'm converting some HSSF specific code to use the generic SS one. I keep getting NPEs from XSSFPicture functions (using the Interface, Picture) since they don't contain anchors. Anchors are null. This generic code works just fine on HSSF.
>
> I also need the locations of the images, so the getAllImages() just doesn't cut it.
>
> XSSFDrawing drawing = ((XSSFSheet)sheet).createDrawingPatriarch();
>
> // Get the shapes
> for (XSSFShape shape : drawing.getShapes()) {
> if (shape instanceof Picture) {
> ClientAnchor anchor = picture.getPreferredSize(); //Fails on XSSF
> }
> }
>
> I found something here, possibly some coordinates that I need to convert but this seems very ugly. If it even works...
> ((XSSFPicture)picture).getCTPicture().getSpPr().getXfrm().getOff();
>
> Can somebody help me please?
>
> --
> Toni Helenius
> Syncron Tech Oy
> FIN-53850 LAPPEENRANTA
> Street address: Laserkatu 6
> Mobile: +358 (0) 400 213 218
> Tel: +358 (0) 102176908
> Fax: +358 (0) 102176907
> www.syncrontech.com
> toni.helenius@syncrontech.com
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org For additional
> commands, e-mail: user-help@poi.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org For additional commands, e-mail: user-help@poi.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Extracting images from XSSF, no anchors
Posted by Yegor Kozlov <ye...@dinom.ru>.
I confirmed the problem: shape.getAnchor() returns null when reading
shapes from worksheet.
Can you create a new bug in Bugzilla and attach sample Java code that
demonstrates the problem and the .xlsx file you are reading.
Yegor
On Wed, Jul 18, 2012 at 5:02 PM, Toni Helenius
<To...@syncrontech.com> wrote:
> Hello,
>
> I'm converting some HSSF specific code to use the generic SS one. I keep getting NPEs from XSSFPicture functions (using the Interface, Picture) since they don't contain anchors. Anchors are null. This generic code works just fine on HSSF.
>
> I also need the locations of the images, so the getAllImages() just doesn't cut it.
>
> XSSFDrawing drawing = ((XSSFSheet)sheet).createDrawingPatriarch();
>
> // Get the shapes
> for (XSSFShape shape : drawing.getShapes()) {
> if (shape instanceof Picture) {
> ClientAnchor anchor = picture.getPreferredSize(); //Fails on XSSF
> }
> }
>
> I found something here, possibly some coordinates that I need to convert but this seems very ugly. If it even works...
> ((XSSFPicture)picture).getCTPicture().getSpPr().getXfrm().getOff();
>
> Can somebody help me please?
>
> --
> Toni Helenius
> Syncron Tech Oy
> FIN-53850 LAPPEENRANTA
> Street address: Laserkatu 6
> Mobile: +358 (0) 400 213 218
> Tel: +358 (0) 102176908
> Fax: +358 (0) 102176907
> www.syncrontech.com
> toni.helenius@syncrontech.com
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org