Bug 51341

Summary: Adding Image to Header in Excel Using HSSF
Product: POI Reporter: shafiexp
Component: HSSFAssignee: POI Developers List <dev>
Severity: critical    
Priority: P2    
Version: 3.7-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Bug Depends on:    
Bug Blocks: 53010    
Attachments: Header Image Problem

Description shafiexp 2011-06-08 16:21:34 UTC
Created attachment 27132 [details]
Header Image Problem


My Requirement is insert image to header inn excel file,

As POI doesn't support for this,
I have created Image header in Template Excel File manually by using MS-Excel.

Then I opened that Excel File by using POI(POIFSFileSystem) and then after I have Manipulated String data and Images into that existing Excel Template.

I have stored above entire workbook in another excel file.

Then when I pen that excel file,

in that file Header Image and data coming,
I'm not able to see the Image which I have inserted after opening that excel.

Please help me in this case.

Here I'm attaching that files

Comment 1 Yegor Kozlov 2011-06-14 11:59:28 UTC
It is a limitation of HSSF - it can create drawings from scratch, but cannot
modify existing ones. This means that if you add an image to a sheet that
already has graphic objects then the existing graphic objects are invalidated. 

XSSF does not have this limitation and should work fine for you. Convert your
template in the .xlsx format and you will be good.

P.S. Please post usage questions to the poi-user list. Bugzilla is for
submitting bugs.


*** This bug has been marked as a duplicate of bug 51287 ***
Comment 2 Evgeniy Berlog 2012-08-12 12:03:41 UTC
This problem should be fixed in trunk. Anyway, you have a bug in your code. 

ClientAnchor anchor=helper.createClientAnchor();
int picIndex=wb.addPicture(img_bytes.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG);

Anchor.row1 == anchor.row2 and anchor.dx1 == anchor.dx2 , so the width of your image is equals to 0

Please try with a nightly build - see download links on http://poi.apache.org/
or build yourself from SVN trunk, see http://poi.apache.org/subversion.html