styler

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

Used to represent a style

Parameters
  • 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.

Parameters
  • 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.

Parameters
  • 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.

Parameters

Note

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.

New in version 4.1.

Parameters
  • strikethrough (bool) –

  • italic (bool) –

classmethod combine(*styles: Styler)

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)
Parameters

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

Returns

self

Return type

Styler