Class CalcCellRange

class ooodev.calc.CalcCellRange(owner, rng, lo_inst=None)[source]

Bases: LoInstPropsPartial, CalcDocPropPartial, CalcSheetPropPartial, SheetCellRangeComp, EventsPartial, CellProperties2PartialProps, QiPartial, PropPartial, StylePartial, ServicePartial, FontOnlyPartial, FontEffectsPartial, FontPartial, TextAlignPartial, TextOrientationPartial, PropertiesPartial, FillColorPartial, CalcBordersPartial, CellProtectionPartial, NumbersNumbersPartial, StylePropertyPartial

Represents a calc cell range.

Parameters:
__eq__(other)[source]

Compares two instances of CalcCellRange.

Return type:

bool

Parameters:

other (Any) –

__init__(owner, rng, lo_inst=None)[source]

Constructor

Parameters:
  • owner (CalcSheet) – Sheet that owns this cell range.

  • rng (Any) – Range object.

  • lo_inst (LoInst | None) –

Return type:

None

__ne__(other)[source]

Compares two instances of CalcCellRange.

Return type:

bool

Parameters:

other (Any) –

add_event_chart_data_change_event_events_disposing(cb)

Adds a listener for an event.

Event is invoked when the broadcaster is about to be disposed.

The callback EventArgs.event_data will contain a UNO com.sun.star.lang.EventObject struct.

Return type:

None

Parameters:

cb (Any) –

add_event_chart_data_changed(cb)

Adds a listener for an event.

Event is invoked when chart data changes in value or structure.

The callback EventArgs.event_data will contain a UNO com.sun.star.chart.ChartDataChangeEvent struct.

Return type:

None

Parameters:

cb (Any) –

add_event_modified(cb)

Adds a listener for an event.

Event is invoked when something changes in the object.

The callback EventArgs.event_data will contain a UNO com.sun.star.lang.EventObject struct.

Return type:

None

Parameters:

cb (Any) –

add_event_modify_events_disposing(cb)

Adds a listener for an event.

Event is invoked when the broadcaster is about to be disposed.

The callback EventArgs.event_data will contain a UNO com.sun.star.lang.EventObject struct.

Return type:

None

Parameters:

cb (Any) –

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.

add_event_property_change(name, cb)

Adds a listener for an event.

Event is invoked when property is changed.

The callback EventArgs.event_data will contain a com.sun.star.beans.PropertyChangeEvent struct.

Parameters:
  • name (str) – Property Name

  • cb (EventArgsCallbackT) – Callback

Return type:

None

add_event_property_change_events_disposing(name, cb)

Adds a listener for an event.

Event is invoked when the property listener is about to be disposed.

The callback EventArgs.event_data will contain a UNO com.sun.star.lang.EventObject struct.

Parameters:
  • name (str) – Property Name

  • cb (EventArgsCallbackT) – Callback

Return type:

None

add_event_vetoable_change(name, cb)

Adds a listener for an event.

Event is invoked when property is changed.

The callback EventArgs.event_data will contain a com.sun.star.beans.PropertyChangeEvent struct.

Parameters:
  • name (str) – Property Name

  • cb (EventArgsCallbackT) – Callback

Return type:

None

add_event_vetoable_change_events_disposing(name, cb)

Adds a listener for an event.

Event is invoked when the property listener is about to be disposed.

The callback EventArgs.event_data will contain a UNO com.sun.star.lang.EventObject struct.

Parameters:
  • name (str) – Property Name

  • cb (EventArgsCallbackT) – Callback

Return type:

None

apply_styles(*styles, **kwargs)

Applies style to component.

Parameters:
  • obj. (styles expandable list of styles object such as Font to apply to) –

  • kwargs (Any, optional) – Expandable list of key value pairs.

  • styles (StyleT) –

Return type:

None

change_style(style_name)[source]

Changes style of a range of cells.

Parameters:
  • style_name (str) – Name of style to apply.

  • range_obj (RangeObj) – Range Object.

Returns:

True if style has been changed; Otherwise, False.

Return type:

bool

clear_cells(cell_flags=None)[source]

Clears the specified contents of the cell range

If cell_flags is not specified then cell range of types VALUE, DATETIME and STRING are cleared

Raises:

MissingInterfaceError – If XSheetOperation interface cannot be obtained.

Events:
Parameters:

cell_flags (CellFlagsEnum, optional) – Cell flags to clear. Default None.

Returns:

True if cells are cleared; Otherwise, False

Return type:

bool

Note

Events arg for this method have a cell type of XCellRange.

Events arg event_data is a dictionary containing cell_flags.

Hint

  • CellFlagsEnum can be imported from ooo.dyn.sheet.cell_flags

contains(cell_obj: ooodev.utils.data_type.cell_obj.CellObj)[source]
contains(cell_addr: com.sun.star.table.CellAddress)
contains(cell_vals: ooodev.utils.data_type.cell_values.CellValues)
contains(cell_name: str)
contains(*args, **kwargs)

Gets if current instance contains a cell value.

Parameters:
  • cell_obj (CellObj) – Cell object

  • cell_addr (CellAddress) – Cell address

  • cell_vals (CellValues) – Cell Values

  • cell_name (str) – Cell name

Returns:

True if instance contains cell; Otherwise, False.

Return type:

bool

Note

If cell input contains sheet info the it is use in comparison. Otherwise sheet is ignored.

create_cursor()[source]

Creates a cell cursor to travel in the given range context.

Returns:

Cell cursor

Return type:

CalcCellCursor

delete_cells(is_shift_left)[source]

Deletes cell in a spreadsheet

Parameters:

is_shift_left (bool) – If True then cell are shifted left; Otherwise, cells are shifted up.

Events:
Returns:

True if cells are deleted; Otherwise, False

Return type:

bool

Note

Events args for this method have a cell type of XCellRange

Note

Event args event_data is a dictionary containing is_shift_left.

export_as_image(fnm, resolution=96)[source]

Exports a range of cells as an image.

If the filename extension is .png then the image is exported as a PNG; Otherwise, image is exported as a JPEG.

Parameters:
  • fnm (PathOrStr) – Filename to export to.

  • resolution (int, optional) – Resolution in dpi. Defaults to 96.

Return type:

None

Example

from pathlib import Path
from ooodev.events.args.cancel_event_args_export import CancelEventArgsExport
from ooodev.events.args.event_args_export import EventArgsExport
from ooodev.calc.filter.export_png import ExportPngT
from ooodev.calc import CalcNamedEvent

def on_exporting(source: Any, args: CancelEventArgsExport[ExportJpgT]) -> None:
    args.event_data["compression"] = 9

def on_exported(source: Any, args: EventArgsGeneric[ImgExportT]) -> None:
    print(f"Image has been exported to {args.event_data['file']}")

rng = sheet.get_range(range_name="A1:M4")
rng.subscribe_event(CalcNamedEvent.EXPORTING_RANGE_JPG, on_exporting)
rng.subscribe_event(CalcNamedEvent.EXPORTED_RANGE_JPG, on_exported)
pth = Path("./export_range.jpg")
rng.export_as_image(pth)

See also

New in version 0.20.3.

export_jpg(fnm, resolution=96)[source]

Exports page as jpg image.

Parameters:
  • fnm (PathOrStr, optional) – Image file name.

  • resolution (int, optional) – Resolution in dpi. Defaults to 96.

Raises:
  • ValueError – If fnm is empty.

  • CancelEventError – If EXPORTING_RANGE_JPG event is canceled.

Events:
Return type:

None

Note

On exporting event is Class CancelEventArgsExport. On exported event is Class EventArgsExport. Args event_data is a ExportJpgT dictionary.

Example

from pathlib import Path
from ooodev.events.args.cancel_event_args_export import CancelEventArgsExport
from ooodev.events.args.event_args_export import EventArgsExport
from ooodev.calc.filter.export_jpg import ExportJpgT
from ooodev.calc import CalcNamedEvent

def on_exporting(source: Any, args: CancelEventArgsExport[ExportJpgT]) -> None:
    args.event_data["quality"] = 80

def on_exported(source: Any, args: EventArgsExport[ExportJpgT]) -> None:
    print(f"Image has been exported to {args.fnm}")

rng = sheet.get_range(range_name="A1:M4")
rng.subscribe_event(CalcNamedEvent.EXPORTING_RANGE_JPG, on_exporting)
rng.subscribe_event(CalcNamedEvent.EXPORTED_RANGE_JPG, on_exported)
pth = Path("./export_range.jpg")
rng.export_jpg(pth)

See also

Live LibreOffice Example Export Calc Sheet Range as Image

New in version 0.21.0.

export_png(fnm, resolution=96)[source]

Exports page as jpg image.

Parameters:
  • fnm (PathOrStr, optional) – Image file name.

  • resolution (int, optional) – Resolution in dpi. Defaults to 96.

Raises:
  • ValueError – If fnm is empty.

  • CancelEventError – If EXPORTING_RANGE_PNG event is canceled.

Events:
Return type:

None

Note

On exporting event is Class CancelEventArgsExport. On exported event is Class EventArgsExport. Args event_data is a ExportPngT dictionary.

Example

from pathlib import Path
from ooodev.events.args.cancel_event_args_export import CancelEventArgsExport
from ooodev.events.args.event_args_export import EventArgsExport
from ooodev.calc.filter.export_png import ExportPngT
from ooodev.calc import CalcNamedEvent

def on_exporting(source: Any, args: CancelEventArgsExport[ExportPngT]) -> None:
    args.event_data["compression"] = 9

def on_exported(source: Any, args: EventArgsExport[ExportPngT]) -> None:
    print(f"Image has been exported to {args.fnm}")

rng = sheet.get_range(range_name="A1:M4")
rng.subscribe_event(CalcNamedEvent.EXPORTING_RANGE_JPG, on_exporting)
rng.subscribe_event(CalcNamedEvent.EXPORTED_RANGE_JPG, on_exported)
pth = Path("./export_range.png")
rng.export_png(pth)

See also

Live LibreOffice Example Export Calc Sheet Range as Image

New in version 0.21.0.

get_address()[source]

Gets Range Address.

Returns:

Cell Range Address.

Return type:

CellRangeAddress

get_array()[source]

Gets a 2-Dimensional array of values from a range of cells.

Returns:

2-Dimensional array of values.

Return type:

TupleArray

get_cell_range()[source]

Gets the XCellRange for the current range.

Returns:

Cell series

Return type:

XCellRange

get_cell_range_address()[source]

Gets the cell range address for the current range.

Returns:

Cell range address

Return type:

CellRangeAddress

get_cell_series()[source]

Gets the cell series for the current range.

Returns:

Cell series

Return type:

XCellSeries

get_col()[source]

Gets a column of data from spreadsheet.

Parameters:

range_obj (RangeObj) – Range Object.

Returns:

1-Dimensional List.

Return type:

List[Any]

get_data_array()

Gets an array from the contents of the cell range.

Each element of the result contains a float or a string.

Return type:

Tuple[Tuple[Any, ...], ...]

get_float_array()[source]

Gets a 2-Dimensional List of floats.

Returns:

2-Dimensional List of floats.

Return type:

FloatTable

get_property(name, default=<object object>)

Get property value

Parameters:
  • name (str) – Property Name.

  • default (Any, optional) – Return value if property value is None.

Returns:

Property value or default.

Return type:

Any

get_range_size()[source]

Gets the size of the range.

Returns:

Size, Width is number of Columns and Height is number of Rows

Return type:

Size

get_range_str()[source]

Gets the range as a string in format of A1:B2 or Sheet1.A1:B2

If sheet is included the format Sheet1.A1:B2 is returned; Otherwise, A1:B2 format is returned.

Returns:

range as string

Return type:

str

get_row()[source]

Gets a row of data from spreadsheet

Parameters:

range_obj (RangeObj) – Range Object

Returns:

1-Dimensional List of values on success; Otherwise, None

Return type:

Row

get_services()

Gets service names for the instance.

Returns:

service names

Return type:

List[str]

get_val()[source]

Get the value of the very first cell in the range.

Useful for merged cells.

Returns:

Value of cell.

Return type:

Any

highlight(headline: str)[source]
highlight(headline: str, color: Color)
highlight(headline, color=11393254)

Draw a colored border around the range and write a headline in the top-left cell of the range.

Parameters:
  • headline (str) – Headline.

  • color (Color) – RGB color.

Returns:

Cell object. First cell of range that headline ia applied on.

Return type:

CalcCell

insert_chart(*, cell_name='', width=16, height=9, diagram_name='Column', color_bg=14085119, color_wall=11393254, **kwargs)[source]

Insert a new chart.

Parameters:
  • cell_name (str, optional) – Cell name such as A1.

  • width (int, optional) – Width. Default 16.

  • height (int, optional) – Height. Default 9.

  • diagram_name (ChartTemplateBase | str) – Diagram Name. Defaults to Column.

  • color_bg (Color, optional) – Color Background. Defaults to CommonColor.PALE_BLUE. If set to None then no color is applied.

  • color_wall (Color, optional) – Color Wall. Defaults to CommonColor.LIGHT_BLUE. If set to None then no color is applied.

Keyword Arguments:
  • chart_name (str, optional) – Chart name

  • is_row (bool, optional) – Determines if the data is row data or column data.

  • first_cell_as_label (bool, optional) – Set is first row is to be used as a label.

  • set_data_point_labels (bool, optional) – Determines if the data point labels are set.

Raises:

ChartError – If error occurs

Returns:

Chart Document that was created and inserted into the sheet.

Return type:

TableChart

Note

Keyword Arguments are to mostly be ignored. If finer control over chart creation is needed then Keyword Arguments can be used.

Note

See Open Office Wiki - The Structure of Charts for more information.

is_merged_cells()[source]

Gets is a range of cells is merged.

Parameters:

range_obj (RangeObj) – Range Object.

Returns:

True if range is merged; Otherwise, False

Return type:

bool

is_single_cell_range()[source]

Gets if a cell address is a single cell or a range

Returns:

True if single cell; Otherwise, False

Return type:

bool

is_single_column_range()[source]

Gets if a cell address is a single column or multi-column

Returns:

True if single column; Otherwise, False

Return type:

bool

is_single_row_range()[source]

Gets if a cell address is a single row or multi-row

Returns:

True if single row; Otherwise, False

Return type:

bool

merge_cells(center=False)[source]

Merges a range of cells

Parameters:

center (bool) – Determines if the merge will be a merge and center. Default False.

Return type:

None

qi(atype, raise_err=False)

Generic method that get an interface instance from an object.

Parameters:
  • atype (T) – Interface type to query obj for. Any Uno class that starts with ‘X’ such as XInterface

  • raise_err (bool, optional) – If True then raises MissingInterfaceError if result is None. Default False

Raises:

MissingInterfaceError – If ‘raise_err’ is ‘True’ and result is None

Returns:

instance of interface if supported; Otherwise, None

Return type:

T | None

Note

When raise_err=True return value will never be None.

refresh()[source]

Refreshes the range of cells.

This method should be call if the sheet has rows or columns inserted or deleted since this instance as been created.

Return type:

None

New in version 0.45.0.

remove_border()[source]

Removes border from range of cells.

Return type:

None

New in version 0.25.2.

remove_event_chart_data_change_event_events_disposing(cb)

Removes a listener for an event

Return type:

None

Parameters:

cb (Any) –

remove_event_chart_data_changed(cb)

Removes a listener for an event

Return type:

None

Parameters:

cb (Any) –

remove_event_modified(cb)

Removes a listener for an event

Return type:

None

Parameters:

cb (Any) –

remove_event_modify_events_disposing(cb)

Removes a listener for an event

Return type:

None

Parameters:

cb (Any) –

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

remove_event_property_change(name)

Removes a listener for an event

Parameters:

name (str) – Property Name

Return type:

None

remove_event_property_change_events_disposing(name)

Removes a listener for an event

Parameters:

name (str) – Property Name

Return type:

None

remove_event_vetoable_change(name)

Removes a listener for an event

Parameters:

name (str) – Property Name

Return type:

None

remove_event_vetoable_change_events_disposing(name)

Removes a listener for an event

Parameters:

name (str) – Property Name

Return type:

None

select()[source]

Selects the range of cells represented by this instance.

Return type:

None

New in version 0.20.3.

set_array(values, styles=None)[source]

Inserts array of data into spreadsheet

Parameters:
  • values (Table) – A 2-Dimensional array of value such as a list of list or tuple of tuples.

  • styles (Sequence[StyleT], optional) – One or more styles to apply to cell range.

Return type:

None

set_array_range(values, styles=None)[source]

Inserts array of data into spreadsheet

Parameters:
  • values (Table) – A 2-Dimensional array of value such as a list of list or tuple of tuples.

  • styles (Sequence[StyleT], optional) – One or more styles to apply to cell range.

Return type:

None

set_cell_range_array(values, styles=None)[source]

Inserts array of data into spreadsheet

Parameters:
  • values (Table) – A 2-Dimensional array of value such as a list of list or tuple of tuples.

  • styles (Sequence[StyleT], optional) – One or more styles to apply to cell range.

Return type:

None

set_data_array(array)

Fills the cell range with values from an array.

The size of the array must be the same as the size of the cell range. Each element of the array must contain a float or a string.

Warning

The size of the array must be the same as the size of the cell range. This means when setting table data the table must be the same size as the data. When setting a table range the array must be the same size as the range.

Return type:

None

Parameters:

array (Sequence[Sequence[Any]]) –

set_property(**kwargs)

Set property value

Parameters:

**kwargs (Any) – Variable length Key value pairs used to set properties.

Return type:

None

set_val(value)[source]

Set the value of the very first cell in the range.

Useful for merged cells.

Parameters:

value (Any) – Value to set.

Return type:

None

style_align_orientation(vert_stack=None, rotation=None, edge=None)

Style Text Orientation.

Parameters:
  • vert_stack (bool, optional) – Specifies if vertical stack is to be used.

  • rotation (int, Angle, optional) – Specifies if the rotation.

  • edge (EdgeKind, optional) – Specifies the Reference Edge.

Raises:

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

Returns:

Text Alignment instance or None if cancelled.

Return type:

TextOrientationT | None

Hint

  • EdgeKind can be imported from ooodev.format.inner.direct.calc.alignment.text_orientation

style_align_orientation_get()

Gets the Alignment Text Orientation Style.

Raises:

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

Returns:

Text Alignment style or None if cancelled.

Return type:

TextOrientationT | None

style_align_properties(*, wrap_auto=None, hyphen_active=None, shrink_to_fit=None, direction=None)

Style Alignment Properties.

Parameters:
  • hori_align (HoriAlignKind, optional) – Specifies Horizontal Alignment.

  • indent – (float, UnitT, optional): Specifies indent in pt (point) units or Class UnitT. Only used when hori_align is set to HoriAlignKind.LEFT

  • vert_align (VertAdjustKind, optional) – Specifies Vertical Alignment.

  • wrap_auto (bool | None) –

  • hyphen_active (bool | None) –

  • shrink_to_fit (bool | None) –

  • direction (TextDirectionKind | None) –

Raises:

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

Returns:

Text Alignment instance or None if cancelled.

Return type:

PropertiesT | None

Hint

  • TextDirectionKind can be imported from ooodev.format.inner.direct.calc.alignment.properties

style_align_properties_get()

Gets the Alignment Properties Style.

Raises:

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

Returns:

Text Alignment style or None if cancelled.

Return type:

PropertiesT | None

style_align_text(hori_align=None, indent=None, vert_align=None)

Style Alignment Text.

Parameters:
  • hori_align (HoriAlignKind, optional) – Specifies Horizontal Alignment.

  • indent (float | UnitT | None) – (float, UnitT, optional): Specifies indent in pt (point) units or Class UnitT. Only used when hori_align is set to HoriAlignKind.LEFT

  • vert_align (VertAdjustKind, optional) – Specifies Vertical Alignment.

Raises:

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

Returns:

Text Alignment instance or None if cancelled.

Return type:

TextAlignT | None

Hint

  • HoriAlignKind can be imported from ooodev.format.inner.direct.calc.alignment.text_align

  • VertAlignKind can be imported from ooodev.format.inner.direct.calc.alignment.text_align

style_align_text_get()

Gets the Alignment Text Style.

Raises:

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

Returns:

Text Alignment style or None if cancelled.

Return type:

TextAlignT | None

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_borders(*, right=None, left=None, top=None, bottom=None, border_side=None, vertical=None, horizontal=None, distance=None, diagonal_down=None, diagonal_up=None, shadow=None, padding=None)

Style 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.

  • diagonal_down (Side, optional) – Specifies the line style from top-left to bottom-right diagonal.

  • diagonal_up (Side, optional) – Specifies the line style from bottom-left to top-right diagonal.

  • shadow (Shadow, optional) – Cell Shadow.

  • padding (padding, optional) – Cell padding.

Raises:

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

Returns:

Border instance or None if cancelled.

Return type:

BordersT | None

Hint

  • Side, Shadow and Padding can be imported from ooodev.format.calc.direct.cell.borders

  • BorderLineKind can be imported from ooodev.format.calc.direct.cell.borders

  • LineSize can be imported from ooodev.format.calc.direct.cell.borders

style_borders_clear()

Clear Borders Styles.

Return type:

None

style_borders_default()

Style default border.

Returns:

Border instance or None if cancelled.

Return type:

BordersT | None

style_borders_get()

Gets the Borders Style.

Raises:

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

Returns:

border style or None if cancelled.

Return type:

BordersT | None

style_borders_sides(*, line=None, color=None, width=None, distance=None, shadow=None, padding=None, hori=False, vert=False)

Style All border to specified line properties. This method is a subset of style_borders() method for convenience.

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

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

  • shadow (Shadow, optional) – Cell Shadow.

  • padding (padding, optional) – Cell padding.

  • hori (bool, optional) – If True then horizontal lines are also styled.

  • vert (bool, optional) – If True then vertical lines are also styled.

Raises:

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

Returns:

Font Effects instance or None if cancelled.

Return type:

BordersT | None

Hint

  • Shadow and Padding can be imported from ooodev.format.calc.direct.cell.borders

  • BorderLineKind can be imported from ooodev.format.calc.direct.cell.borders

  • LineSize can be imported from ooodev.format.calc.direct.cell.borders

style_by_name(name='')[source]

Assign a style by name to the component.

name (str, StyleCellKind, optional): The name of the style to apply. StyleCellKind contains various style names.

If not provided, the default style is applied.

Raises:

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

Return type:

None

Parameters:

name (str | StyleCellKind) –

Hint

  • StyleCellKind can be imported from ooodev.format.calc.style

style_by_name_get()

Get the style name of the component.

Returns:

The name of the style.

Return type:

str

style_font(name=None, size=None, font_style=None, lang=None)

Style Font.

Parameters:
  • name (str | None, optional) – Font Name.

  • size (float | UnitT | None, optional) – Font Size in PT units or UnitT.

  • font_style (str | None, optional) – Font Style such as Bold Italics

  • lang (FontLangT | None, optional) – Font Language.

Raises:

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

Returns:

Font Only instance or None if cancelled.

Return type:

FontOnlyT | None

See also

FontLang

style_font_effect(*, color=None, transparency=None, overline=None, underline=None, strike=None, word_mode=None, case=None, relief=None, outline=None, shadowed=None)

Style Font options.

Parameters:
  • color (Color, optional) – The value of the text color. If value is -1 the automatic color is applied.

  • transparency (Intensity, int, optional) – The transparency value from 0 to 100 for the font color.

  • overline (FontLine, optional) – Character overline values.

  • underline (FontLine, optional) – Character underline values.

  • strike (FontStrikeoutEnum, optional) – Determines the type of the strike out of the character.

  • word_mode (bool, optional) – If True, the underline and strike-through properties are not applied to white spaces.

  • case (CaseMapEnum, optional) – Specifies the case of the font.

  • relief (FontReliefEnum, optional) – Specifies the relief of the font.

  • outline (bool, optional) – Specifies if the font is outlined.

  • shadowed (bool, optional) – Specifies if the characters are formatted and displayed with a shadow effect.

Raises:

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

Returns:

Font Effects instance or None if cancelled.

Return type:

FontEffectsT | None

Hint

  • CaseMapEnum can be imported from ooo.dyn.style.case_map

  • FontReliefEnum can be imported from ooo.dyn.awt.font_relief

  • FontStrikeoutEnum can be imported from ooo.dyn.awt.font_strikeout

  • FontLine can be imported from ooodev.format.inner.direct.write.char.font.font_effects

  • Intensity can be imported from ooodev.utils.data_type.intensity

  • FontUnderlineEnum can be imported from ooo.dyn.awt.font_underline

style_font_effect_get()

Gets the font effect Style.

Raises:

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

Returns:

Font Effect style or None if cancelled.

Return type:

FontEffectsT | None

style_font_effect_line(line=None, color=None, overline=False)

Style Font Underline or Overline.

This method is a subset of style_font_effect() method for convenience.

Parameters:
  • color (Color, optional) – The value of the text color. If value is -1 the automatic color is applied.

  • line (FontUnderlineEnum, optional) – Font Line kind.

  • overline (bool, optional) – If True the line is overline, otherwise it is underline.

Raises:

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

Returns:

Font Effects instance or None if cancelled.

Return type:

FontEffectsT | None

Hint

  • FontUnderlineEnum can be imported from ooo.dyn.awt.font_underline

style_font_general(b=None, i=None, u=None, bg_color=None, bg_transparent=None, charset=None, color=None, family=None, name=None, overline=None, rotation=None, shadow_fmt=None, shadowed=None, size=None, slant=None, spacing=None, strike=None, subscript=None, superscript=None, underline=None, weight=None, word_mode=None)

Style Font.

Parameters:
  • b (bool, optional) – Shortcut to set weight to bold.

  • i (bool, optional) – Shortcut to set slant to italic.

  • u (bool, optional) – Shortcut ot set underline to underline.

  • bg_color (Color, optional) – The value of the text background color.

  • bg_transparent (bool, optional) – Determines if the text background color is set to transparent.

  • charset (CharSetEnum, optional) – The text encoding of the font.

  • color (Color, optional) – The value of the text color. Setting to -1 will cause automatic color.

  • family (FontFamilyEnum, optional) – Font Family.

  • name (str, optional) – This property specifies the name of the font style. It may contain more than one name separated by comma.

  • overline (FontLine, optional) – Character overline values.

  • rotation (int, Angle, optional) – Specifies the rotation of a character in degrees. Depending on the implementation only certain values may be allowed.

  • shadow_fmt (ShadowFormat | None) – (ShadowFormat, optional): Determines the type, color, and width of the shadow.

  • shadowed (bool, optional) – Specifies if the characters are formatted and displayed with a shadow effect.

  • size (float, UnitT, optional) – This value contains the size of the characters in pt (point) units or Class UnitT.

  • slant (FontSlant, optional) – The value of the posture of the document such as FontSlant.ITALIC.

  • spacing (CharSpacingKind, float, UnitT, optional) – Specifies character spacing in pt (point) units or Class UnitT.

  • strike (FontStrikeoutEnum, optional) – Determines the type of the strike out of the character.

  • subscript (bool, optional) – Subscript option.

  • superscript (bool, optional) – Superscript option.

  • underline (FontLine, optional) – Character underline values.

  • weight (FontWeightEnum, optional) – The value of the font weight.

  • word_mode (bool, optional) – If True, the underline and strike-through properties are not applied to white spaces.

Raises:

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

Returns:

Font instance or None if cancelled.

Return type:

FontT | None

Hint

  • FontFamilyEnum can be imported from ooo.dyn.awt.font_family

  • CharSetEnum can be imported from ooo.dyn.awt.char_set

  • ShadowFormat can be imported from ooo.dyn.table.shadow_format

  • FontSlant can be imported from ooo.dyn.awt.font_slant

  • FontStrikeoutEnum can be imported from ooo.dyn.awt.font_strikeout

  • FontWeightEnum can be imported from ooo.dyn.awt.font_weight

  • FontLine can be imported from ooodev.format.inner.direct.write.char.font.font_effects

  • CharSpacingKind can be imported from ooodev.format.inner.direct.write.char.font.font_position

style_font_get()

Gets the font Style.

Raises:

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

Returns:

Font style or None if cancelled.

Return type:

FontOnlyT | None

style_numbers_boolean()

Style numbers boolean.

Return type:

NumbersT | None

style_numbers_currency()

Style numbers currency.

Return type:

NumbersT | None

style_numbers_date()

Style numbers date.

Return type:

NumbersT | None

style_numbers_datetime()

Style numbers datetime.

Return type:

NumbersT | None

style_numbers_fraction()

Style numbers fraction.

Return type:

NumbersT | None

style_numbers_general()

Style numbers general.

Return type:

NumbersT | None

style_numbers_number()

Style numbers number.

Return type:

NumbersT | None

style_numbers_numbers(num_format=0, num_format_index=-1, lang_locale=None)

Style numbers numbers.

Parameters:
  • num_format (NumberFormatEnum, int, optional) – Type of a number format. Use this to select a default format. Defaults to 0 (General Format). Only used if num_format_index is -1 (omitted).

  • num_format_index (NumberFormatIndexEnum, int, optional) – Index of a number format. The enumeration values represent the built-in number formats. Defaults to -1.

  • lang_locale (Locale, optional) – Locale of the number format. Defaults to None which used current Locale.

Raises:

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

Returns:

Style Numbers instance or None if cancelled.

Return type:

NumbersT | None

Hint

  • NumberFormatEnum can be imported from ooo.dyn.util.number_format

  • NumberFormatIndexEnum can be imported from ooo.dyn.i18n.number_format_index

  • Locale can be imported from ooo.dyn.lang.locale

style_numbers_numbers_get()

Gets the Numbers Style.

Raises:

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

Returns:

Numbers style or None if cancelled.

Return type:

NumbersT | None

style_numbers_numbers_get_from_index(idx, locale=None)

Gets the Numbers Style.

Raises:

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

Returns:

Numbers style or None if cancelled.

Return type:

NumbersT | None

Parameters:
  • idx (int) –

  • locale (Locale | None) –

Hint

  • Locale can be imported from ooo.dyn.lang.locale

style_numbers_numbers_get_from_str(nf_str, locale=None, auto_add=False)

Gets the Numbers Style.

Parameters:
  • nf_str (str) – Format string.

  • lang_locale (Locale, optional) – Locale. Defaults to None.

  • auto_add (bool, optional) – If True, format string will be added to document if not found. Defaults to False.

  • source_format (bool, optional) – If True, the number format will be linked to the source format. Defaults to False.

  • locale (Locale | None) –

Raises:

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

Returns:

Numbers style or None if cancelled.

Return type:

NumbersT | None

Hint

  • Locale can be imported from ooo.dyn.lang.locale

style_numbers_percent()

Style numbers percent.

Return type:

NumbersT | None

style_numbers_scientific()

Style numbers scientific.

Return type:

NumbersT | None

style_numbers_time()

Style numbers time.

Return type:

NumbersT | None

style_protection(hide_all=False, protected=False, hide_formula=False, hide_print=False)

Style cell protection.

AArgs:

hide_all (bool, optional): Specifies if all is hidden. Defaults to False. protected (bool, optional): Specifies protected value. Defaults to False. hide_formula (bool, optional): Specifies if the formula is hidden. Defaults to False. hide_print (bool, optional): Specifies if the cell are to be omitted during print. Defaults to False.

Raises:

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

Returns:

Attribute Options Style instance or None if cancelled.

Return type:

CellProtection | None

Parameters:
  • hide_all (bool) –

  • protected (bool) –

  • hide_formula (bool) –

  • hide_print (bool) –

Hint

PlacementKind, SeparatorKind and CellProtection can be imported from ooodev.format.inner.direct.chart2.series.data_labels.data_labels.attrib_options

style_protection_get()

Gets the cell protection Style.

Raises:

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

Returns:

Number percent style or None if cancelled.

Return type:

PercentFormat | 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

support_service(*service)

Gets if instance supports a service.

Parameters:

*service (str) – Variable length argument list of UNO namespace strings such as com.sun.star.configuration.GroupAccess

Returns:

True if instance supports any passed in service; Otherwise, False

Return type:

bool

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

unmerge_cells()[source]

Removes merging from a range of cells

Parameters:

range_obj (RangeObj) – Range Object.

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 asian_vertical_mode: bool | None

Gets/Sets Asian character orientation in vertical orientation.

If the CellProperties.Orientation property is CellOrientation.STACKED, in Asian mode only Asian characters are printed in horizontal orientation instead of all characters. For other values of CellProperties.Orientation, this value is not used.

optional

Return type:

bool | None

property bottom_border: BorderLineStructComp

Gets/Sets a description of the bottom border line of each cell.

Setting value can be done with a BorderLine or BorderLineStructComp object.

Returns:

Returns Border Line.

Return type:

BorderLineStructComp

Hint

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

property bottom_border2: BorderLine2StructComp

Gets/Sets a description of the bottom border line of each cell.

Preferred over bottom_border.

Setting value can be done with a BorderLine2 or BorderLine2StructComp object.

Returns:

Returns BorderLine2.

Return type:

BorderLine2StructComp

Hint

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

property calc_doc: CalcDoc

Calc Document.

Return type:

CalcDoc

property calc_sheet: CalcSheet

Calc Sheet.

Return type:

CalcSheet

property cell_back_color: Color

Gets/Sets the cell background color.

Returns:

Returns Color.

Return type:

Color

property cell_interop_grab_bag: Tuple[PropertyValue, ...] | None

Gets/Sets Grab bag of cell properties, used as a string-any map for interim interop purposes.

This property is intentionally not handled by the ODF filter. Any member that should be handled there should be first moved out from this grab bag to a separate property.

optional

Return type:

Tuple[PropertyValue, …] | None

property cell_protection: CellProtectionStructComp

Gets/Sets a description of the cell protection.

Cell protection is active only if the sheet is protected.

Return type:

CellProtectionStructComp

property cell_style: str

Gets/Sets the name of the style of the cell.

Return type:

str

property component: com.sun.star.sheet.SheetCellRange

Sheet Cell Range Component

Return type:

SheetCellRange

property control: CellRangeControl

Gets access to class for managing cell control.

Returns:

Cell Range Control instance.

Return type:

CellRangeControl

property diagonal_bltr: BorderLineStructComp

Gets/Sets a description of the bottom left to top right diagonal line of each cell.

Setting value can be done with a BorderLine or BorderLineComp object.

Returns:

Returns Border Line.

Return type:

BorderLineComp

Hint

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

property diagonal_bltr2: BorderLine2StructComp

Gets/Sets a description of the bottom left to top right diagonal line of each cell.

Preferred over diagonal_bltr.

Setting value can be done with a BorderLine2 or BorderLine2StructComp object.

Returns:

Returns BorderLine2.

Return type:

BorderLine2StructComp

Hint

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

property diagonal_tlbr: BorderLineStructComp

Gets/Sets a description of the top left to bottom right diagonal line of each cell.

Setting value can be done with a BorderLine or BorderLineComp object.

Returns:

Returns BorderLine.

Return type:

BorderLineComp

Hint

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

property diagonal_tlbr2: BorderLine2StructComp

contains a description of the top left to bottom right diagonal line of each cell.

Preferred over diagonal_tlbr.

Returns:

Returns BorderLine2.

Return type:

BorderLine2StructComp

Hint

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

property event_observer: EventObserver

Gets/Sets The Event Observer for this instance.

Return type:

EventObserver

property events_listener_chart_data_change_event: ChartDataChangeEventListener

Returns listener

Return type:

ChartDataChangeEventListener

property events_listener_modify: ModifyListener

Returns listener

Return type:

ModifyListener

property hori_justify: CellHoriJustify

Gets/Sets the horizontal alignment of the cell contents.

Returns:

Returns Horizontal Justify.

Return type:

CellHoriJustify

Hint

  • CellHoriJustifyProto can be imported from ooo.dyn.table.cell_hori_justify

property is_cell_background_transparent: bool

Gets/Sets - is True, if the cell background is transparent.

In this case the CellProperties.CellBackColor value is not used.

Return type:

bool

property is_text_wrapped: bool

Gets/Sets - is True, if text in the cells will be wrapped automatically at the right border.

Return type:

bool

property left_border: BorderLineStructComp

Gets/Sets a description of the left border line of each cell.

Setting value can be done with a BorderLine or BorderLineStructComp object.

Returns:

Returns Border Line.

Return type:

BorderLineStructComp

Hint

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

property left_border2: BorderLine2StructComp

Gets/Sets a description of the left border line of each cell.

Preferred over left_border.

Setting value can be done with a BorderLine2 or BorderLine2StructComp object.

Returns:

Returns BorderLine2.

Return type:

BorderLine2StructComp

Hint

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

property lo_inst: LoInst

Lo Instance

Return type:

LoInst

property number_format: int

Gets/Sets the index of the number format that is used in the cells.

The proper value can be determined by using the com.sun.star.util.NumberFormatter interface of the document.

Return type:

int

property office_doc: OfficeDocumentT

Office Document.

Return type:

OfficeDocumentT

property orientation: CellOrientation

Gets/Sets the orientation of the cell contents.

If the CellProperties.RotateAngle property is non-zero, this value is not used.

Returns:

Returns Cell Orientation.

Return type:

CellOrientation

Hint

  • CellOrientation can be imported from ooo.dyn.table.cell_orientation

property para_indent: UnitMM100

Gets/Sets the indentation of the cell contents (in 1/100 mm).

The value can be set with an integer (in 1/100 mm) or an UnitT object.

Returns:

Returns UnitMM100 object (unit 1/100 mm).

Return type:

UnitMM100

property range_obj: RangeObj

Range object.

Return type:

RangeObj

property right_border: BorderLineStructComp

Gets/Sets a description of the right border line of each cell.

Setting value can be done with a BorderLine or BorderLineStructComp object.

Returns:

Returns Border Line.

Return type:

BorderLineStructComp

Hint

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

property right_border2: BorderLine2StructComp

Gets/Sets a description of the right border line of each cell.

Setting value can be done with a BorderLine2 or BorderLine2StructComp object.

Preferred over right_border.

Returns:

Returns BorderLine2.

Return type:

BorderLine2StructComp

Hint

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

property rotate_angle: Angle100

Gets/Sets how much the content of cells is rotated (in 1/100 degrees).

The value can be set with an integer (in 1/100 degrees) or an AngleT object.

Return type:

Angle100

property rotate_reference: CellVertJustify2Enum

Gets/Sets at which edge rotated cells are aligned.

Returns:

Returns CellVertJustify2Enum.

Return type:

CellVertJustify2Enum

Hint

  • CellVertJustify2Enum can be imported from ooo.dyn.table.cell_vert_justify2

property shadow_format: ShadowFormatStructComp

Gets/Sets a description of the shadow.

When setting the value can be an instance of ShadowFormatStructComp or ShadowFormat.

Returns:

Shadow Format

Return type:

ShadowFormatStructComp

Hint

  • ShadowFormat can be imported from ooo.dyn.table.shadow_format

property shrink_to_fit: bool | None

Gets/Sets - is True, if the cell content will be shrunk to fit in the cell.

optional

Return type:

bool | None

property size: GenericUnitSize[UnitMM, float]

Gets the size of the cell range in UnitMM Values.

Return type:

GenericUnitSize[UnitMM, float]

property table_border: TableBorderStructComp

contains a description of the cell or cell range border.

If used with a cell range, the top, left, right, and bottom lines are at the edges of the entire range, not at the edges of the individual cell.

Setting value can be done with a TableBorder or TableBorderStructComp object.

Returns:

Table Border.

Return type:

TableBorderComp

Hint

  • TableBorder can be imported from ooo.dyn.table.table_border

property table_border2: TableBorder2StructComp

Gets/Seta a description of the cell or cell range border.

Preferred over table_border.

If used with a cell range, the top, left, right, and bottom lines are at the edges of the entire range, not at the edges of the individual cell.

Setting value can be done with a TableBorder2 or TableBorder2StructComp object.

Returns:

Returns TableBorder2 or None if not supported.

Return type:

TableBorder2StructComp | None

Hint

  • TableBorder2 can be imported from ooo.dyn.table.table_border2

property top_border: BorderLineStructComp

Gets/Sets a description of the top border line of each cell.

Setting value can be done with a BorderLine or BorderLineStructComp object.

Returns:

Returns Border Line.

Return type:

BorderLineStructComp

Hint

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

property top_border2: BorderLine2StructComp

Gets/Sets a description of the top border line of each cell.

Preferred over top_border.

Setting value can be done with a BorderLine2 or BorderLine2StructComp object.

Returns:

Returns BorderLine2.

Return type:

BorderLine2StructComp

Hint

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

property user_defined_attributes: NameContainerComp | None

Gets/Sets - stores additional attributes.

This property is used i.e. by the XML filters to load and restore unknown attributes.

Return type:

NameContainerComp | None

property vert_justify: CellVertJustify2Enum

Gets/Sets the vertical alignment of the cell contents.

When setting the value, it can be an integer or an instance of CellVertJustify2Enum.

Returns:

Returns Vertical Justify.

Return type:

CellVertJustify2Enum

Hint

  • CellVertJustify2Enum can be imported from ooo.dyn.table.cell_vert_justify2