Iam using .png 


[EMAIL PROTECTED] 
05.12.2006 13:48
Bitte antworten an
poi-user@jakarta.apache.org


An
poi-user@jakarta.apache.org
Kopie

Thema
Re: Add images to  a cell  using POI 2.5  ---Help urgent






I am pretty sure you should be able to use a template that includes an 
image and then create a workbook based upon that template. What type of 
image are you using (.jpg, .png, .bmp)? It may be that it is simply the 
'wrong' type.

[EMAIL PROTECTED] wrote: I want to have a logo in a cell and 
tried having it part of the template 
and loading it ..
While trying to open gives error which otherwise works perfectly without 
the image ..
Therefore tried the following  code...

But POI 2.5 does not support createPicture() method of patriach and 
addPicture () of workbook ..

Is there  a way out for this ..please help ..


Regards 

Hepzibah

private int loadPicture( String path, HSSFWorkbook wb ) throws IOException
    {
        int pictureIndex;
        FileInputStream fis = null;
        ByteArrayOutputStream bos = null;
        try
        {
            fis = new FileInputStream( path);
            bos = new ByteArrayOutputStream( );
            int c;
            while ( (c = fis.read()) != -1)
                bos.write( c );
            pictureIndex = wb.addPicture( 
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG); 
        }
        finally
        {
            if (fis != null)
                fis.close();
            if (bos != null)
                bos.close();
        }
        return pictureIndex;
    }
        private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws 
IOException
    {
                HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
        HSSFClientAnchor anchor;
        anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14);
        //anchor.setAnchorType(2);
        patriarch.createPicture(anchor, loadPicture( 
"/images/logos/DC.png", wb ));
     }




 
---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.

Reply via email to