Add image to HeaderFooter using Axlsx

686 Views Asked by At

Is there a way to add an image to a header footer using Axlsx?

header_footer = {:different_first => false, odd_header:'&C&14 &B&UHeader Text', odd_footer:'&L&11&BPage &P &C&11Footer Text &R&11&ILast updated:&D'}

@wb.add_worksheet(name: "Sheet1",:header_footer => header_footer) do |sheet|
    #add rows, etc.
end

I'd like to add an image to the Right section of the header and all of the examples are to place the image in a particular cell.

Any ideas on how I can accomplish this?

1

There are 1 best solutions below

2
On BEST ANSWER

To answer your question "Is there a way to add an image to a header footer using Axlsx?" is currently No. The header_footer.rb file in the axlsx github repository has the options to include a string with control characters that allow to include author name, dates, page numbers, etc. It states - "Headers and footers are generated using a string which is a combination of plain text and control characters". Also, the header_footer object is serialized to xml_string for processing.

So far, the only way of adding images in a sheet is via add_image method.