You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Sudheer Raju <rn...@gmail.com> on 2010/07/30 09:20:43 UTC

Re: Writing image to HSSFHeader or HSSFFooter

Hi,
Is it possible to read a Excel file which has an Image added to
Header/Footer.
Even I am stuck with the same problem, let me know in case any of you guys
get a solution for this problem.

Thanks,
Sudheer



MSB wrote:
> 
> As far as I am aware, the answer to this questionis no, teher is no simple
> way to accomplish this task with POI.
> 
> You do however have two options, the first of which is to create a
> template using Excel. This way, you can create the header/footer and add
> the image using Microsoft's application and then save the file away as a
> templte. Next, open the file using POI and populate the worksheet(s) with
> data and I think that I am correct when I say that the image should be
> preserved/copied successfully by the api.
> 
> The ability to add images to headers/footers is quite a recent addition to
> Excel - I think that versions prior to 2002/3 did not support this feature
> so you may need to be aware of that limitation if some of your users still
> have, for example, Excel 2000. There are ways to circumvent the issue and
> trick Excel into seemingly placing images in header/footers. In essence,
> you place the logo into a cell at the top of the sheet and then set the
> number of rows to be repeated at the top of each page to include this
> row/rows. I have never tried it but the support does exist in the API -
> for example it is possible to place an image into cell A1 for example and
> the HSSFSheet class does offer the setRepeatingRowsAndColumns(int
> sheetIndex, int startColumn, int endColumn, int startRow, int endRow)
> method. It should be easy enough to put together some code to test this
> hypothesis out.
> 
> Yours
> 
> Mark B
> 
> 
> Nikkie wrote:
>> 
>> My requirement is to write data to excel Header & Footer section which is
>> accomplished using the following code.
>> 
>>                    HSSFHeader header=this.sheet.getHeader();
>>                     header.setCenter("XXX");
>>                     header.setLeft("YYY");
>>                     header.setRight(HSSFHeader.page());
>>                     
>>                     HSSFFooter footer=this.sheet.getFooter();
>>                     
>>                     footer.setCenter("XXX");
>>                     footer.setLeft("YYY");
>>                     footer.setRight("ZZZ");
>> 
>> My question is how can I write an image (for eg:a logo)to the
>> header/footer?
>> setCenter()
>> setLeft()
>> setRight()
>> alll expects String
>> 
>> Please help me to resolve the issue.
>> 
>> 
>> Regards
>> Nikkie
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Writing-image-to-HSSFHeader--or-HSSFFooter-tp26790805p29303478.html
Sent from the POI - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org