class Styler(bg_color=None, bold=False, font='Arial', font_size=12.0, font_color=None, number_format='General', protection=False, underline=None, border_type='thin', horizontal_alignment='center', vertical_alignment='center', wrap_text=True, shrink_to_fit=True, fill_pattern_type='solid', indent=0.0, comment_author=None, comment_text=None, text_rotation=0, date_format='DD/MM/YY', time_format='HH:MM', date_time_format='DD/MM/YY HH:MM')

Used to represent a style

  • bg_color (str: one of utils.colors, hex string or color name ie ‘yellow’ Excel supports) – The background color

  • bold (bool) – If True, a bold typeface is used

  • font (str: one of utils.fonts or other font name Excel supports) – The font to use

  • font_size (int) – The font size

  • font_color (str: one of utils.colors, hex string or color name ie ‘yellow’ Excel supports) – The font color

  • number_format (str: one of utils.number_formats or any other format Excel supports) – The format of the cell’s value

  • protection (bool) – If True, the cell/column will be write-protected

  • underline (str: one of utils.underline or any other underline Excel supports) – The underline type

  • border_type (str: one of utils.borders or any other border type Excel supports) – The border type

New in version 1.2.

  • horizontal_alignment (str: one of utils.horizontal_alignments or any other horizontal alignment Excel supports) – Text’s horizontal alignment

  • vertical_alignment (str: one of utils.vertical_alignments or any other vertical alignment Excel supports) – Text’s vertical alignment

New in version 1.3.

  • wrap_text (bool) –

  • shrink_to_fit (bool) –

  • fill_pattern_type (str: one of utils.fill_pattern_types or any other fill pattern type Excel supports) – Cells’s fill pattern type

  • indent (int) –

  • comment_author (str) –

  • comment_text (str) –

  • text_rotation (int) – Integer in the range 0 - 180

New in version 4.0.



For any of date_format, time_format and date_time_format to take effect, the value being styled must be an actual date/time/datetime object.

classmethod combine(*styles)

New in version 1.6.

Used to combine Styler objects. The right-most object has precedence. For example:

Styler.combine(Styler(bg_color='yellow', font_size=24), Styler(bg_color='blue'))

will return

Styler(bg_color='blue', font_size=24)

styles (list or tuple or set) – Iterable of Styler objects



Return type