openpyxl.utils.cell module

Collection of utilities used within the package and also available for client code

openpyxl.utils.cell.absolute_coordinate(coord_string)[source]

Convert a coordinate to an absolute coordinate string (B12 -> $B$12)

openpyxl.utils.cell.cols_from_range(range_string)[source]

Get individual addresses for every cell in a range. Yields one row at a time.

openpyxl.utils.cell.column_index_from_string(col)[source]

Convert ASCII column name (base 26) to decimal with 1-based index

Characters represent descending multiples of powers of 26

“AFZ” == 26 * pow(26, 0) + 6 * pow(26, 1) + 1 * pow(26, 2)

openpyxl.utils.cell.coordinate_from_string(coord_string)[source]

Convert a coordinate string like ‘B12’ to a tuple (‘B’, 12)

openpyxl.utils.cell.coordinate_to_tuple(coordinate)[source]

Convert an Excel style coordinate to (row, column) tuple

openpyxl.utils.cell.get_column_interval(start, end)[source]

Given the start and end columns, return all the columns in the series.

The start and end columns can be either column letters or 1-based indexes.

openpyxl.utils.cell.get_column_letter(col_idx)[source]

Convert decimal column position to its ASCII (base 26) form.

Because column indices are 1-based, strides are actually pow(26, n) + 26 Hence, a correction is applied between pow(26, n) and pow(26, 2) + 26 to prevent and additional column letter being prepended

“A” == 1 == pow(26, 0) “Z” == 26 == pow(26, 0) + 26 // decimal equivalent 10 “AA” == 27 == pow(26, 1) + 1 “ZZ” == 702 == pow(26, 2) + 26 // decimal equivalent 100

openpyxl.utils.cell.quote_sheetname(sheetname)[source]

Add quotes around sheetnames if they contain spaces.

openpyxl.utils.cell.range_boundaries(range_string)[source]

Convert a range string into a tuple of boundaries: (min_col, min_row, max_col, max_row) Cell coordinates will be converted into a range with the cell at both end

openpyxl.utils.cell.range_to_tuple(range_string)[source]

Convert a worksheet range to the sheetname and maximum and minimum coordinate indices

openpyxl.utils.cell.rows_from_range(range_string)[source]

Get individual addresses for every cell in a range. Yields one row at a time.