ebm.services.spreadsheet module
- class SpreadsheetCell(column: int, row: int, value: object)[source]
Bases:
objectA class to represent a cell in a spreadsheet.
Attributes
- columnint
The column number of the cell.
- rowint
The row number of the cell.
- valueobject
The value contained in the cell.
Methods
- spreadsheet_cell() -> str
Returns the cell’s address in A1 notation.
- replace(**kwargs) -> ‘SpreadsheetCell’
Returns a new SpreadsheetCell with updated attributes.
- first_row(cell_range) -> tuple
Returns the first row of cells in the given range.
- first_column(cell_range) -> tuple
Returns the first column of cells in the given range.
- submatrix(cell_range) -> tuple
Returns the submatrix excluding the first row and column.
- column: int
- row: int
- value: object
- spreadsheet_cell() str[source]
Returns the cell’s address in A1 notation.
Returns
- str
The cell’s address in A1 notation.
- replace(**kwargs) SpreadsheetCell[source]
Returns a new SpreadsheetCell with updated attributes.
Parameters
- **kwargsdict
The attributes to update.
Returns
- SpreadsheetCell
A new SpreadsheetCell with updated attributes.
- classmethod first_row(cell_range)[source]
Returns the first row of cells in the given range.
Parameters
- cell_rangestr
The range of cells in A1 notation.
Returns
- tuple
A tuple of SpreadsheetCell objects representing the first row.
- classmethod first_column(cell_range)[source]
Returns the first column of cells in the given range.
Parameters
- cell_rangestr
The range of cells in A1 notation.
Returns
- tuple
A tuple of SpreadsheetCell objects representing the first column.
- classmethod submatrix(cell_range)[source]
Returns the submatrix excluding the first row and column.
Parameters
- cell_rangestr
The range of cells in A1 notation.
Returns
- tuple
A tuple of SpreadsheetCell objects representing the submatrix.
Examples
the_range = “A1:C3” submatrix = SpreadsheetCell.submatrix(the_range) for cell in submatrix:
print(cell.spreadsheet_cell(), cell.column, cell.row)
B2 2 2 C2 3 2 B3 2 3 C3 3 3
- __init__(column: int, row: int, value: object) None
- iter_cells(first_column: str = 'E', left_padding: str = '') Generator[str, None, None][source]
Returns spreadsheet column names from A up to ZZ Parameters: - first_column Letter of the first column to return. Default (E) - left_padding Padding added in front of single letter columns. Default empty Returns: - Generator supplying a column name