Cant set worksheet header (xlsxwriter Python)

580 Views Asked by At
hereworkbook = xlsxwriter.Workbook(<filename>)
worksheet = workbook.add_worksheet()
worksheet.set_header("&A" + str(<text>))

So i tried to set it, but I've got nothing as the result.

1

There are 1 best solutions below

0
On

It should work. Here is a working example based on your snippet:

import xlsxwriter

workbook = xlsxwriter.Workbook('header.xlsx')
preview = 'Select Print Preview or Page Layout to view header'

worksheet = workbook.add_worksheet('My Worksheet')

worksheet.set_header("&A" + " - Some text")

worksheet.set_column('A:A', 50)
worksheet.write('A1', preview)

workbook.close()

And here is the output from the Page Layout mode in Excel:

enter image description here