`

Bug 51173 - XSSFClientAnchor.setDx1() has no effect

 
阅读更多

http://blog.csdn.net/hantiannan/article/details/7012363 

 

 

ASF Bugzilla – Bug 51173

XSSFClientAnchor.setDx1() has no effect

Last modified: 2014-04-02 10:15:01 UTC

 
Bug 51173 - XSSFClientAnchor.setDx1() has no effect
Status: Product:Component:Version:Hardware:Importance: Target Milestone: Assigned To: URL:Keywords: Depends on:Blocks:  
RESOLVED INVALID
 
POI
XSSF
3.7-FINAL
PC All
 
P2 normal (vote)
---
POI Developers List
 
 
 
 
 
 
Show dependency tree
 
Reported: Modified: CC List:
2011-05-09 08:20 UTC by at13
2014-04-02 10:15 UTC (History)
0 users
 
 
 


Attachments

NoteYou need to log in before you can comment on or make changes to this bug.
 
Descriptionat13 2011-05-09 08:20:45 UTC
The methods:
setDx1(...)
setDx2(...)   
setDy1(...)
setDy2(...)

have no effect on XSSFClientAnchor.
On HSSFClientAnchor you can position/size a picture within the cell and it works, on XSSFClientAnchor it does not.
I also tried the newest 3.8-beta2 and it also does not work.
Comment 1Nick Burch 2011-05-09 15:58:41 UTC
Is the problem that the XML isn't changing, or that the expected effect in excel isn't seen? (These are two very different problems)
Comment 2at13 2011-05-10 08:14:54 UTC
Hello!
I created two xlsx files one with calling the setdx... methods and one without. Then I opened these files as zip files and compared the sheet1.xml files in the folder xl/worksheets. Both of the sheet1.xml-files were exactly the same.
So if I did everything correct, it seems that the methods have no effect on the creating of the XML. I am not very familiar with the internal structure of the xslx files.
Comment 3at13 2011-05-11 06:38:35 UTC
OK, these methods DOES have an effect. But the parameter values have to be much bigger in XSSFClientAnchor than in HSSFClientAnchor.
I have not find out yet, how to calculate these values or what unit they have. 
The JavaDoc only says e.g. for setDx1(int dx1):
"dx1 the x coordinate within the first cell"
but not what unit the parameter has.
Is there any documentation for that?
So I think there is no bug, so this bug entry can be closed?
Comment 4Nick Burch 2011-05-11 10:00:02 UTC
Could you try creating a few files with HSSF with various dx/dy values, then open these in Excel, save as .xlsx, and see what the values were written as? That might give us a hint on the scaling factor different between the two formats
Comment 5at13 2011-05-11 13:53:55 UTC
The secret is solved!
You have to calculate everything in pixels, the anchor-width and -height, the image-width and -height and with that the margin values (dx and dy).
In the setDx.../setDy... methods you have to multiply the dx/dy pixel-values with the constant XSSFShape.EMU_PER_PIXEL and voila, everything works!
Pleeeeeaaaase write JavaDocs for those secret things! I like the apache libraries and APIs very much and you guys make a great job, but documentation is very important for using the libraries.
Comment 6Nick Burch 2011-05-13 09:24:32 UTC
Note added in r1102624, thanks for the investigations!
Comment 7suman saurav 2013-07-24 11:18:05 UTC
Hi Nick,

I have same issue here. And I have tried every EMU value like XSSFShape.EMU_PER_PIXEL and multiplied it by 10 and 20, but it doesn't make an effect in converted sheet. Images are still coming at the edge of cell.

Below is the code, i am using write now:

XSSFClientAnchor anchor = new XSSFClientAnchor(XSSFShape.EMU_PER_PIXEL*200,XSSFShape.EMU_PER_PIXEL*200,0,0,(short)col,row,(short)col1,row1);

Please suggest, if i did anything wrong.

Thanks,
Saurav
Comment 8Malcolm McMahon 2014-04-02 10:15:01 UTC
(In reply to suman saurav from comment #7)
> Hi Nick,
> 
> I have same issue here. And I have tried every EMU value like
> XSSFShape.EMU_PER_PIXEL and multiplied it by 10 and 20, but it doesn't make
> an effect in converted sheet. Images are still coming at the edge of cell.
> 
> Below is the code, i am using write now:
> 
> XSSFClientAnchor anchor = new
> XSSFClientAnchor(XSSFShape.EMU_PER_PIXEL*200,XSSFShape.EMU_PER_PIXEL*200,0,0,
> (short)col,row,(short)col1,row1);
> 
> Please suggest, if i did anything wrong.
> 
> Thanks,
> Saurav


The real problem behind all these bug report seems to be in XSSFPicture.resize();

In here we find

 anchor.setCol2(col2);

 anchor.setDx1(0);  // !!


 anchor.setDx2(pref.getDx2());


 anchor.setRow2(row2);

 anchor.setDy1(0);  // !!

In other words calling resize discards any offsets you've set in your anchor.

I've replaced the resize call with:

Picture pic = drawing.createPicture(anchor, pictures.get(value));
ClientAnchor pref = pic.getPreferredSize();
anchor.setDx2(pref.getDx2() + anchor.getDx1());
anchor.setDy2(pref.getDy2() + anchor.getDy1());

And it works as expected. Something slightly more complicated would be needed if the picture extended over more than one cell.


 anchor.setDy2(pref.getDy2());

This kills any offsets you set, and if you don't call resize your picture will probably collapse.

The resize source could be changed easily enough to preserver dx1 and dy1, and I don't imagine any existing code would break.
 

 
This is ASF Bugzilla: the Apache Software Foundation bug system. In case of problems with the functioning of ASF Bugzilla, please contact bugzilla-admin@apache.orgPlease Note: this e-mail address is only for reporting problems with ASF Bugzilla. Mail about any other subject will be silently ignored.
分享到:
评论

相关推荐

    Netty (netty-3.2.5.Final.jar,netty-3.2.5.Final-sources.jar)

    这个版本是3.2.5.Final,这意味着它是3.2.x系列中的最后一个稳定版本,通常包含了一些修复的bug和改进的性能。 `netty-3.2.5.Final-sources.jar` 提供了Netty框架的源代码,这对于开发者来说是非常有价值的,因为它...

    PyPI 官网下载 | bugbug-0.0.146-py3-none-any.whl

    **PyPI官网下载 | bugbug-0.0.146-py3-none-any.whl** 在Python开发中,PyPI(Python Package Index)是官方的第三方Python软件包仓库,它为开发者提供了一个平台来发布他们的模块、库和其他工具,同时方便其他用户...

    PyPI 官网下载 | bugbug-0.0.355-py3-none-any.whl

    《PyPI官网下载:探索bugbug-0.0.355-py3-none-any.whl》 在Python的世界里,PyPI(Python Package Index)是最重要的资源库,它为开发者提供了一个平台来分享和下载Python软件包。本文将深入探讨PyPI官网下载的...

    selenium-java-2.47.1.zip

    2.47.1 版本可能修复了一些已知的bug,提高了稳定性,并增加了对新浏览器版本的支持。作为开发人员,你可以通过这个版本进行网页应用的功能测试、回归测试以及性能测试,确保软件的质量。 总之,"selenium-java-...

    Python库 | bugbug-0.0.50-py3-none-any.whl

    在这个场景中,我们关注的是名为"bugbug-0.0.50-py3-none-any.whl"的Python库。这个库的版本号是0.0.50,表明它可能还处于早期开发阶段,但已经可以使用。 `.whl`文件是Python的轮子(Wheel)格式,它是一种预编译...

    Marlin-bugfix-2.0.x

    Marlin-bugfix-2.0.x 是Marlin固件的一个特定版本,专注于修复已知问题和改进功能。Marlin是一款广泛使用的开源3D打印机固件,由C++编写,适用于多种基于ARM架构的微控制器,包括STM32F7在内的多款芯片。这个版本的...

    Python库 | bugbug-0.0.350-py3-none-any.whl

    Python库“bugbug-0.0.350-py3-none-any.whl”是一个用于Python开发的软件包,特别适合后端应用。这个压缩包是Python生态系统中的一个wheel文件,它是一种预编译的Python分发包格式,旨在简化安装过程,提高效率。在...

    mysql-connector-java-5.1.40.zip和mysql-connector-java-5.1.10.jar

    在版本差异上,5.1.40相对于5.1.10可能包含了一些bug修复、性能优化、新特性的添加或对旧版本的兼容性改进。选择哪个版本主要取决于你的项目需求,通常建议使用最新稳定版,以获取更好的性能和安全性。 在实际开发...

    [bug15570patch]kernel-3.10.0-957.1.3and5.1

    kernel-3.10.0-957.1.3.bug15570.plus.el7.x86_64.rpm kernel-3.10.0-957.5.1.bug15570.plus.el7.x86_64.rpm kernel-devel-3.10.0-957.1.3.bug15570.plus.el7.x86_64.rpm kernel-devel-3.10.0-957.5.1.bug15570.plus...

    PyPI 官网下载 | bugbug-0.0.350-py3-none-any.whl

    资源来自pypi官网。 资源全名:bugbug-0.0.350-py3-none-any.whl

    spring导入eclipse时少的spring-cglib-repack-3.2.4.jar和spring-objenesis-repack-2.4.jar

    1. 下载`spring-cglib-repack-3.2.4.jar`和`spring-objenesis-repack-2.4.jar`,通常可以在Maven中央仓库或者GitHub上找到对应版本的文件。 2. 将这两个jar包添加到你的项目的`lib`目录下,或者如果你使用的是Maven...

    Python库 | bugbug-0.0.57-py3-none-any.whl

    资源分类:Python库 所属语言:Python 使用前提:需要解压 资源全名:bugbug-0.0.57-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    Python库 | bugbug-0.0.295-py3-none-any.whl

    资源分类:Python库 所属语言:Python 资源全名:bugbug-0.0.295-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    Python库 | bugbug-0.0.299-py3-none-any.whl

    资源分类:Python库 所属语言:Python 资源全名:bugbug-0.0.299-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    Python库 | bugbug-0.0.163-py3-none-any.whl

    资源分类:Python库 所属语言:Python 资源全名:bugbug-0.0.163-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    Python库 | bugbug-0.0.113-py3-none-any.whl

    资源分类:Python库 所属语言:Python 资源全名:bugbug-0.0.113-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

Global site tag (gtag.js) - Google Analytics