I've needed to create a custom invoice using Python XlsxWriter, where I need to create a custom header with a company logo. The resulting workbook must be opened using LibreOffice, not Excel.
Using the example from here. My code is:
#!/usr/bin/env python
try:
import xlsxwriter
except ImportError as e:
print e
exit()
workbook = xlsxwriter.Workbook('tmp.xlsx')
preview = 'Select Print Preview to see the header and footer'
# Insert a header image.
#
worksheet1 = workbook.add_worksheet('Simple')
header1 = '&L&G'
footer1 = '&LHere is some left aligned text.'
worksheet1.set_header(header1, {'image_left': 'logo.png'})
worksheet1.set_footer(footer1)
worksheet1.set_margins(top=1.3)
# Insert an image.
worksheet1.write('A2', 'Insert an image in a cell:')
worksheet1.insert_image('B2', 'logo.png')
worksheet1.set_column('A:A', 50)
worksheet1.write('A1', preview)
workbook.close()
While my logo can be inserted in B2 cell, my image is not to be found in the header, when opened with LibreOffice. The image appears as it should in Excel.