Class Calc

class ooodev.office.calc.Calc[source]
class BorderEnum(value)[source]

An enumeration.

BOTTOM_BORDER = 2
LEFT_BORDER = 4
RIGHT_BORDER = 8
TOP_BORDER = 1
class CellTypeEnum(value)[source]

An enumeration.

EMPTY = 'EMPTY'
FORMULA = 'FORMULA'
TEXT = 'TEXT'
UNKNOWN = 'UNKNOWN'
VALUE = 'VALUE'
class HeaderFooter(value)[source]

An enumeration.

HF_CENTER = 1
HF_LEFT = 0
HF_RIGHT = 2
classmethod add_annotation(sheet, cell_name, msg)[source]
classmethod add_annotation(sheet, cell_name, msg, is_visible: bool)
classmethod add_annotation(sheet, cell_name, msg, is_visible=True)

Adds an annotation to a cell and makes the annotation visible.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • cell_name (str) – Name of cell to add annotation such as A1.

  • msg (str) – Annotation Text.

  • set_visible (bool) – Determines if the annotation is set visible.

Raises:

MissingInterfaceError – If interface is missing.

Returns:

Cell annotation that was added.

Return type:

XSheetAnnotation

classmethod add_border(sheet: com.sun.star.sheet.XSpreadsheet, cell_range: com.sun.star.table.XCellRange)[source]
classmethod add_border(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod add_border(sheet: com.sun.star.sheet.XSpreadsheet, cell_range: com.sun.star.table.XCellRange)
classmethod add_border(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod add_border(sheet: com.sun.star.sheet.XSpreadsheet, cell_range: com.sun.star.table.XCellRange)
classmethod add_border(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod add_border(*args, **kwargs)

Adds borders to a cell range.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • cell_range (XCellRange) – Cell range.

  • range_name (str) – Range Name such as A1:F9.

  • color (Color) – RGB color

  • border_vals (BorderEnum) – Determines what borders are applied.

Raises:

CancelEventError – If CELLS_BORDER_ADDING event is canceled.

Returns:

Range borders that are affected.

Return type:

XCellRange

Events:

Note

Event args cells is of type XCellRange.

Event args event_data is a dictionary containing color and border_vals.

static apply_scenario(sheet, name)[source]

Applies scenario.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • name (str) – Scenario name to apply.

Raises:

Exception – If scenario is not able to be applied.

Returns:

the applied scenario.

Return type:

XScenario

Note

A LibreOffice Calc scenario is a set of cell values that can be used within your calculations. You assign a name to every scenario on your sheet. Define several scenarios on the same sheet, each with some different values in the cells. Then you can easily switch the sets of cell values by their name and immediately observe the results. Scenarios are a tool to test out “what-if” questions.

See also

Using Scenarios

static call_fun(func_name, *args)[source]

Execute a Calc function by its (English) name and based on the given arguments.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • func_name (str) – the English name of the function to execute

  • args (Any) – (Any): the arguments of the called function. Each argument must be either a string, a numeric value or a sequence of sequences ( tuples or list ) combining those types.

Returns:

The (string or numeric) value or the array of arrays returned by the call to the function

When the arguments contain arrays, the function is executed as an array function Wrong arguments generate an error

Return type:

Any

classmethod change_style(sheet: com.sun.star.sheet.XSpreadsheet, style_name: str)[source]
classmethod change_style(sheet: com.sun.star.sheet.XSpreadsheet, style_name: str)
classmethod change_style(sheet: com.sun.star.sheet.XSpreadsheet, style_name: str)
classmethod change_style(sheet: com.sun.star.sheet.XSpreadsheet, style_name: str)
classmethod change_style(*args, **kwargs)

Changes style of a range of cells.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

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

  • cell_range (XCellRange) – Cell range to apply style to.

  • range_name (str) – Range to apply style to such as A1:E23.

  • range_obj (RangeObj) – Range Object.

  • start_col (int) – Zero-base start column index.

  • start_row (int) – Zero-base start row index.

  • end_col (int) – Zero-base end column index.

  • end_row (int) – Zero-base end row index.

Returns:

True if style has been changed; Otherwise, False.

Return type:

bool

classmethod clear_cells(sheet: com.sun.star.sheet.XSpreadsheet, cell_range: com.sun.star.table.XCellRange)[source]
classmethod clear_cells(sheet: com.sun.star.sheet.XSpreadsheet, cell_range: com.sun.star.table.XCellRange)
classmethod clear_cells(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod clear_cells(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod clear_cells(sheet: com.sun.star.sheet.XSpreadsheet, range_val: ooodev.utils.data_type.range_obj.RangeObj)
classmethod clear_cells(sheet: com.sun.star.sheet.XSpreadsheet, range_val: ooodev.utils.data_type.range_obj.RangeObj)
classmethod clear_cells(sheet: com.sun.star.sheet.XSpreadsheet, cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress)
classmethod clear_cells(sheet: com.sun.star.sheet.XSpreadsheet, cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress)
classmethod clear_cells(*args, **kwargs)

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.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • cell_range (XCellRange) – Cell range.

  • range_name (str) – Range name such as A1:G3.

  • range_val (RangeObj) – Range object.

  • cr_addr (CellRangeAddress) – Cell Range Address.

  • cell_flags (CellFlagsEnum) – Flags that determine what to clear.

Raises:

MissingInterfaceError – If XSheetOperation interface cannot be obtained.

Events:
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.

static column_number_str(col)[source]

Creates a column Name from zero base column number.

Method is Lo Instance Safe for use with multiple documents.

Columns are numbered starting at 0 where 0 corresponds to A They run as A-Z, AA-AZ, BA-BZ, …, IV

Parameters:

col (int) – Zero based column index

Returns:

Column Name

Return type:

str

static column_string_to_number(col_str)[source]

Converts a Column Name into an int. Results are zero based so a converts to 0

Method is Lo Instance Safe for use with multiple documents.

Parameters:

col_str (str) – Case insensitive column name such as ‘a’ or ‘AB’

Returns:

Zero based int representing column name

Return type:

int

classmethod compute_function(fn, cell_range)[source]

Computes a Calc Function.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • fn (GeneralFunction | str) – Function to calculate, GeneralFunction Enum value or String such as ‘SUM’ or ‘MAX’.

  • cell_range (XCellRange) – Cell range to apply function on.

Returns:

result of function if successful. If there is an error then 0.0 is returned.

Return type:

float

static convert_to_double(val)

Converts value to float.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

val (Any) – Value to convert

Returns:

value converted to float. 0.0 is returned if conversion fails.

Return type:

float

classmethod convert_to_doubles(vals)

Converts a 1d or 2d array into List of float.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

vals (Row | Table) – List or 2-Dimensional list to convert to floats.

Returns:

vals converted to float

Return type:

FloatList | FloatTable

static convert_to_float(val)[source]

Converts value to float.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

val (Any) – Value to convert

Returns:

value converted to float. 0.0 is returned if conversion fails.

Return type:

float

classmethod convert_to_floats(vals: Any) Any[source]
classmethod convert_to_floats(vals: Any) Any
classmethod convert_to_floats(vals: Any) Any
classmethod convert_to_floats(vals)

Converts a 1d or 2d array into List of float.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

vals (Row | Table) – List or 2-Dimensional list to convert to floats.

Returns:

vals converted to float

Return type:

FloatList | FloatTable

static create_cell_style(doc, style_name)[source]

Creates a style.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • doc (XSpreadsheetDocument) – Spreadsheet Document.

  • style_name (str) – Style name.

Raises:
Returns:

Newly created style.

Return type:

XStyle

static create_doc() com.sun.star.sheet.XSpreadsheetDocument[source]
static create_doc(loader: com.sun.star.frame.XComponentLoader) com.sun.star.sheet.XSpreadsheetDocument
static create_doc(*, visible: bool) com.sun.star.sheet.XSpreadsheetDocument
static create_doc(loader: com.sun.star.frame.XComponentLoader, *, visible: bool) com.sun.star.sheet.XSpreadsheetDocument
static create_doc(loader=None, **kwargs)

Creates a new spreadsheet document.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • loader (XComponentLoader) – Component Loader.

  • kwargs (Any) –

Raises:
Returns:

Spreadsheet document.

Return type:

XSpreadsheetDocument

Events:

See also

get_ss_doc()

Note

Event args event_data is a dictionary containing loader.

classmethod delete_cells(sheet: com.sun.star.sheet.XSpreadsheet, cell_range: com.sun.star.table.XCellRange)[source]
classmethod delete_cells(sheet: com.sun.star.sheet.XSpreadsheet, cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress)
classmethod delete_cells(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod delete_cells(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod delete_cells(sheet: com.sun.star.sheet.XSpreadsheet, col_start: int)
classmethod delete_cells(*args, **kwargs)

Deletes cells in a spreadsheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • cell_range (XCellRange) – Cell range to delete.

  • cr_addr (CellRangeAddress) – Cell range Address.

  • range_name (str) – Range Name such as A1:D5.

  • range_obj (RangeObj) – Range Object.

  • col_start (int) – Start Column.

  • row_start (int) – Start Row.

  • col_end (int) – End Column.

  • row_end (int) – End Row.

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

static delete_column(sheet, idx, count=1)[source]

Delete a column from a spreadsheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • idx (int) – Zero base of index of column to delete.

  • count (int, optional) – Number of columns to delete. Defaults to 1.

Events:
Returns:

True if column is deleted; Otherwise, False.

Return type:

bool

Changed in version 0.15.0: Added count parameter

static delete_row(sheet, idx, count=1)[source]

Deletes a row from spreadsheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • idx (int) – Zero based index of row to delete.

  • count (int, optional) – Number of rows to delete. Defaults to 1.

Events:
Returns:

True if row is deleted; Otherwise, False.

Return type:

bool

Changed in version 0.15.0: Added count parameter

static dispatch_recalculate()[source]

Dispatches recalculate command to the current sheet.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Also useful when needing to refresh a chart.

Return type:

None

New in version 0.9.4.

static extract_col(vals, col_idx)[source]

Extract column data and returns as a list.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • vals (Table) – 2-d table of data.

  • col_idx (int) – column index to extract.

Returns:

Column data if found; Otherwise, empty list.

Return type:

List[Any]

static extract_row(vals, row_idx)[source]

Extracts a row from a table.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • vals (Table) – Table of data.

  • row_idx (int) – Row index to extract.

Raises:

IndexError – If row_idx is out of range.

Returns:

Row of data

Return type:

Row

static find_all(srch, sd)[source]

Searches spreadsheet and returns a list of Cell Ranges that match search criteria.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • srch (XSearchable) – Searchable object.

  • sd (XSearchDescriptor) – Search description.

Returns:

A list of cell ranges on success; Otherwise, None.

Return type:

List[XCellRange] | None

Example
from ooodev.loader.lo import Lo
from ooodev.office.calc import Calc
from com.sun.star.util import XSearchable

doc = Calc.create_doc(loader)
sheet = Calc.get_sheet(doc=doc, index=0)
Calc.set_val(value='test', sheet=sheet, cell_name="A1")
Calc.set_val(value='test', sheet=sheet, cell_name="C3")
srch = Lo.qi(XSearchable, sheet)
sd = srch.createSearchDescriptor()
sd.setSearchString('test')
results = Calc.find_all(srch=srch, sd=sd)
assert len(results) == 2
classmethod find_function(func_nm: str) Tuple[PropertyValue] | None[source]
classmethod find_function(idx: int) Tuple[PropertyValue] | None
classmethod find_function(*args, **kwargs)

Finds a function.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • func_nm (str) – function name.

  • idx (int) – Index of function.

Returns:

Function properties as tuple on success; Otherwise, None.

Return type:

Tuple[PropertyValue, …] | None

static find_used_cursor(cursor)[source]

Find used cursor.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

cursor (XSheetCellCursor) – Sheet Cursor

Raises:

MissingInterfaceError – if unable to find interface

Returns:

Cell range

Return type:

XCellRange

classmethod find_used_range(sheet: com.sun.star.sheet.XSpreadsheet)[source]
classmethod find_used_range(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod find_used_range(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod find_used_range(sheet: com.sun.star.sheet.XSpreadsheet, cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress)
classmethod find_used_range(*args, **kwargs)

Find used range.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet Document.

  • range_name (str) – Range Name such as A1:D5.

  • range_obj (RangeObj) – Range Object.

  • cr_addr (CellRangeAddress) – Cell range Address.

Returns:

Cell range.

Return type:

XCellRange

classmethod find_used_range_obj(sheet: com.sun.star.sheet.XSpreadsheet)[source]
classmethod find_used_range_obj(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod find_used_range_obj(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod find_used_range_obj(sheet: com.sun.star.sheet.XSpreadsheet, cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress)
classmethod find_used_range_obj(*args, **kwargs)

Find used range.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet Document.

  • range_name (str) – Range Name such as A1:D5.

  • range_obj (RangeObj) – Range Object.

  • cr_addr (CellRangeAddress) – Cell range Address.

Returns:

Range object.

Return type:

RangeObj

New in version 0.9.0.

classmethod freeze(doc, num_cols, num_rows)[source]

Freezes spreadsheet columns and rows.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • doc (XSpreadsheetDocument) – Spreadsheet Document.

  • num_cols (int) – Number of columns to freeze.

  • num_rows (int) – Number of rows to freeze.

Return type:

None

classmethod freeze_cols(doc, num_cols)[source]

Freezes spreadsheet columns.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • doc (XSpreadsheetDocument) – Spreadsheet Document.

  • num_cols (int) – Number of columns to freeze.

Return type:

None

classmethod freeze_rows(doc, num_rows)[source]

Freezes spreadsheet rows.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • doc (XSpreadsheetDocument) – Spreadsheet Document.

  • num_rows (int) – Number of rows to freeze.

Return type:

None

classmethod get_active_sheet() com.sun.star.sheet.XSpreadsheet[source]
classmethod get_active_sheet(doc: com.sun.star.sheet.XSpreadsheetDocument) com.sun.star.sheet.XSpreadsheet
classmethod get_active_sheet(doc=None)

Gets the active sheet.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

doc (XSpreadsheetDocument, optional) – Spreadsheet Document.

Returns:

Active Sheet.

Return type:

XSpreadsheet

classmethod get_address(cell_range: com.sun.star.table.XCellRange)[source]
classmethod get_address(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod get_address(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod get_address(sheet: com.sun.star.sheet.XSpreadsheet, start_col: int)
classmethod get_address(*args, **kwargs)

Gets Range Address.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • cell_range (XCellRange) – Cell Range.

  • sheet (XSpreadsheet) – Spreadsheet.

  • range_name (str) – Range name such as A1:D7.

  • range_obj (RangeObj) – Range Object.

  • start_col (int) – Zero-base start column index.

  • start_row (int) – Zero-base start row index.

  • end_col (int) – Zero-base end column index.

  • end_row (int) – Zero-base end row index.

Raises:

MissingInterfaceError – if unable to obtain interface.

Returns:

Cell Range Address.

Return type:

CellRangeAddress

classmethod get_annotation(sheet, cell_name)[source]

Gets an annotation of a cell.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet

  • cell_name (str | CellObj) – Cell name

Raises:

MissingInterfaceError – If interface is missing

Returns:

Cell annotation on success; Otherwise, None

Return type:

XSheetAnnotation

classmethod get_annotation_str(sheet, cell_name)[source]

Gets text of an annotation for a cell.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet

  • cell_name (str | CellObj) – Cell name

Returns:

Cell annotation text

Return type:

str

classmethod get_array(cell_range: com.sun.star.table.XCellRange)[source]
classmethod get_array(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod get_array(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod get_array(sheet: com.sun.star.sheet.XSpreadsheet, cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod get_array(*args, **kwargs)

Gets Array of data from a spreadsheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • cell_range (XCellRange) – Cell range to get data from.

  • sheet (XSpreadsheet) – Spreadsheet

  • range_name (str) – Range of data to get such as “A1:E16”

  • range_obj (RangeObj) – Range object

  • cell_obj (CellObj) – Cell Object

Raises:

MissingInterfaceError – if interface is missing

Returns:

Resulting data array.

Return type:

TupleArray

classmethod get_cell(cell: com.sun.star.table.XCell)[source]
classmethod get_cell(sheet: com.sun.star.sheet.XSpreadsheet, addr: com.sun.star.table.CellAddress)
classmethod get_cell(sheet: com.sun.star.sheet.XSpreadsheet, cell_name: str)
classmethod get_cell(sheet: com.sun.star.sheet.XSpreadsheet, cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod get_cell(sheet: com.sun.star.sheet.XSpreadsheet, col: int)
classmethod get_cell(cell_range: com.sun.star.table.XCellRange)
classmethod get_cell(cell_range: com.sun.star.table.XCellRange, col: int)
classmethod get_cell(*args, **kwargs)

Gets a cell.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • addr (CellAddress) – Cell Address.

  • cell_name (str) – Cell Name such as A1.

  • cell_obj – (CellObj): Cell object.

  • cell_range (XCellRange) – Cell Range.

  • col (int) – Cell column.

  • row (int) – cell row.

  • cell (XCell) – Cell.

Returns:

cell.

Return type:

XCell

Note

if cell is passed, it is returned verbatim.

Changed in version 0.10.0: Added overload for cell argument.

classmethod get_cell_address(cell: com.sun.star.table.XCell)[source]
classmethod get_cell_address(sheet: com.sun.star.sheet.XSpreadsheet, cell_name: str)
classmethod get_cell_address(sheet: com.sun.star.sheet.XSpreadsheet, cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod get_cell_address(sheet: com.sun.star.sheet.XSpreadsheet, addr: com.sun.star.table.CellAddress)
classmethod get_cell_address(sheet: com.sun.star.sheet.XSpreadsheet, col: int)
classmethod get_cell_address(*args, **kwargs)

Gets Cell Address.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • cell (XCell) – Cell.

  • sheet (XSpreadsheet) – Spreadsheet.

  • cell_name (str) – Cell name such as A1.

  • cell_obj (CellObj) – Cell object.

  • addr (CellAddress) – Cell Address.

  • col (int) – Zero-base column index.

  • row (int) – Zero-base row index.

Raises:

MissingInterfaceError – if unable to obtain interface.

Returns:

Cell Address.

Return type:

CellAddress

classmethod get_cell_obj()[source]
classmethod get_cell_obj(cell_name: str)
classmethod get_cell_obj(addr: com.sun.star.table.CellAddress)
classmethod get_cell_obj(cell: com.sun.star.table.XCell)
classmethod get_cell_obj(cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod get_cell_obj(col: int, row: int)
classmethod get_cell_obj(*args, **kwargs)

Gets the cell as CellObj instance.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • cell_name (str) – Cell name.

  • addr (CellAddress) – Cell Address.

  • cell (XCell) – Cell.

  • cell_obj (CellObj) – Cell Object. If passed in the same CellObj is returned.

  • col (int) – Zero-based column index.

  • row (int) – Zero-based row index.

Returns:

Cell Object

Return type:

CellObj

Note

If no args are pass in then current selected cell is returned.

New in version 0.8.2.

classmethod get_cell_pos(sheet, cell_name)[source]

Contains the position of the top left cell of this range in the sheet (in 1/100 mm).

This property contains the absolute position in the whole sheet, not the position in the visible area.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet

  • cell_name (str | CellObj) – Cell name

Returns:

cell name as Point

Return type:

Point

classmethod get_cell_position(cell_name)[source]

Gets a cell name as a Point.

  • Point.X is column zero-based index.

  • Point.Y is row zero-based index.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

cell_name (str | CellObj) – Cell name

Returns:

cell name as Point with X as col and Y as row

Return type:

Point

classmethod get_cell_protection(cell: com.sun.star.table.XCell)[source]
classmethod get_cell_protection(sheet: com.sun.star.sheet.XSpreadsheet, addr: com.sun.star.table.CellAddress)
classmethod get_cell_protection(sheet: com.sun.star.sheet.XSpreadsheet, cell_name: str)
classmethod get_cell_protection(sheet: com.sun.star.sheet.XSpreadsheet, cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod get_cell_protection(sheet: com.sun.star.sheet.XSpreadsheet, col: int)
classmethod get_cell_protection(cell_range: com.sun.star.table.XCellRange)
classmethod get_cell_protection(cell_range: com.sun.star.table.XCellRange, col: int)
classmethod get_cell_protection(*args, **kwargs)

Gets cell protection.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • addr (CellAddress) – Cell Address.

  • cell_name (str) – Cell Name such as A1.

  • cell_obj – (CellObj): Cell object.

  • cell_range (XCellRange) – Cell Range.

  • col (int) – Cell column.

  • row (int) – cell row.

  • cell (XCell) – Cell.

Returns:

Cell Protection.

Return type:

com.sun.star.util.CellProtection

Warning

Cell Protection is only valid after the current sheet has been protected.

New in version 0.10.0.

classmethod get_cell_range(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)[source]
classmethod get_cell_range(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod get_cell_range(sheet: com.sun.star.sheet.XSpreadsheet, cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod get_cell_range(sheet: com.sun.star.sheet.XSpreadsheet, cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress)
classmethod get_cell_range(cell_range: com.sun.star.table.XCellRange)
classmethod get_cell_range(sheet: com.sun.star.sheet.XSpreadsheet, col_start: int)
classmethod get_cell_range(*args, **kwargs)

Gets a cell range.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet Document.

  • range_name (str) – Range Name such as A1:D5.

  • range_obj (RangeObj) – Range Object.

  • cell_obj (CellObj) – Cell Object.

  • cr_addr (CellRangeAddress) – Cell range Address.

  • cell_range (XCellRange) – Cell Range. If passed in then the same instance is returned.

  • col_start (int) – Start Column.

  • row_start (int) – Start Row.

  • col_end (int) – End Column.

  • row_end (int) – End Row.

Raises:

Exception – if unable to access cell range.

Returns:

Cell range

Return type:

XCellRange

classmethod get_cell_range_positions(range_obj: ooodev.utils.data_type.range_obj.RangeObj)[source]
classmethod get_cell_range_positions(range_values: ooodev.utils.data_type.range_values.RangeValues)
classmethod get_cell_range_positions(range_name: str)
classmethod get_cell_range_positions(*args, **kwargs)

Gets Cell range as a tuple of Point, Point.

  • First Point.X is start column index, Point.Y is start row index.

  • Second Point.X is end column index, Point.Y is end row index.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • range_name (str) – Range name such as A1:C8.

  • range_obj (RangeObj) – Range object

  • range_values (RangeValues) – Range values

Raises:

ValueError – if invalid range name

Returns:

Range as tuple. Point values are zero-based indexes.

Return type:

Tuple[Point, Point]

static get_cell_series(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)[source]
static get_cell_series(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
static get_cell_series(*args, **kwargs)

Get cell series for a range.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • range_name (str) – Range name such as A1:B7.

  • range_obj (RangeObj) – Range object.

Raises:

MissingInterfaceError – if unable to obtain interface.

Returns:

Cell series.

Return type:

XCellSeries

classmethod get_cell_str(cell_obj: ooodev.utils.data_type.cell_obj.CellObj)[source]
classmethod get_cell_str(addr: com.sun.star.table.CellAddress)
classmethod get_cell_str(cell: com.sun.star.table.XCell)
classmethod get_cell_str(col: int, row: int)
classmethod get_cell_str(*args, **kwargs)

Gets the cell as a string in format of A1.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • cell_obj (CellObj) – Cell object.

  • addr (CellAddress) – Cell address.

  • cell (XCell) – Cell.

  • col (int) – Zero-based column index.

  • row (int) – Zero-based row index.

Returns:

Cell as str.

Return type:

str

classmethod get_col(cell_range: com.sun.star.table.XCellRange)[source]
classmethod get_col(sheet: com.sun.star.sheet.XSpreadsheet, col_name: str)
classmethod get_col(sheet: com.sun.star.sheet.XSpreadsheet, col_idx: int)
classmethod get_col(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod get_col(sheet: com.sun.star.sheet.XSpreadsheet, cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod get_col(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod get_col(*args, **kwargs)

Gets a column of data from spreadsheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • cell_range (XCellRange) – Cell range to get column data from.

  • sheet (XSpreadsheet) – Spreadsheet.

  • col_name (str) – column name such as A.

  • col_idx (int) – Zero base column index such as 0 for column A.

  • range_name (str) – Range such as A1:A12.

  • range_obj (RangeObj) – Range Object.

  • cell_obj (CellObj) – Cell Object.

Returns:

1-Dimensional List.

Return type:

List[Any]

static get_col_range(sheet, idx)[source]

Get Column by index.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • idx (int) – Zero-based column index.

Raises:

MissingInterfaceError – if unable to find interface.

Returns:

Cell range.

Return type:

XCellRange

classmethod get_col_used_first_index(sheet)[source]

Gets the index of the column of the left edge of the used sheet range.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

sheet (XSpreadsheet) – Spreadsheet

Returns:

Zero based index of first column used on the sheet.

Return type:

int

classmethod get_col_used_last_index(sheet)[source]

Gets the index of the column of the right edge of the used sheet range.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

sheet (XSpreadsheet) – Spreadsheet.

Returns:

Zero based index of last column used on the sheet.

Return type:

int

classmethod get_controller() com.sun.star.frame.XController[source]
classmethod get_controller(doc: com.sun.star.sheet.XSpreadsheetDocument) com.sun.star.frame.XController
classmethod get_controller(doc=None)

Provides access to the controller which currently controls this model.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

doc (XSpreadsheetDocument, optional) – Spreadsheet Document

Raises:

MissingInterfaceError – If unable to access controller

Returns:

Controller for Spreadsheet Document

Return type:

XController | None

classmethod get_current_doc()[source]

Gets the current document.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Raises:

NoneError – If no current document

Returns:

Spreadsheet Document

Return type:

XSpreadsheetDocument

classmethod get_doubles_array(*args, **kwargs)

Gets a 2-Dimensional List of floats.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • cell_range (XCellRange) – Cell range to get data from.

  • sheet (XSpreadsheet) – Spreadsheet to get the float values from.

  • range_name (str) – Range to get array of floats from such as A1:E18.

  • range_obj (RangeObj) – Range object.

  • cell_obj (CellObj) – Cell Object.

Returns:

2-Dimensional List of floats.

Return type:

FloatTable

classmethod get_float_array(cell_range: com.sun.star.table.XCellRange)[source]
classmethod get_float_array(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod get_float_array(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod get_float_array(sheet: com.sun.star.sheet.XSpreadsheet, cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod get_float_array(*args, **kwargs)

Gets a 2-Dimensional List of floats.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • cell_range (XCellRange) – Cell range to get data from.

  • sheet (XSpreadsheet) – Spreadsheet to get the float values from.

  • range_name (str) – Range to get array of floats from such as A1:E18.

  • range_obj (RangeObj) – Range object.

  • cell_obj (CellObj) – Cell Object.

Returns:

2-Dimensional List of floats.

Return type:

FloatTable

static get_function_names()[source]

Get a list of all function names.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Returns:

List of function names if found; Otherwise, None

Return type:

List[str] | None

static get_head_foot(props, content)[source]

Gets header footer content.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • props (XPropertySet) – Properties.

  • content (str) – content.

Raises:

MissingInterfaceError – If unable to obtain XHeaderFooterContent interface.

Returns:

Header Footer Content

Return type:

XHeaderFooterContent

classmethod get_num(cell: com.sun.star.table.XCell)[source]
classmethod get_num(sheet: com.sun.star.sheet.XSpreadsheet, cell_name: str)
classmethod get_num(sheet: com.sun.star.sheet.XSpreadsheet, cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod get_num(sheet: com.sun.star.sheet.XSpreadsheet, addr: com.sun.star.table.CellAddress)
classmethod get_num(sheet: com.sun.star.sheet.XSpreadsheet, col: int)
classmethod get_num(*args, **kwargs)

Get cell value a float.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • cell (XCell) – Cell to get value of.

  • sheet (XSpreadsheet) – Spreadsheet.

  • cell_name (str) – Cell name such as B4.

  • cell_obj (CellObj) – Cell Object.

  • addr (CellAddress) – Cell Address.

  • col (int) – Cell zero-base column number.

  • row (int) – Cell zero-base row number.

Returns:

Cell value as float. If cell value cannot be converted then 0.0 is returned.

Return type:

float

static get_pilot_table(dp_tables, name)[source]

Get a pivot table (formerly known as DataPilot) from a XDataPilotTables instance.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • dp_tables (XDataPilotTables) – Instance that contains the table.

  • name (str) – Name of the table to get.

Raises:

Exception – If table is not found or other error has occurred.

Returns:

Table.

Return type:

XDataPilotTable

static get_pilot_tables(sheet)[source]

Gets pivot tables (formerly known as DataPilot) for a sheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

sheet (XSpreadsheet) – Spreadsheet

Raises:

MissingInterfaceError – If a required interface is missing.

Returns:

Pivot tables

Return type:

XDataPilotTables

static get_pivot_table(dp_tables, name)

Get a pivot table (formerly known as DataPilot) from a XDataPilotTables instance.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • dp_tables (XDataPilotTables) – Instance that contains the table.

  • name (str) – Name of the table to get.

Raises:

Exception – If table is not found or other error has occurred.

Returns:

Table.

Return type:

XDataPilotTable

static get_pivot_tables(sheet)

Gets pivot tables (formerly known as DataPilot) for a sheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

sheet (XSpreadsheet) – Spreadsheet

Raises:

MissingInterfaceError – If a required interface is missing.

Returns:

Pivot tables

Return type:

XDataPilotTables

classmethod get_range_obj(range_name: str)[source]
classmethod get_range_obj(cell_range: com.sun.star.table.XCellRange)
classmethod get_range_obj(cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress)
classmethod get_range_obj(range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod get_range_obj(cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod get_range_obj(cell_range: com.sun.star.table.XCellRange, sheet: com.sun.star.sheet.XSpreadsheet)
classmethod get_range_obj(col_start: int, row_start: int)
classmethod get_range_obj(col_start: int, row_start: int)
classmethod get_range_obj(*args, **kwargs)

Gets a range Object representing a range.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • range_name (str) – Cell range as string.

  • cell_range (XCellRange) – Cell Range.

  • sheet (XSpreadsheet) – Spreadsheet.

  • cr_addr (CellRangeAddress) – Cell Range Address.

  • cell_obj (CellObj) – Cell Object.

  • range_obj (RangeObj) – Range Object. If passed in the same RangeObj is returned.

  • col_start (int) – Zero-based start column index.

  • row_start (int) – Zero-based start row index.

  • col_end (int) – Zero-based end column index.

  • row_end (int) – Zero-based end row index.

Returns:

Range object.

Return type:

RangeObj

New in version 0.8.2.

classmethod get_range_size(range_obj: ooodev.utils.data_type.range_obj.RangeObj)[source]
classmethod get_range_size(cell_range: com.sun.star.table.XCellRange)
classmethod get_range_size(cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress)
classmethod get_range_size(col_start: int, row_start: int)
classmethod get_range_size(*args, **kwargs)

Gets range size.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • range_obj (RangeObj) – Range Object.

  • cell_range (XCellRange) – Cell Range.

  • cr_addr (CellRangeAddress) – Cell Range Address.

  • col_start (int) – Zero-based start column index.

  • row_start (int) – Zero-based start row index.

  • col_end (int) – Zero-based end column index.

  • row_end (int) – Zero-based end row index.

Returns:

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

Return type:

Size

New in version 0.8.2.

classmethod get_range_str(cell_range: com.sun.star.table.XCellRange)[source]
classmethod get_range_str(range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod get_range_str(cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress)
classmethod get_range_str(cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod get_range_str(cell_range: com.sun.star.table.XCellRange, sheet: com.sun.star.sheet.XSpreadsheet)
classmethod get_range_str(cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress, sheet: com.sun.star.sheet.XSpreadsheet)
classmethod get_range_str(col_start: int, row_start: int)
classmethod get_range_str(col_start: int, row_start: int)
classmethod get_range_str(*args, **kwargs)

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.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • cell_range (XCellRange) – Cell Range

  • range_obj (RangeObj) – Range Object

  • cr_addr (CellRangeAddress) – Cell Range Address

  • cell_obj (CellObj) – Cell Object

  • sheet (XSpreadsheet) – Spreadsheet

  • col_start (int) – Zero-based start column index

  • row_start (int) – Zero-based start row index

  • col_end (int) – Zero-based end column index

  • row_end (int) – Zero-based end row index

Returns:

range as string

Return type:

str

static get_recent_functions()[source]

Gets recent functions.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Returns:

Tuple of integers that point to functions

Return type:

Tuple[int, …] | None

classmethod get_region(hfc, region)[source]

Get region for Header-Footer-Content.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • hfc (XHeaderFooterContent) – Content.

  • region (HeaderFooter) – Region to get.

Raises:

TypeError – If hfc or region is not a valid type.

Returns:

interface instance

Return type:

XText

classmethod get_row(cell_range: com.sun.star.table.XCellRange)[source]
classmethod get_row(sheet: com.sun.star.sheet.XSpreadsheet, row_idx: int)
classmethod get_row(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod get_row(sheet: com.sun.star.sheet.XSpreadsheet, cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod get_row(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod get_row(*args, **kwargs)

Gets a row of data from spreadsheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • cell_range (XCellRange) – Cell range to get column data from.

  • row_idx (int) – Zero base row index such as 0 for row 1

  • sheet (XSpreadsheet) – Spreadsheet.

  • range_name (str) – Range such as A1:A12.

  • cell_obj (CellObj) – Cell Object.

  • range_obj (RangeObj) – Range Object.

Returns:

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

Return type:

Row

static get_row_range(sheet, idx)[source]

Get Row by index.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • idx (int) – Zero-based column index.

Raises:

MissingInterfaceError – if unable to find interface.

Returns:

Cell range.

Return type:

XCellRange

classmethod get_row_used_first_index(sheet)[source]

Gets the index of the row of the top edge of the used sheet range.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

sheet (XSpreadsheet) – Spreadsheet.

Returns:

Zero based index of first row used on the sheet.

Return type:

int

classmethod get_row_used_last_index(sheet)[source]

Gets the index of the row of the bottom edge of the used sheet range.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

sheet (XSpreadsheet) – Spreadsheet.

Returns:

Zero based index of last row used on the sheet.

Return type:

int

classmethod get_safe_rng_str(range_name)[source]
classmethod get_safe_rng_str(range_name, allow_cell_name)
classmethod get_safe_rng_str(range_name, allow_cell_name=False)

Gets safe range string.

If range name is out of order then correct order is returned.

For instance:

  • A7:B2 returns A2:B7

  • R7:B22 returns B7:R22

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • range_name (str) – range name such as A1.B7 or Sheet1.A1.B7.

  • allow_cell_name (bool) – Determines if range_name accepts cell name input.

Returns:

Range name as string with correct column an row order.

Return type:

str

Note

If allow_cell_name is True and range_name is a cell name then the cell name is converted into a range string.

  • C2 is returned as C2:C2

  • Sheet1.C2 is returned as Sheet1.C2:C2

New in version 0.9.0.

classmethod get_selected_addr(doc: com.sun.star.sheet.XSpreadsheetDocument)[source]
classmethod get_selected_addr(model: com.sun.star.frame.XModel)
classmethod get_selected_addr(*args, **kwargs)

Gets select cell range addresses.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • doc (XSpreadsheetDocument) – Spreadsheet Document.

  • model (XModel) – model used to access sheet.

Raises:
  • Exception – if unable to get document model.

  • MissingInterfaceError – if unable to get interface XCellRangeAddressable.

Returns:

Cell range addresses.

Return type:

CellRangeAddress

classmethod get_selected_cell() ooodev.utils.data_type.cell_obj.CellObj[source]
classmethod get_selected_cell(doc: com.sun.star.sheet.XSpreadsheetDocument) ooodev.utils.data_type.cell_obj.CellObj
classmethod get_selected_cell(doc=None)

Gets the cell address of current selected cell of the active sheet.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

doc (XSpreadsheetDocument, Optional) – Spreadsheet document

Raises:

CellError – if active selection is not a single cell

Returns:

Cell Address

Return type:

CellAddress

Note

CellAddress returns Zero-base values. For instance: Cell B4 has Column value of 1 and Row value of 3

classmethod get_selected_cell_addr(doc)[source]

Gets the cell address of current selected cell of the active sheet.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

doc (XSpreadsheetDocument) – Spreadsheet document

Raises:

CellError – if active selection is not a single cell

Returns:

Cell Address

Return type:

CellAddress

Note

CellAddress returns Zero-base values. For instance: Cell B4 has Column value of 1 and Row value of 3

classmethod get_selected_range(doc: com.sun.star.sheet.XSpreadsheetDocument)[source]
classmethod get_selected_range(model: com.sun.star.frame.XModel)
classmethod get_selected_range(*args, **kwargs)

Gets select cell range.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • doc (XSpreadsheetDocument) – Spreadsheet Document

  • model (XModel) – model used to access sheet

Raises:
  • Exception – if unable to get document model

  • MissingInterfaceError – if unable to get interface XCellRangeAddressable

Returns:

Cell range addresses

Return type:

RangeObj

New in version 0.8.2.

classmethod get_sheet()[source]
classmethod get_sheet(idx: int)
classmethod get_sheet(sheet_name: str)
classmethod get_sheet(doc: com.sun.star.sheet.XSpreadsheetDocument)
classmethod get_sheet(doc: com.sun.star.sheet.XSpreadsheetDocument, idx: int)
classmethod get_sheet(doc: com.sun.star.sheet.XSpreadsheetDocument, sheet_name: str)
classmethod get_sheet(*args, **kwargs)

Gets a sheet of spreadsheet document.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • doc (XSpreadsheetDocument, optional) – Spreadsheet document.

  • idx (int, optional) – Zero based index of spreadsheet. Defaults to 0.

  • sheet_name (str, optional) – Name of spreadsheet.

Raises:
  • Exception – If spreadsheet is not found.

  • CancelEventError – If SHEET_GETTING event is canceled.

Returns:

Spreadsheet at index.

Return type:

XSpreadsheet

Events:

Note

For Event args, if index is available then name is None and if sheet_name is available then index is None.

Changed in version 0.6.10: Added overload get_sheet(doc: XSpreadsheetDocument) -> XSpreadsheet

Changed in version 0.8.6: Added overload get_sheet() -> XSpreadsheet. Added overload get_sheet(idx: int) -> XSpreadsheet. Added overload get_sheet(sheet_name: str) -> XSpreadsheet. Changed get_sheet(doc: XSpreadsheetDocument, index: int) to get_sheet(doc: XSpreadsheetDocument, idx: int)

classmethod get_sheet_index() int[source]
classmethod get_sheet_index(sheet: com.sun.star.sheet.XSpreadsheet) int
classmethod get_sheet_index(sheet=None)

Gets index if sheet.

Parameters:

sheet (XSpreadsheet, optional) – Spread sheet. Defaults to active sheet.

Returns:

Sheet Index.

Return type:

int

classmethod get_sheet_name()[source]
classmethod get_sheet_name(safe_quote: bool)
classmethod get_sheet_name(idx: int)
classmethod get_sheet_name(idx: int, safe_quote: bool)
classmethod get_sheet_name(sheet: com.sun.star.sheet.XSpreadsheet)
classmethod get_sheet_name(sheet: com.sun.star.sheet.XSpreadsheet, safe_quote: bool)
classmethod get_sheet_name(*args, **kwargs)

Gets the name of a sheet.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • sheet (XSpreadsheet, optional) – Spreadsheet

  • idx (int, optional) – Index of Spreadsheet

  • safe_quote (bool, optional) – If True, returns quoted (in single quotes) sheet name if the sheet name is not alphanumeric. Defaults to True.

Raises:

MissingInterfaceError – If unable to access spreadsheet named interface

Returns:

Name of sheet

Return type:

str

Changed in version 0.8.6: Added overload get_sheet_name(idx: int) -> str

Changed in version 0.11.12: Added safe_quote parameter.

static get_sheet_name_from_code_name(doc, code_name)[source]

Gets the sheet name from the code name.

Parameters:
  • doc (XSpreadsheetDocument) – Spreadsheet document.

  • code_name (str) – The sheet code name. Case insensitive.

Returns:

The sheet name or an empty string if not found.

Return type:

str

New in version 0.44.1.

classmethod get_sheet_names() Tuple[str, ...][source]
classmethod get_sheet_names(doc: com.sun.star.sheet.XSpreadsheetDocument) Tuple[str, ...]
classmethod get_sheet_names(doc=None)

Gets names of all existing spreadsheets in the spreadsheet document.

Parameters:

doc (XSpreadsheetDocument, optional) – Document to get sheets names of.

Returns:

Tuple of sheet names.

Return type:

Tuple[str, …]

Changed in version 0.8.6: Added overload get_sheet_names() -> Tuple[str, ...]

classmethod get_sheets() com.sun.star.sheet.XSpreadsheets[source]
classmethod get_sheets(doc: com.sun.star.sheet.XSpreadsheetDocument) com.sun.star.sheet.XSpreadsheets
classmethod get_sheets(doc=None)

Gets all existing spreadsheets in the spreadsheet document.

Parameters:

doc (XSpreadsheetDocument, optional) – Document to get sheets of.

Returns:

document sheets

Return type:

XSpreadsheets

static get_solvers()[source]

Get solvers.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Return type:

None

New in version 0.9.1.

static get_ss_doc(doc)[source]

Gets a spreadsheet document.

When using this method in a macro the Lo.this_component value should be passed as doc arg.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

doc (XComponent) – Component to get spreadsheet from

Raises:
  • Exception – If not a spreadsheet document

  • MissingInterfaceError – If doc does not have XSpreadsheetDocument interface

Returns:

spreadsheet document

Return type:

XSpreadsheetDocument

Events:

See also

create_doc()

classmethod get_string(cell: com.sun.star.table.XCell)[source]
classmethod get_string(sheet: com.sun.star.sheet.XSpreadsheet, cell_name: str)
classmethod get_string(sheet: com.sun.star.sheet.XSpreadsheet, cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod get_string(sheet: com.sun.star.sheet.XSpreadsheet, addr: com.sun.star.table.CellAddress)
classmethod get_string(sheet: com.sun.star.sheet.XSpreadsheet, col: int)
classmethod get_string(*args, **kwargs)

Gets the value of a cell as a string.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • cell (XCell) – Cell to get value of.

  • sheet (XSpreadsheet) – Spreadsheet.

  • cell_name (str) – Name of cell to get the value of such as B4.

  • addr (CellAddress) – Cell address.

  • cell_obj (CellObj) – Cell Object.

  • col (int) – Cell zero-based column number.

  • row (int) – Cell zero-based row number.

Returns:

Cell value as string.

Return type:

str

static get_type_enum(cell)[source]

Gets enum representing the Type.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

cell (XCell) – Cell to get type of

Returns:

Enum of cell type

Return type:

CellTypeEnum

classmethod get_type_string(cell)[source]

Gets String representing the Type.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

cell (XCell) – Cell to get type of

Returns:

String of cell type

Return type:

str

classmethod get_val(cell: com.sun.star.table.XCell)[source]
classmethod get_val(sheet: com.sun.star.sheet.XSpreadsheet, addr: com.sun.star.table.CellAddress)
classmethod get_val(sheet: com.sun.star.sheet.XSpreadsheet, cell_name: str)
classmethod get_val(sheet: com.sun.star.sheet.XSpreadsheet, cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod get_val(sheet: com.sun.star.sheet.XSpreadsheet, col: int)
classmethod get_val(*args, **kwargs)

Gets cell value.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • cell (XCell) – cell to get value of.

  • sheet (XSpreadsheet) – Spreadsheet.

  • addr (CellAddress) – Address of cell.

  • cell_name (str) – Name of cell such as B4.

  • cell_obj (CellObj) – Cell Object.

  • col (int) – Cell zero-based column.

  • row (int) – Cell zero-base row.

Returns:

Cell value cell has a value; Otherwise, None.

Return type:

Any

classmethod get_view(doc)[source]

Is the main interface of a SpreadsheetView.

It manages the active sheet within this view.

The com.sun.star.sheet.SpreadsheetView service is the spreadsheet’s extension of the com.sun.star.frame.Controller service and represents a table editing view for a spreadsheet document.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

doc (XSpreadsheetDocument) – Spreadsheet Document.

Returns:

XSpreadsheetView.

Return type:

XSpreadsheetView

classmethod get_view_data(doc)[source]

Gets a set of data that can be used to restore the current view status at later time by using set_view_data().

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

doc (XSpreadsheetDocument) – Spreadsheet Document

Returns:

View Data

Return type:

str

classmethod get_view_panes(doc)[source]

Represents a pane in a view of a spreadsheet document.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

doc (XSpreadsheetDocument) – Spreadsheet Document.

Raises:

MissingInterfaceError – if unable access the view pane container.

Returns:

List of XViewPane on success; Otherwise, None.

Return type:

List[XViewPane] | None

Note

The com.sun.star.sheet.XViewPane interface’s getFirstVisibleColumn(), getFirstVisibleRow(), setFirstVisibleColumn() and setFirstVisibleRow() methods query and set the start of the exposed area. The getVisibleRange() method returns a com.sun.star.table. CellRangeAddress struct describing which cells are shown in the pane. Columns or rows that are only partly visible at the right or lower edge of the view are not included.

classmethod get_view_states(doc)[source]

Extract the view states for all the sheets from the view data. The states are returned as an array of ViewState objects.

The view data string has the format 100/60/0;0;tw:879;0/4998/0/1/0/218/2/0/0/4988/4998.

The view state info starts after the third ;, the fourth entry. The view state for each sheet is separated by ;

Based on a post by user Hanya to: openoffice forum

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

doc (XSpreadsheetDocument) – Spreadsheet Document

Return type:

None

classmethod goal_seek(gs, sheet, cell_name, formula_cell_name, result)[source]

Calculates a value which gives a specified result in a formula.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • gs (XGoalSeek) – Goal seeking value for cell

  • sheet (XSpreadsheet) – Spreadsheet

  • cell_name (str | CellObj) – cell name

  • formula_cell_name (str | CellObj) – formula cell name

  • result (int, float) – float or int, result of the goal seek

Raises:

GoalDivergenceError – If goal divergence is greater than 0.1

Returns:

result of the goal seek

Return type:

float

classmethod goto_cell(cell_name: str, doc: com.sun.star.sheet.XSpreadsheetDocument)[source]
classmethod goto_cell(cell_obj: ooodev.utils.data_type.cell_obj.CellObj, doc: com.sun.star.sheet.XSpreadsheetDocument)
classmethod goto_cell(cell_name: str, frame: com.sun.star.frame.XFrame)
classmethod goto_cell(cell_obj: ooodev.utils.data_type.cell_obj.CellObj, frame: com.sun.star.frame.XFrame)
classmethod goto_cell(*args, **kwargs)

Go to a cell.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • cell_name (str) – Cell Name such as ‘B4’

  • doc (XSpreadsheetDocument) – Spreadsheet Document

  • frame (XFrame) – Spreadsheet frame.

Return type:

None

Attention

dispatch_cmd() method is called along with any of its events.

Dispatch command is GoToCell.

Return type:

None

classmethod highlight_range(sheet: com.sun.star.sheet.XSpreadsheet, headline: str) com.sun.star.table.XCell[source]
classmethod highlight_range(sheet: com.sun.star.sheet.XSpreadsheet, headline: str) com.sun.star.table.XCell
classmethod highlight_range(sheet: com.sun.star.sheet.XSpreadsheet, headline: str) com.sun.star.table.XCell
classmethod highlight_range(sheet: com.sun.star.sheet.XSpreadsheet, headline: str) com.sun.star.table.XCell
classmethod highlight_range(sheet: com.sun.star.sheet.XSpreadsheet, headline: str) com.sun.star.table.XCell
classmethod highlight_range(sheet: com.sun.star.sheet.XSpreadsheet, headline: str) com.sun.star.table.XCell
classmethod highlight_range(*args, **kwargs)

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

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • headline (str) – Headline.

  • cell_range (XCellRange) – Cell Range.

  • range_name (str) – Range Name such as ‘A1:F9’.

  • range_obj (RangeObj) – Range Object

  • color (Color) – RGB color.

Raises:

CancelEventError – If CELLS_HIGH_LIGHTING event is canceled.

Returns:

First cell of range that headline ia applied on.

Return type:

XCell

Events:

Note

Event args cells is of type XCellRange.

Event args event_data is a dictionary containing color and headline.

classmethod insert_cells(sheet: com.sun.star.sheet.XSpreadsheet, cell_range: com.sun.star.table.XCellRange)[source]
classmethod insert_cells(sheet: com.sun.star.sheet.XSpreadsheet, cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress)
classmethod insert_cells(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod insert_cells(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod insert_cells(sheet: com.sun.star.sheet.XSpreadsheet, col_start: int)
classmethod insert_cells(*args, **kwargs)

Inserts Cells into a spreadsheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • cell_range (XCellRange) – Cell range to insert.

  • cr_addr (CellRangeAddress) – Cell range Address.

  • range_name (str) – Range Name such as A1:D5.

  • range_obj (RangeObj) – Range Object.

  • col_start (int) – Start Column.

  • row_start (int) – Start Row.

  • col_end (int) – End Column.

  • row_end (int) – End Row.

  • is_shift_right (bool) – If True then cell are inserted to the right; Otherwise, inserted down.

Events:
Returns:

True if cells are inserted; Otherwise, False.

Return type:

bool

Note

Events args for this method have a cell type of XCellRange

Event args event_data is a dictionary containing is_shift_right.

static insert_column(sheet, idx, count=1)[source]

Inserts a column in a spreadsheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • idx (int) – Zero base index of column to insert.

  • count (int, optional) – Number of columns to insert. Defaults to 1.

Events:
Returns:

True if column has been inserted; Otherwise, False.

Return type:

bool

Changed in version 0.15.0: Added count parameter

static insert_row(sheet, idx, count=1)[source]

Inserts a row in spreadsheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet

  • idx (int) – Zero base index of row to insert.

  • count (int, optional) – Number of rows to insert. Defaults to 1.

Events:
Returns:

True if row has been inserted; Otherwise, False.

Return type:

bool

Changed in version 0.15.0: Added count parameter

static insert_scenario(sheet, range_name, vals, name, comment)[source]

Insert a scenario into sheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • range_name (str | RangeObj) – Range name.

  • vals (Table) – 2d array of values.

  • name (str) – Scenario name.

  • comment (str) – Scenario description.

Raises:

MissingInterfaceError – If a required interface is missing.

Returns:

the newly created scenario.

Return type:

XScenario

Note

A LibreOffice Calc scenario is a set of cell values that can be used within your calculations. You assign a name to every scenario on your sheet. Define several scenarios on the same sheet, each with some different values in the cells. Then you can easily switch the sets of cell values by their name and immediately observe the results. Scenarios are a tool to test out “what-if” questions.

See also

Using Scenarios

static insert_sheet(doc, name, idx)[source]

Inserts a spreadsheet into document.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • doc (XSpreadsheetDocument) – Spreadsheet document

  • name (str) – Name of sheet to insert

  • idx (int) – zero-based index position of the sheet to insert

Raises:
  • Exception – If unable to insert spreadsheet

  • CancelEventError – If SHEET_INSERTING event is canceled

Returns:

The newly inserted sheet

Return type:

XSpreadsheet

Events:
classmethod is_cell_protected(cell: com.sun.star.table.XCell)[source]
classmethod is_cell_protected(sheet: com.sun.star.sheet.XSpreadsheet, addr: com.sun.star.table.CellAddress)
classmethod is_cell_protected(sheet: com.sun.star.sheet.XSpreadsheet, cell_name: str)
classmethod is_cell_protected(sheet: com.sun.star.sheet.XSpreadsheet, cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod is_cell_protected(sheet: com.sun.star.sheet.XSpreadsheet, col: int)
classmethod is_cell_protected(cell_range: com.sun.star.table.XCellRange)
classmethod is_cell_protected(cell_range: com.sun.star.table.XCellRange, col: int)
classmethod is_cell_protected(*args, **kwargs)

Gets whether a cell is protected.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • cell (XCell) – Sheet Cell.

  • sheet (XSpreadsheet) – Spreadsheet.

  • addr – (CellAddress): Cell address.

  • cell_name – (str): Cell name.

  • cell_obj – (CellObj): Cell object.

  • col (int) – Cell column.

  • row (int) – cell row.

  • cell_range (XCellRange) – Cell Range.

Returns:

True if protected; Otherwise, False

Return type:

bool

Warning

Cell Protection is only valid after the current sheet has been protected.

New in version 0.10.0.

static is_cell_range_name(s)[source]

Gets if is a cell name or a cell range.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

s (str) – cell name such as ‘A1’ or range name such as ‘B3:E7’

Returns:

True if range name; Otherwise, False

Return type:

bool

static is_equal_addresses(addr1: com.sun.star.table.CellAddress, addr2: com.sun.star.table.CellAddress)[source]
static is_equal_addresses(addr1: ooo.lo.table.cell_range_address.CellRangeAddress, addr2: ooo.lo.table.cell_range_address.CellRangeAddress)
static is_equal_addresses(addr1, addr2)

Gets if two instances of CellRangeAddress are equal.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • addr1 (CellAddress | CellRangeAddress) – Cell address or cell range address.

  • addr2 (CellAddress | CellRangeAddress) – Cell address or cell range address.

Returns:

True if equal; Otherwise, False.

Return type:

bool

classmethod is_merged_cells(cell_range: com.sun.star.table.XCellRange)[source]
classmethod is_merged_cells(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod is_merged_cells(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod is_merged_cells(sheet: com.sun.star.sheet.XSpreadsheet, cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress)
classmethod is_merged_cells(col_start: int, row_start: int)
classmethod is_merged_cells(*args, **kwargs)

Gets is a range of cells is merged.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet Document.

  • range_name (str) – Range Name such as A1:D5.

  • range_obj (RangeObj) – Range Object.

  • cr_addr (CellRangeAddress) – Cell range Address.

  • cell_range (XCellRange) – Cell Range.

  • col_start (int) – Start Column.

  • row_start (int) – Start Row.

  • col_end (int) – End Column.

  • row_end (int) – End Row.

Returns:

True if range is merged; Otherwise, False

Return type:

bool

New in version 0.8.4.

static is_sheet_protected(sheet)[source]

Gets whether a sheet is protected.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

sheet (XSpreadsheet) – Sheet to check

Returns:

True if protected; Otherwise, False

Return type:

bool

New in version 0.10.0.

static is_single_cell_range(cr_addr)[source]

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

Method is Lo Instance Safe for use with multiple documents.

Parameters:

cr_addr (CellRangeAddress) – cell range address

Returns:

True if single cell; Otherwise, False

Return type:

bool

static is_single_column_range(cr_addr)[source]

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

Method is Lo Instance Safe for use with multiple documents.

Parameters:

cr_addr (CellRangeAddress) – cell range address

Returns:

True if single column; Otherwise, False

Return type:

bool

Note

If cr_addr is a single cell address then True is returned.

New in version 0.8.2.

static is_single_row_range(cr_addr)[source]

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

Method is Lo Instance Safe for use with multiple documents.

Parameters:

cr_addr (CellRangeAddress) – cell range address

Returns:

True if single row; Otherwise, False

Return type:

bool

Note

If cr_addr is a single cell address then True is returned.

New in version 0.8.2.

static list_solvers()[source]

Prints solvers.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Return type:

None

classmethod make_constraint(num: int | float, op: str)[source]
classmethod make_constraint(num: int | float, op: ooo.lo.sheet.solver_constraint_operator.SolverConstraintOperator)
classmethod make_constraint(num: int | float, op: str)
classmethod make_constraint(num: int | float, op: str)
classmethod make_constraint(num: int | float, op: ooo.lo.sheet.solver_constraint_operator.SolverConstraintOperator)
classmethod make_constraint(*args, **kwargs)

Makes a constraint for a solver model.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • num (Number) – Constraint number such as float or int.

  • op (str | SolverConstraintOperator) – Operation such as <=.

  • addr (CellAddress) – Cell Address.

  • cell_name (str) – Cell name such as A1.

  • cell_obj (CellObj) – Cell Object.

  • sheet (XSpreadsheet) – Spreadsheet.

Returns:

Solver constraint that can be use in a solver model.

Return type:

SolverConstraint

classmethod merge_cells(cell_range: com.sun.star.table.XCellRange)[source]
classmethod merge_cells(cell_range: com.sun.star.table.XCellRange, center: bool)
classmethod merge_cells(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod merge_cells(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod merge_cells(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod merge_cells(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod merge_cells(sheet: com.sun.star.sheet.XSpreadsheet, cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress)
classmethod merge_cells(sheet: com.sun.star.sheet.XSpreadsheet, cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress)
classmethod merge_cells(col_start: int, row_start: int)
classmethod merge_cells(*args, **kwargs)

Merges a range of cells.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet Document.

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

  • range_name (str) – Range Name such as A1:D5.

  • range_obj (RangeObj) – Range Object.

  • cr_addr (CellRangeAddress) – Cell range Address.

  • cell_range (XCellRange) – Cell Range.

  • col_start (int) – Start Column.

  • row_start (int) – Start Row.

  • col_end (int) – End Column.

  • row_end (int) – End Row.

Return type:

None

New in version 0.8.4.

static move_sheet(doc, name, idx)[source]

Moves a sheet in a spreadsheet document.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • doc (XSpreadsheetDocument) – Spreadsheet document.

  • name (str) – Name of sheet to move.

  • idx (int) – The zero based index to move sheet into.

Returns:

True on success; Otherwise, False.

Return type:

bool

Events:
classmethod open_doc() com.sun.star.sheet.XSpreadsheetDocument[source]
classmethod open_doc(fnm: Any) com.sun.star.sheet.XSpreadsheetDocument
classmethod open_doc(*, visible: bool) com.sun.star.sheet.XSpreadsheetDocument
classmethod open_doc(fnm: Any, *, visible: bool) com.sun.star.sheet.XSpreadsheetDocument
classmethod open_doc(*, loader: com.sun.star.frame.XComponentLoader) com.sun.star.sheet.XSpreadsheetDocument
classmethod open_doc(*, loader: com.sun.star.frame.XComponentLoader, visible: bool) com.sun.star.sheet.XSpreadsheetDocument
classmethod open_doc(fnm: Any, loader: com.sun.star.frame.XComponentLoader) com.sun.star.sheet.XSpreadsheetDocument
classmethod open_doc(fnm: Any, loader: com.sun.star.frame.XComponentLoader, *, visible: bool) com.sun.star.sheet.XSpreadsheetDocument
classmethod open_doc(fnm=None, loader=None, **kwargs)

Opens or creates a spreadsheet document.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • fnm (str) – Spreadsheet file to open. If omitted then a new Spreadsheet document is returned.

  • loader (XComponentLoader) – Component loader

  • kwargs (Any) –

Raises:

CancelEventError – If DOC_OPENING is canceled

Returns:

Spreadsheet document

Return type:

XSpreadsheetDocument

Events:

Note

Event args event_data is a dictionary containing all method parameters.

If fnm is omitted then DOC_OPENED event will not be raised.

classmethod print_address(cell_range: com.sun.star.table.XCellRange)[source]
classmethod print_address(cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress)
classmethod print_address(*args, **kwargs)

Prints Cell range to console such as Range: Sheet1.C3:F22.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • cell_range (XCellRange) – Cell range.

  • cr_addr (CellRangeAddress) – Cell Address.

Return type:

None

Changed in version 0.6.10: Removed cancel event args.

classmethod print_addresses(*cr_addrs)[source]

Prints Address for one or more CellRangeAddress.

Method is Lo Instance Safe for use with multiple documents.

Return type:

None

Parameters:

cr_addrs (CellRangeAddress) –

Changed in version 0.6.10: Removed cancel event args.

static print_array(vals: Any) None[source]
static print_array(vals: Any, format_opt: ooodev.formatters.formatter_table.FormatterTable) None
static print_array(vals, format_opt=None)

Prints a 2-Dimensional array to console.

Method is Lo Instance Safe for use with multiple documents.

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

  • format_opt (FormatterTable, optional) – Optional format used to format values when printing to console such as FormatterTable(format=".2f")

Return type:

None

Changed in version 0.6.6: Added format_opt parameter

Changed in version 0.6.10: Removed cancel event args.

classmethod print_cell_address(cell: com.sun.star.table.XCell)[source]
classmethod print_cell_address(addr: com.sun.star.table.CellAddress)
classmethod print_cell_address(*args, **kwargs)

Prints Cell to console such as Cell: Sheet1.D3

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • cell (XCell) – cell

  • addr (CellAddress) – Cell Address

Return type:

None

Changed in version 0.6.10: Removed cancel event args.

classmethod print_fun_arguments(prop_vals)[source]

Prints Function Arguments to console.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

prop_vals (Sequence[PropertyValue]) – Property values

Return type:

None

Changed in version 0.6.10: Removed cancel event args.

classmethod print_function_info(func_name)[source]

Prints Function Info to console.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

func_name (str) – Function name

Return type:

None

Changed in version 0.6.10: Removed cancel event args.

static print_head_foot(title, hfc)[source]

Prints header, footer to console.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • title (str) – Title printed to console.

  • hfc (XHeaderFooterContent) – Content.

Return type:

None

Changed in version 0.6.10: Removed cancel event args.

classmethod print_sheet(*, printer_name, range_name: str)[source]
classmethod print_sheet(*, printer_name, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod print_sheet(*, printer_name, cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod print_sheet(*, printer_name, cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress)
classmethod print_sheet(*, printer_name, cell_range: com.sun.star.table.XCellRange)
classmethod print_sheet(*, printer_name, **kwargs)

Print a sheet to the specified printer directly.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • printer_name (str) – Name of Printer to use such as “Brother MFC-L2750DW series”

  • idx (int, optional) – Index of sheet to print. If not specified then the active sheet is used.

  • range_name (str) – Range Name such as A1:D5

  • range_obj (RangeObj) – Range Object

  • cell_obj (CellObj) – Cell Object

  • cr_addr (CellRangeAddress) – Cell range Address

  • cell_range (XCellRange) – Cell Range. If passed in then the same instance is returned.

  • doc (XSpreadsheetDocument, optional) – Document to use. If not specified then the active document is used.

Raises:
  • ValueError – If printer_name is not specified

  • ValueError – If no range is specified

Return type:

None

New in version 0.11.2.

static protect_sheet(sheet, password)[source]

Protects a Spreadsheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Sheet to protect.

  • password (str) – Password to protect sheet with.

Returns:

True on success; Otherwise, False

Return type:

bool

New in version 0.10.0.

classmethod remove_border(sheet: com.sun.star.sheet.XSpreadsheet, cell_range: com.sun.star.table.XCellRange)[source]
classmethod remove_border(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod remove_border(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod remove_border(sheet: com.sun.star.sheet.XSpreadsheet, cell_range: com.sun.star.table.XCellRange)
classmethod remove_border(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod remove_border(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod remove_border(*args, **kwargs)

Removes borders of a cell range.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • cell_range (XCellRange) – Cell range.

  • range_name (str) – Range Name such as A1:F9.

  • range_obj (RangeObj) – Range Object.

  • border_vals (BorderEnum) – Determines what borders are applied.

Raises:

CancelEventError – If CELLS_BORDER_REMOVING event is canceled.

Returns:

Range borders that are affected.

Return type:

XCellRange

Events:

Note

Event args cells is of type XCellRange.

Event arg properties modified on CELLS_BORDER_REMOVING it is reflected in this method.

See also

add_border()

classmethod remove_sheet(doc: com.sun.star.sheet.XSpreadsheetDocument, sheet_name: str)[source]
classmethod remove_sheet(doc: com.sun.star.sheet.XSpreadsheetDocument, idx: int)
classmethod remove_sheet(*args, **kwargs)

Removes a sheet from document.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • doc (XSpreadsheetDocument) – Spreadsheet document.

  • sheet_name (str) – Name of sheet to remove.

  • idx (int) – Zero based index of sheet to remove.

Returns:

True of sheet was removed; Otherwise, False.

Return type:

bool

Events:

Note

Event args event_data is set to a dictionary. If idx is available then args event_data["fn_type"] is set to a value idx; Otherwise, set to a value name.

Changed in version 0.8.6: Renamed index arg to idx. index will still work but is now undocumented.

static row_string_to_number(row_str)[source]

Converts a string containing an int into an int.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

row_str (str) – string to convert

Returns:

Number if conversion succeeds; Otherwise, 0

Return type:

int

static save_doc(doc, fnm)[source]

Saves text document.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • text_doc (XSpreadsheetDocument) – Text Document

  • fnm (PathOrStr) – Path to save as

  • doc (XSpreadsheetDocument) –

Raises:

MissingInterfaceError – If doc does not implement XComponent interface

Returns:

True if doc is saved; Otherwise, False

Return type:

bool

Events:

Note

Event args event_data is a dictionary containing text_doc and fnm.

Attention

Lo.save_doc method is called along with any of its events.

classmethod set_active_sheet(doc, sheet)[source]

Sets the active sheet.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • doc (XSpreadsheetDocument) – Spreadsheet Document

  • sheet (XSpreadsheet) – Sheet to set active

Events:
Return type:

None

Note

Event arg properties modified on SHEET_ACTIVATING it is reflected in this method.

Return type:

None

Parameters:
  • doc (XSpreadsheetDocument) –

  • sheet (XSpreadsheet) –

classmethod set_array(values: Any, cell_range: com.sun.star.table.XCellRange)[source]
classmethod set_array(values: Any, cell_range: com.sun.star.table.XCellRange)
classmethod set_array(values: Any, sheet: com.sun.star.sheet.XSpreadsheet)
classmethod set_array(values: Any, sheet: com.sun.star.sheet.XSpreadsheet)
classmethod set_array(values: Any, sheet: com.sun.star.sheet.XSpreadsheet)
classmethod set_array(values: Any, sheet: com.sun.star.sheet.XSpreadsheet)
classmethod set_array(values: Any, sheet: com.sun.star.sheet.XSpreadsheet)
classmethod set_array(values: Any, sheet: com.sun.star.sheet.XSpreadsheet)
classmethod set_array(values: Any, doc: com.sun.star.sheet.XSpreadsheetDocument)
classmethod set_array(values: Any, doc: com.sun.star.sheet.XSpreadsheetDocument)
classmethod set_array(values: Any, sheet: com.sun.star.sheet.XSpreadsheet)
classmethod set_array(values: Any, sheet: com.sun.star.sheet.XSpreadsheet)
classmethod set_array(*args, **kwargs)

Inserts array of data into spreadsheet.

Method is Lo Instance Safe for use with multiple documents.

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

  • cell_range (XCellRange) – Range in spreadsheet to insert data.

  • sheet (XSpreadsheet) – Spreadsheet.

  • name (str) – Range name such as ‘A1:D4’ or cell name such as B4.

  • range_obj (RangeObj) – Range Object.

  • cell_obj (CellObj) – Cell Object.

  • doc (XSpreadsheetDocument) – Spreadsheet Document.

  • addr (CellAddress) – Address to insert data.

  • col_start (int) – Zero-base Start Column.

  • row_start (int) – Zero-base Start Row.

  • col_end (int) – Zero-base End Column.

  • row_end (int) – Zero-base End Row.

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

Return type:

None

Changed in version 0.9.1: Added overloads for styles.

classmethod set_array_cell(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)[source]
classmethod set_array_cell(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod set_array_cell(sheet: com.sun.star.sheet.XSpreadsheet, cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod set_array_cell(sheet: com.sun.star.sheet.XSpreadsheet, cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod set_array_cell(*args, **kwargs)

Inserts array of data into spreadsheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • range_name (str) – Range to insert data such as A1:E12.

  • cell_obj (CellObj) – Range Object,

  • 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

Changed in version 0.9.1: Added overloads for styles.

classmethod set_array_range(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)[source]
classmethod set_array_range(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod set_array_range(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod set_array_range(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod set_array_range(*args, **kwargs)

Inserts array of data into spreadsheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • range_name (str) – Range to insert data such as A1:E12.

  • range_obj (RangeObj) – Range Object.

  • 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

Changed in version 0.9.1: Added overloads for styles.

static set_cell_range_array(cell_range: com.sun.star.table.XCellRange, values: Any) None[source]
static set_cell_range_array(cell_range: com.sun.star.table.XCellRange, values: Any, styles: Sequence[ooodev.proto.style_obj.StyleT]) None
static set_cell_range_array(cell_range, values, styles=None)

Inserts array of data into spreadsheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • cell_range (XCellRange) – Cell Range

  • 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

Changed in version 0.9.1: Added overloads for styles.

classmethod set_col(sheet: com.sun.star.sheet.XSpreadsheet, values: Any)[source]
classmethod set_col(sheet: com.sun.star.sheet.XSpreadsheet, values: Any)
classmethod set_col(sheet: com.sun.star.sheet.XSpreadsheet, values: Any)
classmethod set_col(*args, **kwargs)

Inserts a column of data into spreadsheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • values (Column) – Column Data.

  • cell_name (str) – Name of Cell to begin the insert such as A1.

  • cell_obj (CellObj) – Cell Object.

  • col_start (int) – Zero-base column index.

  • row_start (int) – Zero-base row index.

Return type:

None

classmethod set_col_width(sheet, width, idx)[source]

Sets column width. width is in mm, e.g. 6

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet

  • width (int, UnitT) – Width in mm units or Class UnitT.

  • idx (int) – Index of column.

Raises:

CancelEventError – If SHEET_COL_WIDTH_SETTING event is canceled.

Returns:

Column cell range that width is applied on or None if column width <= 0

Return type:

XCellRange | None

Events:

Note

Event args index is set to idx value, event_data is set to width value (mm100 units).

Changed in version 0.9.4: width can now also be UnitT

classmethod set_date(sheet, cell_name, day, month, year)[source]

Writes a date with standard date format into a spreadsheet.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • cell_name (str | CellObj) – Cell name.

  • day (int) – Date day part.

  • month (int) – Date month part.

  • year (int) – Date year part.

Return type:

None

classmethod set_head_foot(hfc, region, text)[source]

Sets the Header-Footer-Content.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • hfc (XHeaderFooterContent) – Content.

  • region (HeaderFooter) – Region to set.

  • text (str) – Text to set.

Return type:

None

classmethod set_row(sheet: com.sun.star.sheet.XSpreadsheet, values: Any)[source]
classmethod set_row(sheet: com.sun.star.sheet.XSpreadsheet, values: Any)
classmethod set_row(sheet: com.sun.star.sheet.XSpreadsheet, values: Any)
classmethod set_row(*args, **kwargs)

Inserts a row of data into spreadsheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • values (Row) – Row Data.

  • cell_obj (CellObj) – Cell Object.

  • cell_name (str) – Name of Cell to begin the insert such as A1.

  • col_start (int) – Zero-base column index.

  • row_start (int) – Zero-base row index.

Raises:

MissingInterfaceError – if unable to obtain interface.

Return type:

None

classmethod set_row_height(sheet, height, idx)[source]

Sets column width. height is in mm, e.g. 6.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet

  • height (int, UnitT) – Width in mm units or Class UnitT.

  • idx (int) – Index of Row

Raises:

CancelEventError – If SHEET_ROW_HEIGHT_SETTING event is canceled.

Returns:

Row cell range that height is applied on or None if height <= 0.

Return type:

XCellRange | None

Events:

Note

Event args index is set to idx value, event_data is set to height value (mm100 units).

Changed in version 0.9.4: width can now also be UnitT

classmethod set_selected_addr(doc: com.sun.star.sheet.XSpreadsheetDocument, sheet: com.sun.star.sheet.XSpreadsheet) CellRangeAddress | None[source]
classmethod set_selected_addr(doc: com.sun.star.sheet.XSpreadsheetDocument, sheet: com.sun.star.sheet.XSpreadsheet) CellRangeAddress | None
classmethod set_selected_addr(*args, **kwargs)

Selects cells in a Spreadsheet.

If range_name is omitted then deselection is preformed.

Parameters:
  • doc (XSpreadsheetDocument) – Spreadsheet document

  • sheet (XSpreadsheet) – Spreadsheet

  • range_val (str | RangeObj) – Range name

Returns:

Cell range address of the current selection if successful, otherwise None

Return type:

CellRangeAddress | None

New in version 0.8.1.

classmethod set_selected_range(doc: com.sun.star.sheet.XSpreadsheetDocument, sheet: com.sun.star.sheet.XSpreadsheet, range_val: ooodev.utils.data_type.range_obj.RangeObj) ooodev.utils.data_type.range_obj.RangeObj[source]
classmethod set_selected_range(doc: com.sun.star.sheet.XSpreadsheetDocument, sheet: com.sun.star.sheet.XSpreadsheet, range_val: str) ooodev.utils.data_type.range_obj.RangeObj
classmethod set_selected_range(doc: com.sun.star.sheet.XSpreadsheetDocument, sheet: com.sun.star.sheet.XSpreadsheet) ooodev.utils.data_type.range_obj.RangeObj
classmethod set_selected_range(doc, sheet, range_val='')

Selects cells in a Spreadsheet.

If range_name is omitted then deselection is preformed.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • doc (XSpreadsheetDocument) – Spreadsheet document.

  • sheet (XSpreadsheet) – Spreadsheet.

  • range_val (str) – Range name such as A1:G3 or RangeObj.

Returns:

Cell range address of the current selection if successful, otherwise None.

Return type:

CellRangeAddress | None

New in version 0.8.2.

classmethod set_sheet_name(name: str)[source]
classmethod set_sheet_name(sheet: com.sun.star.sheet.XSpreadsheet, name: str)
classmethod set_sheet_name(*args, **kwargs)

Sets the name of a spreadsheet.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet to set name of.

  • name (str) – New name for spreadsheet.

Returns:

True on success; Otherwise, False.

Return type:

bool

classmethod set_style_cell(sheet: com.sun.star.sheet.XSpreadsheet, addr: com.sun.star.table.CellAddress)[source]
classmethod set_style_cell(sheet: com.sun.star.sheet.XSpreadsheet, cell_name: str)
classmethod set_style_cell(sheet: com.sun.star.sheet.XSpreadsheet, cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod set_style_cell(sheet: com.sun.star.sheet.XSpreadsheet, col: int)
classmethod set_style_cell(cell_range: com.sun.star.table.XCellRange, *, styles: Sequence[ooodev.proto.style_obj.StyleT])
classmethod set_style_cell(cell_range: com.sun.star.table.XCellRange, col: int)
classmethod set_style_cell(*args, **kwargs)

Set style/formatting on cell.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • addr (CellAddress) – Cell Address.

  • cell_name (str) – Cell Name such as A1.

  • cell_obj – (CellObj): Cell object.

  • cell_range (XCellRange) – Cell Range.

  • col (int) – Cell column.

  • row (int) – cell row.

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

Return type:

None

New in version 0.9.2.

classmethod set_style_range(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)[source]
classmethod set_style_range(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod set_style_range(sheet: com.sun.star.sheet.XSpreadsheet, cell_obj: ooodev.utils.data_type.cell_obj.CellObj)
classmethod set_style_range(sheet: com.sun.star.sheet.XSpreadsheet, cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress)
classmethod set_style_range(cell_range: com.sun.star.table.XCellRange, *, styles: Sequence[ooodev.proto.style_obj.StyleT])
classmethod set_style_range(sheet: com.sun.star.sheet.XSpreadsheet, col_start: int)
classmethod set_style_range(*args, **kwargs)

Set style/formatting on cell range.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet Document.

  • range_name (str) – Range Name such as A1:D5.

  • range_obj (RangeObj) – Range Object.

  • cell_obj (CellObj) – Cell Object.

  • cr_addr (CellRangeAddress) – Cell range Address.

  • cell_range (XCellRange) – Cell Range. If passed in then the same instance is returned.

  • col_start (int) – Start Column.

  • row_start (int) – Start Row.

  • col_end (int) – End Column.

  • row_end (int) – End Row.

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

Return type:

None

New in version 0.9.2.

classmethod set_val(value: object, cell: com.sun.star.table.XCell)[source]
classmethod set_val(value: object, cell: com.sun.star.table.XCell)
classmethod set_val(value: object, sheet: com.sun.star.sheet.XSpreadsheet)
classmethod set_val(value: object, sheet: com.sun.star.sheet.XSpreadsheet)
classmethod set_val(value: object, sheet: com.sun.star.sheet.XSpreadsheet)
classmethod set_val(value: object, sheet: com.sun.star.sheet.XSpreadsheet)
classmethod set_val(value: object, sheet: com.sun.star.sheet.XSpreadsheet)
classmethod set_val(value: object, sheet: com.sun.star.sheet.XSpreadsheet)
classmethod set_val(*args, **kwargs)

Sets the value of a cell.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • value (object) – Value for cell.

  • cell (XCell) – Cell to assign value.

  • sheet (XSpreadsheet) – Spreadsheet.

  • cell_name (str) – Name of cell to set value of such as B4.

  • cell_obj (CellObj) – Cell Object.

  • col (int) – Cell column as zero-based integer.

  • row (int) – Cell row as zero-based integer.

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

Return type:

None

Changed in version 0.9.1: Added overloads for styles.

classmethod set_view_data(doc, view_data)[source]

Restores the view status using the data gotten from a previous call to get_view_data()

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • doc (XSpreadsheetDocument) – Spreadsheet Document

  • view_data (str) – Data to restore.

Return type:

None

classmethod set_view_states(doc, states)[source]

Updates the sheet state part of the view data, which starts as the fourth entry in the view data string.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • doc (XSpreadsheetDocument) – spreadsheet document

  • states (Sequence[ViewState]) – Sequence of ViewState objects.

Return type:

None

classmethod solver_report(solver)[source]

Prints the result of solver.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

solver (XSolver) – Solver to print result of.

Return type:

None

classmethod split_window(doc, cell_name)[source]

Splits window.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • doc (XSpreadsheetDocument) – Spreadsheet Document.

  • cell_name (str) – Cell to preform split on. e.g. C4.

Return type:

None

static to_constraint_op(op)[source]

Convert string value to SolverConstraintOperator.

If op is not valid then SolverConstraintOperator.EQUAL is returned.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

op (str) – Operator such as =, ==, <=, =<, >=, =>

Returns:

Operator as enum

Return type:

SolverConstraintOperator

classmethod unfreeze(doc)[source]

UN-Freezes spreadsheet columns and/or rows.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

doc (XSpreadsheetDocument) – Spreadsheet Document.

Return type:

None

classmethod unmerge_cells(cell_range: com.sun.star.table.XCellRange)[source]
classmethod unmerge_cells(sheet: com.sun.star.sheet.XSpreadsheet, range_name: str)
classmethod unmerge_cells(sheet: com.sun.star.sheet.XSpreadsheet, range_obj: ooodev.utils.data_type.range_obj.RangeObj)
classmethod unmerge_cells(sheet: com.sun.star.sheet.XSpreadsheet, cr_addr: ooo.lo.table.cell_range_address.CellRangeAddress)
classmethod unmerge_cells(col_start: int, row_start: int)
classmethod unmerge_cells(*args, **kwargs)

Removes merging from a range of cells.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet Document.

  • range_name (str) – Range Name such as A1:D5.

  • range_obj (RangeObj) – Range Object.

  • cr_addr (CellRangeAddress) – Cell range Address.

  • cell_range (XCellRange) – Cell Range.

  • col_start (int) – Start Column.

  • row_start (int) – Start Row.

  • col_end (int) – End Column.

  • row_end (int) – End Row.

Return type:

None

New in version 0.8.4.

static unprotect_sheet(sheet, password)[source]

Unprotect a Spreadsheet.

If sheet is not protected, this method will still return True.

If incorrect password is provided, this method will return False.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Sheet to unprotect.

  • password (str) – Password to unprotect sheet with.

Returns:

True on success; Otherwise, False

Return type:

bool

New in version 0.10.0.

classmethod zoom(doc, type)[source]

Zooms spreadsheet document to a specific view.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • doc (XSpreadsheetDocument) – Spreadsheet Document

  • type (GUI.ZoomEnum) – Type of Zoom to set.

Return type:

None

classmethod zoom_value(doc, value)[source]

Sets the zoom level of the Spreadsheet Document.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • doc (XSpreadsheetDocument) – Spreadsheet Document

  • value (int) – Value to set zoom. e.g. 160 set zoom to 160%

Return type:

None

CELL_POS = <ooo.lo.awt.point.Point object>
MAX_VALUE = 2147483647
NO_DATE = 'FILL_DATE_DAY'