Hi, I could not find HSSFPicture.resize() . May be I dont have the updated APIs. But would this retain the original size of the image? Even if I set the anchor type to 2 or 3, it does resize the image and extends to the number of columns specified. Am I missing something? -Prachi
________________________________ From: Yegor Kozlov [mailto:[EMAIL PROTECTED] Sent: Tue 16/10/2007 15:04 To: POI Users List Subject: Re[2]: Export an image as PNG to a particular cell in Excel using POI. I've recently added HSSFPicture.resize() which resizes image anchor to the actual width and height. It might be useful to you. If you want to set the anchor manually you need to change the anchor type as follows: anchor.setAnchorType(2); //Move but don't size with cells By default anchor type=0 which means "Move and size with Cells" and it is what is happening with your image: it gets resized when you resize the columns. > Also, if I need to fit the image to just 1 column and 1row and not > span multiple cols/rows, how should the following API be used: > anchor = new HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7); > I am quite confused on the x/y coordinates. The first four values define the offset in the top-left and bottom-right cells. If you need to fit an image to exactly 1 column and 1 row leave them 0. The next four values are 0-based coordinates of the top-left and bottom-right cells. So, to put an image in 1x1 cell the anchor would be new HSSFClientAnchor(0,0,0,0,(short)col1, row1,(short)(col1+1), row+1); where col1 and row1 are coordinates of the top-left cell. Regards, Yegor > Any help on its usage would be appreciated. > > Thanks, > Prachi > ________________________________ > From: Nick Burch [mailto:[EMAIL PROTECTED] > Sent: Mon 15/10/2007 11:19 > To: POI Users List > Subject: RE: Export an image as PNG to a particular cell in Excel using POI. > On Fri, 12 Oct 2007, [EMAIL PROTECTED] wrote: >> Yes, the positioning can be achieved, but then as the documentation >> says, that any existing image would be erased with the new image. > I didn't write the code so I can't be sure, but I have a feeling that the > warning relates to images already in the file when you start, not ones you > add in. So, you ought to be fine to open the file up, and add several > images to it before closing. > Nick > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
