Adding Header and Footer content to existing .xlsx file

Viewed 179

I have some existing .xlsx files. I want to add content to the header and footer to each file in every worksheet without changing the content within the file. I have the following code with the xlsxwriter module:

import xlsxwriter

workbook = xlsxwriter.Workbook('headers_footers.xlsx')
preview = 'Select Print Preview to see the header and footer'

worksheet = workbook.add_worksheet('Test')
header = '&L&G'
footer = '&L Content Footer'

worksheet.set_header(header, {'image_left': 'logo_white.jpg'})
worksheet.set_footer(footer)

workbook.close()

Works fine when creating a new .xlsx file but it does not adding the header- and footercontent to existing files. Where is the problem?

Thanks

1 Answers

For everyone who want to do the same: I contacted the Developerl. There is no possibility to change existing .xlsx files with xlsxwriter. The Dev recommend openpyxl instead.

Related