Inserting Image to Header and Footer

294 views
Skip to first unread message

Talha Ağaoğlu

unread,
Jan 6, 2022, 3:21:03 AM1/6/22
to openpyxl-users
Hi,

I am trying to edit a template but as I understand openpyxl sometime removes the image. Interestingly some images keep being existing...

Is there a way to add insert to the header and footer? or do you know any lib that supports edit xlsx files without breaking the style?

Thanks in advance

Charlie Clark

unread,
Jan 6, 2022, 5:16:48 AM1/6/22
to openpyxl-users
On 6 Jan 2022, at 9:21, Talha Ağaoğlu wrote:

> Hi,
>
> I am trying to edit a template but as I understand openpyxl sometime
> removes the image. Interestingly some images keep being existing...

Images in worksheets will generally be preserved but not in headers or footers. Support should be possible but would be quite complicated and isn't on my personal agenda.

> Is there a way to add insert to the header and footer? or do you know any
> lib that supports edit xlsx files without breaking the style?

Amongst Python libraries, Openpyxl definitely has the most extensive support for Excel files. If you have Excel on your machine, you could try xlwings which uses Excel to handle files.

Charlie

--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Sengelsweg 34
Düsseldorf
D- 40489
Tel: +49-203-3925-0390
Mobile: +49-178-782-6226

Talha Ağaoğlu

unread,
Jan 6, 2022, 5:20:12 AM1/6/22
to openpyxl-users
I did the hacky way.

Remove header and footer, make (almost 0 pixels) shorter header and areas and put images on the sheet itself. In this way, images does not disappear and looks like it is on the header.

6 Ocak 2022 Perşembe tarihinde saat 13:16:48 UTC+3 itibarıyla charli...@clark-consulting.eu şunları yazdı:

Jason Cobble

unread,
Apr 21, 2022, 7:01:12 AM4/21/22
to openpyxl-users
;/
Reply all
Reply to author
Forward
0 new messages