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
|
|
|
||||||||||||||||||||||
|
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. 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) 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. 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? 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 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. 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 (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. |
相关推荐
Marlin 新发布的版本源码,支持STM32F7等,多款ARM芯片的主板。整个代码的的构架有较大的调整。模块化更清晰。
./code --install-extension MS-CEINTL.vscode-language-pack-zh-hans-1.41.1.vsix
python库。 资源全名:bugbug-0.0.50-py3-none-any.whl
python库,解压后可用。 资源全名:bugbug-0.0.350-py3-none-any.whl
资源来自pypi官网。 资源全名:bugbug-0.0.355-py3-none-any.whl
资源来自pypi官网。 资源全名:bugbug-0.0.350-py3-none-any.whl
资源来自pypi官网。 资源全名:bugbug-0.0.146-py3-none-any.whl
资源分类:Python库 所属语言:Python 使用前提:需要解压 资源全名:bugbug-0.0.57-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源分类:Python库 所属语言:Python 资源全名:bugbug-0.0.295-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源分类:Python库 所属语言:Python 资源全名:bugbug-0.0.299-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源分类:Python库 所属语言:Python 资源全名:bugbug-0.0.163-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源分类:Python库 所属语言:Python 资源全名:bugbug-0.0.113-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059