Aldjinn
Aldjinn

Reputation: 745

Java Excel API: Add images to the footer of excel files

I've got a bunch of huge excel reports created by JExcel. Now the company's styleguide has changed and somebody had the great idea to add some logos to the footer. Unfortunately, adding images to the header or footer is not possible with JExcel. As a workaround, I am currently modifying the PDF files created from the Excel files with iText and adding images to each page. The problem still remains: There is no image in the footer of the Excel file, only in the PDF file.

Has anybody an idea how to get rid of this problem? Is there any other free (?) Java Excel API that might help? I've tried Apache POI but without success.

Thanks in advance!

Upvotes: 0

Views: 3453

Answers (2)

vimal
vimal

Reputation: 11

WritableSheet s = w.createSheet("Report", 0);
BufferedImage input = ImageIO.read(new URL("http://example.com/image.jpg"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(input, "PNG", baos);
s.addImage(new WritableImage(0,0,input.getWidth() / CELL_DEFAULT_WIDTH, input.getHeight()       / CELL_DEFAULT_HEIGHT,baos.toByteArray()));
s.mergeCells(0,0,0,2);

The above code puts the image on top left corner if u need it at the bottom then just change the coordinates as per your wish.

Upvotes: 1

pgras
pgras

Reputation: 12770

As you can modify excel files with both Apache POI and JExcel why don't you use a template file already containing the logo in the footer ?

Upvotes: 1

Related Questions