Class TableStyler

class ooodev.write.style.direct.table.table_styler.TableStyler(owner, component)[source]

Bases: WriteDocPropPartial, WriteTablePropPartial, EventsPartial, LoInstPropsPartial, FillColorPartial, WriteTableFillImgPartial, WriteTableBordersPartial, WriteTablePropertiesPartial, TheDictionaryPartial

Cell Styler class.

Class set various cell properties.

Events are raises when a style is being applied and when a style has been applied. The WriteNamedEvent.TABLE_STYLE_APPLYING event is raised before a style is applied. The WriteNamedEvent.TABLE_STYLE_APPLIED event is raised after a style has been applied. The event data is a dictionary that contains the following:

  • cancel_apply: If set to True the style will not be applied. This is only used in the TABLE_STYLE_APPLYING event.

  • this_component: The component that the style is being applied to. This is the normally same component passed to the constructor.

  • styler_object: The style that is being applied. This is None when TABLE_STYLE_APPLYING is raised. Is the style that was applied when TABLE_STYLE_APPLIED is raised.

Other style specific data is also in the dictionary such as the parameter values used to apply the style.

The event_args.event_source is the instance of the CellStyler class.

Parameters:
__init__(owner, component)[source]

Constructor.

Parameters:
  • owner (WriteTable) – Write Table instance.

  • component (Any) – component instance.

Return type:

None

add_event_observers(*args)

Adds observers that gets their trigger method called when this class trigger method is called.

Parameters:

args (EventObserver) – One or more observers to add.

Return type:

None

Note

Observers are removed automatically when they are out of scope.

remove_event_observer(observer)

Removes an observer

Parameters:

observer (EventObserver) – One or more observers to add.

Returns:

True if observer has been removed; Otherwise, False.

Return type:

bool

style_area_color(color=-1)

Style Area Color.

Parameters:

color (Color, optional) – FillColor Color. Defaults to StandardColor.AUTO_COLOR.

Raises:

CancelEventError – If the event before_style_area_color is cancelled and not handled.

Returns:

FillColor instance or None if cancelled.

Return type:

FillColorT | None

style_area_color_get()

Gets the Area Color Style.

Raises:

CancelEventError – If the event before_style_area_color_get is cancelled and not handled.

Returns:

Area color style or None if cancelled.

Return type:

FillColorT | None

style_area_image(*, bitmap=None, name='', mode=ImgStyleKind.TILED, size=None, position=None, pos_offset=None, tile_offset=None, auto_name=False)

Style Area Color.

Parameters:
  • bitmap (XBitmap, optional) – Bitmap instance. If name is not already in the Bitmap Table then this property is required.

  • name (str, optional) – Specifies the name of the image. This is also the name that is used to store bitmap in LibreOffice Bitmap Table.

  • mode (ImgStyleKind, optional) – Specifies the image style, tiled, stretched etc. Default ImgStyleKind.TILED.

  • size (SizePercent, SizeMM, optional) – Size in percent (0 - 100) or size in mm units.

  • position (RectanglePoint) – Tiling position of Image.

  • pos_offset (Offset, optional) – Tiling position offset.

  • tile_offset (OffsetColumn, OffsetRow, optional) – The tiling offset.

  • auto_name (bool, optional) – Specifies if name is ensured to be unique. Defaults to False.

Raises:

CancelEventError – If the event before_style_area_img is cancelled and not handled.

Returns:

Fill Image instance or None if cancelled.

Return type:

FillImgT | None

Hint

  • RectanglePoint can be imported from ooo.dyn.drawing.rectangle_point

  • ImgStyleKind can be imported from ooodev.format.inner.direct.write.fill.area.img

  • SizePercent can be imported from ooodev.format.inner.common.format_types.size_percent

  • SizeMM can be imported from ooodev.utils.data_type.size_mm

  • OffsetColumn can be imported from ooodev.format.inner.common.format_types.offset_column

  • OffsetRow can be imported from ooodev.format.inner.common.format_types.offset_row

  • Offset can be imported from ooodev.utils.data_type.offset

style_area_image_from_preset(preset)

Style Area Gradient from Preset.

Parameters:

preset (PresetImageKind) – Preset Image Kind.

Returns:

Chart Fill Image instance.

Return type:

FillImgT

Hint

  • PresetImageKind can be imported from ooodev.format.inner.preset.preset_image

style_borders(*, right=None, left=None, top=None, bottom=None, border_side=None, vertical=None, horizontal=None, distance=None, shadow=None, padding=None, merge_adjacent=None)

Style Write Table Borders.

Parameters:
  • left (Side,, optional) – Specifies the line style at the left edge.

  • right (Side, optional) – Specifies the line style at the right edge.

  • top (Side, optional) – Specifies the line style at the top edge.

  • bottom (Side, optional) – Specifies the line style at the bottom edge.

  • border_side (Side, optional) – Specifies the line style at the top, bottom, left, right edges. If this argument has a value then arguments top, bottom, left, right are ignored

  • horizontal (Side, optional) – Specifies the line style of horizontal lines for the inner part of a cell range.

  • vertical (Side, optional) – Specifies the line style of vertical lines for the inner part of a cell range.

  • distance (float, UnitT, optional) – Contains the distance between the lines and other contents in mm units or Class UnitT.

  • shadow (Shadow | None, optional) – Cell Shadow.

  • padding (Padding | None, optional) – Cell padding.

  • merge_adjacent (bool, optional) – Specifies if adjacent line style are to be merged.

Raises:

CancelEventError – If the event before_style_table_borders is cancelled and not handled.

Returns:

Border Style instance or None if cancelled.

Return type:

Borders | None

Hint

  • BorderLine can be imported from ooodev.format.writer.direct.char.borders

  • BorderLine2 can be imported from ooodev.format.writer.direct.char.borders

  • BorderLineKind can be imported from ooodev.format.writer.direct.char.borders

  • Borders can be imported from ooodev.format.writer.direct.char.borders

  • LineSize can be imported from ooodev.format.writer.direct.char.borders

  • Padding can be imported from ooodev.format.inner.direct.calc.border.padding

  • Shadow can be imported from ooodev.format.inner.direct.calc.border.shadow

  • ShadowFormat can be imported from ooodev.format.writer.direct.char.borders

  • Side can be imported from ooodev.format.writer.direct.char.borders

  • side can be imported from ooodev.format.writer.direct.char.borders

  • Sides can be imported from ooodev.format.writer.direct.char.borders

  • ShadowLocation can be imported from ooo.dyn.table.shadow_location

style_borders_padding(*, left=None, right=None, top=None, bottom=None, all_sides=None)

Style Padding for Write Table.

Parameters:
  • left (float, UnitT, optional) – Left (in mm units) or Class UnitT.

  • right (float, UnitT, optional) – Right (in mm units) or Class UnitT.

  • top (float, UnitT, optional) – Top (in mm units) or Class UnitT.

  • bottom (float, UnitT, optional) – Bottom (in mm units) or Class UnitT.

  • all_sides (float, UnitT, optional) – Left, right, top, bottom (in mm units) or Class UnitT. If argument is present then left, right, top, and bottom arguments are ignored.

Raises:

CancelEventError – If the event before_style_table_borders is cancelled and not handled.

Returns:

Borders Style instance or None if cancelled.

Return type:

Borders | None

style_borders_side(*, line=BorderLineKind.SOLID, color=0, width=LineSize.THIN, shadow=None, padding=None)

Style All Write Table Borders.

Parameters:
  • line (BorderLineStyleEnum, optional) – Line Style of the border. Default BorderLineKind.SOLID.

  • color (Color, optional) – Color of the border. Default StandardColor.BLACK

  • width (LineSize, float, UnitT, optional) – Contains the width in of a single line or the width of outer part of a double line (in pt units) or Class UnitT. If this value is zero, no line is drawn. Default LineSize.THIN

  • shadow (Shadow | None, optional) – Cell Shadow.

  • padding (Padding | None, optional) – Cell padding.

Raises:

CancelEventError – If the event before_style_table_borders is cancelled and not handled.

Returns:

Borders Style instance or None if cancelled.

Return type:

Borders | None

Hint

  • BorderLine2 can be imported from ooo.dyn.table.border_line2

  • BorderLine can be imported from ooo.dyn.table.border_line

  • BorderLineKind can be imported from ooodev.format.inner.direct.structs.side

  • LineSize can be imported from ooodev.format.inner.direct.structs.side

  • Padding can be imported from ooodev.format.inner.direct.calc.border.padding

  • Shadow can be imported from ooodev.format.inner.direct.calc.border.shadow

  • ShadowFormat can be imported from ooodev.format.writer.direct.char.borders

  • ShadowLocation can be imported from ooo.dyn.table.shadow_location

style_table_props(*, width=None, left=None, right=None, above=None, below=None, align=None, relative=False)

Style Write Table Properties.

Parameters:
  • width (TblAbsUnit, TblRelUnit, optional) – Specifies table Width.

  • left (TblAbsUnit, TblRelUnit, optional) – Specifies table Left.

  • right (TblAbsUnit, TblRelUnit, optional) – Specifies table Right.

  • above (TblAbsUnit, TblRelUnit, optional) – Specifies table spacing above.

  • below (TblAbsUnit, TblRelUnit, optional) – Specifies table spacing below.

  • align (TableAlignKind, optional) – Specifies table alignment.

  • relative (bool, optional) – Specifies if table horizontal values are in percentages or mm units.

Raises:

CancelEventError – If the event before_style_table_properties is cancelled and not handled.

Returns:

Table Properties Style instance or None if cancelled.

Return type:

TableProperties | None

Hint

  • TblAbsUnit can be imported from ooodev.format.inner.direct.write.table.props.table_properties

  • TblRelUnit can be imported from ooodev.format.inner.direct.write.table.props.table_properties

  • TableAlignKind can be imported from ooodev.format.inner.direct.write.table.props.table_properties

style_table_props_get()

Gets the Table Properties Style.

Returns:

Table Properties Style instance or None if not available.

Return type:

TableProperties | None

subscribe_event(event_name, callback)

Add an event listener to current instance.

Parameters:
  • event_name (str) – Event Name.

  • callback (EventCallback) – Callback of the event listener.

Return type:

None

trigger_event(event_name, event_args)

Trigger an event on current instance.

Parameters:
  • event_name (str) – Event Name.

  • event_args (EventArgsT) – Event Args.

Return type:

None

unsubscribe_event(event_name, callback)

Remove an event listener from current instance.

Parameters:
  • event_name (str) – Event Name.

  • callback (EventCallback) – Callback of the event listener.

Return type:

None

property event_observer: EventObserver

Gets/Sets The Event Observer for this instance.

Return type:

EventObserver

property extra_data: TheDict

Extra Data Key Value Pair Dictionary

Return type:

TheDict

property lo_inst: LoInst

Lo Instance

Return type:

LoInst

property office_doc: OfficeDocumentT

Office Document.

Return type:

OfficeDocumentT

property write_doc: WriteDoc

Write Document.

Return type:

WriteDoc

property write_table: WriteTable[Any]

Write Document.

Return type:

WriteTable[Any]