Hi,
 
I will try getting the latest build and try this method.
thanks!
 
The sample code I am currently using is:
 
try{
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet("new sheet"); 
             
        sheet.setColumnWidth((short)2, (short) 5250);

            HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
            HSSFClientAnchor anchor; 
            
             for(int i=0;i<2;i++){  
                                
                HSSFRow row     = sheet.createRow((short)i);
                HSSFCell cell   = row.createCell((short)0);
        
                row.createCell((short)0).setCellValue(i+1);
                row.createCell((short)1).setCellValue("Compound " + (i+1));
                row.setHeight((short)2500);       
                //sheet.addMergedRegion(new Region(i,(short)2,i,(short)5));     
   
                
                anchor = new HSSFClientAnchor(0,0,0,0,(short)2,i,(short)5,i);
                anchor.setAnchorType( 3 ); --tried using 2 as well!
                patriarch.createPicture(anchor, loadPicture( <image path>, wb 
));
             }
             
        }catch(IOException ex)
        {
            System.out.println("Error!!");
        }
 
This resizes the image and extends as per the row height and column width.
 
Let me know if theres something I am missing or doing incorrectly.
 
Regards,
PRachi

________________________________

From: Yegor Kozlov [mailto:[EMAIL PROTECTED]
Sent: Fri 19/10/2007 13:58
To: POI Users List
Subject: Re[4]: Export an image as PNG to a particular cell in Excel using POI.




>
> I could not find HSSFPicture.resize() .
> May be I dont have the updated APIs.
You need to build POI from svn or download a daily build from 
http://encore.torchbox.com/poi-svn-build/.

> But would this retain the original size of the image?
Yes, HSSFPicture.resize() adjusts anchor to the actual image
dimensions.

> 
> 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?
>

Would you provide sample code?

Yegor

> ________________________________

> 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]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to