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 ));
     }


Reply via email to