Formatted headers/footers? Colour Code
Question: I've found out the way to format header and footer using xlwt (see
<https://groups.google.com/forum/?fromgroups#!topic/python-
excel/3hZP_hK_LSc>),

I'm looking for docs or example on how to define the font color for this
header and footer? any example.


Answer: According to the xlwt [docs](http://open-hea.googlecode.com/hg-
history/e3c022eb2a9a895519930b891dc9ac0a8c09020d/docs/html/xlwt.html#xlwt.BIFFRecords.HeaderRecord),
you can manage just font, font style and font height. You may have found that
there is a special `&K` (e.g. for red `&Kff0000`) notation for header/footer
font color, but it doesn't really work for `xls` (2003) format files.

If you are ok to generate `xlsx` instead - you can choose from
[openpyxl](https://openpyxl.readthedocs.org/en/latest/) or
[xlsxwriter](https://xlsxwriter.readthedocs.org/en/latest/).

Here's an example using `openpyxl`:

    
    
    from openpyxl import Workbook
    
    wb = Workbook()
    ws = wb.worksheets[0]
    
    ws.header_footer.center_header.font_size = 14
    ws.header_footer.center_header.font_name = "Tahoma,Bold"
    ws.header_footer.center_header.text = "Hello, World!"
    ws.header_footer.center_header.font_color = "FF0000"
    
    wb.save('output.xlsx')
    

Here's an example using `xlsxwriter`:

    
    
    from xlsxwriter.workbook import Workbook
    
    workbook = Workbook('output.xlsx')
    worksheet = workbook.add_worksheet()
    
    worksheet.set_header('&"Tahoma,Bold"&14&Kff0000Hello, World!')
    
    workbook.close()
    

Hope that helps.

