You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2012/01/23 17:05:01 UTC
DO NOT REPLY [Bug 52504] New: Can't insert picture on a XSSFWorkbook
https://issues.apache.org/bugzilla/show_bug.cgi?id=52504
Bug #: 52504
Summary: Can't insert picture on a XSSFWorkbook
Product: POI
Version: 3.8-dev
Platform: Other
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
AssignedTo: dev@poi.apache.org
ReportedBy: felipe.issa@simova.com.br
Classification: Unclassified
Created attachment 28195
--> https://issues.apache.org/bugzilla/attachment.cgi?id=28195
Sample code.
I'm using apache poi 3.8 beta 5 (20111217) it It cant add a picture on a
XSSFWorkbook using the margin I configured at the anchor. The same code works
normally when I try to insert it on a HSSFWorkbook.
The only way i found to display the picture was to call picture.resize, but if
i do this it will ignore the dx and dy values I configured at the Anchor.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
DO NOT REPLY [Bug 52504] Can't insert picture on a XSSFWorkbook
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52504
Yegor Kozlov <ye...@dinom.ru> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |WONTFIX
OS/Version| |All
--- Comment #1 from Yegor Kozlov <ye...@dinom.ru> 2012-02-03 11:23:43 UTC ---
The problem is that XSSF interprets dx and dy offsets differently than HSSF.
In HSSF dx is a fraction of cell width in units of 1/1024.
anchor.setDx1(400) sets the offset to approximately 40% of the cell width
(400/1024) and anchor.setDx2(655) sets the second dx offset to 65% of the cell.
that is, the image is located in the middle of the cell between 40% and 65% of
the width.
In XSSF all dx and dy offsets are set in EMUS (one pixel is 9525 EMUs) and the
equivalent code to anchor your image is as follows:
anchor.setDx1(25*XSSFShape.EMU_PER_PIXEL);
anchor.setDx2(41*XSSFShape.EMU_PER_PIXEL);
anchor.setDy1(1*XSSFShape.EMU_PER_PIXEL);
anchor.setDy2(14*XSSFShape.EMU_PER_PIXEL);
Setting dx and dy offsets is not portable between HSSF and XSSF. Change your
code to set them in pixels. If both .xls and .xlsx should be supported then add
a 'if' clause for each format:
if(wb instanceof HSSFWorkbook){
anchor.setDx1(400);
anchor.setDx2(655);
anchor.setDy1(10);
anchor.setDy2(200);
} else {
anchor.setDx1(25*XSSFShape.EMU_PER_PIXEL);
anchor.setDx2(41*XSSFShape.EMU_PER_PIXEL);
anchor.setDy1(1*XSSFShape.EMU_PER_PIXEL);
anchor.setDy2(14*XSSFShape.EMU_PER_PIXEL);
}
Cheers,
Yegor
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org