Class WriteTableColumn
- class ooodev.write.table.write_table_column.WriteTableColumn(owner, idx)[source]
Bases:
WriteDocPropPartial,WriteTablePropPartial,EventsPartial,LoInstPropsPartialRepresents writer table column.
- Parameters:
owner (Any) –
idx (int) –
- __getitem__(key)[source]
Returns the Write Table Cell. The cell must exist in the current column.
- Parameters:
key (Any) – Key. can be a integer such as
2for row index (-1get last cell in col,-2second last) or a string such as “A1” or aCellObj.- Raises:
IndexError – If the key is out of range.
- Returns:
Table Cell Object.
- Return type:
Note
If key is an integer then it is assumed to be a row index. If key is a string then it is assumed to be a cell name.
Cell names and
CellObjare relative to the current column. If the current column is the first column of the table then the cell names andCellObjare the same as the parent table. If the column index is 3 thencol[`A1`]is the same astable[`C1`].No mater the column index the first cell of the column is always
col[0]orcol['A1'].Example
>>> table = doc.tables[0] >>> row = table.rows[3] >>> cell = row["A1"] # or row[0] >>> print(cell, cell.value) WriteTableCell(cell_name=A4) Goldfinger
- __init__(owner, idx)[source]
Constructor
- Parameters:
owner (Any) – Owner of this instance.
idx (int) –
- Return type:
None
- __iter__()[source]
Iterates through the cells of the row.
- Return type:
Generator[WriteTableCell,None,None]
- add_event_observers(*args)
Adds observers that gets their
triggermethod called when this classtriggermethod is called.- Parameters:
args (EventObserver) – One or more observers to add.
- Return type:
None
Note
Observers are removed automatically when they are out of scope.
- get_column_data(as_floats=False, start_row_idx=0)[source]
Gets the data of the column.
- Parameters:
as_floats (bool, optional) – If
Truethen get all values as floats. If the cell is not a number then it is converted to0.0. Defaults toFalse.start_row_idx (int, optional) – Start Row Index. Zero Based. Can be negative to get from end. Defaults to
0.
- Returns:
Column data. If
as_floatsisTruethen all values are floats.- Return type:
Tuple[float | str | None, …]
- remove_event_observer(observer)
Removes an observer
- Parameters:
observer (EventObserver) – One or more observers to add.
- Returns:
Trueif observer has been removed; Otherwise,False.- Return type:
bool
- subscribe_event(event_name, callback)
Add an event listener to current instance.
- Parameters:
event_name (str) – Event Name.
callback (EventCallback) – Callback of the event listener.
- Return type:
None
- trigger_event(event_name, event_args)
Trigger an event on current instance.
- Parameters:
event_name (str) – Event Name.
event_args (EventArgsT) – Event Args.
- Return type:
None
- unsubscribe_event(event_name, callback)
Remove an event listener from current instance.
- Parameters:
event_name (str) – Event Name.
callback (EventCallback) – Callback of the event listener.
- Return type:
None
- property event_observer: EventObserver
Gets/Sets The Event Observer for this instance.
- Return type:
- property index: int
Index of this column.
- Return type:
int
- property office_doc: OfficeDocumentT
Office Document.
- Return type:
- property owner: Any
Owner of this instance.
- Return type:
Any
- property write_table: WriteTable[Any]
Write Document.
- Return type:
WriteTable[Any]