2

I am using Apache POI 4.1 to generate Excel reports. I have a requirement to include logo image as Header event in Sheet. I could find the only below code, which adds text in Header. Is there any way to include image in the Header section of Sheet?

SXSSFWorkbook workBook = new SXSSFWorkbook(100);
SXSSFSheet  sheet = workBook.createSheet("Sample Sheet");
Header header=  sheet.getHeader();
header.setCenter("Header");
shihabudheenk
  • 593
  • 5
  • 18
  • [this may help](https://stackoverflow.com/questions/33712621/how-put-a-image-in-a-cell-of-excel-java/33721090) – madhepurian Sep 25 '19 at 07:48
  • @deshi Thanks for the input. This will add the image only to a specific cell. I want it as a Header event so that, poi will print the image on the header of each newly created pages dynamically – shihabudheenk Sep 25 '19 at 08:16
  • You can encapsulate the logic of adding image to sheet to be a method, and call it after you creating a new sheet. – LHCHIN Sep 25 '19 at 09:14
  • @LHCHIN Thanks for the answer. This will help only upon creating a new Sheet and adding the Header. I want it to add as Header of a single sheet. ie Set Header on each page break in a single sheet – shihabudheenk Sep 25 '19 at 09:43
  • See https://stackoverflow.com/questions/51077404/apache-poi-adding-watermark-in-excel-workbook/51103756#51103756 for how to set an image as header content in `Excel`. – Axel Richter Sep 25 '19 at 11:46

0 Answers0