openpyxl に,openpyxl.utils.cell というモジュールがあって,便利な? 関数が色々定義されている.説明 を読めばわかるものも多いが,一応,実行例を書き留めておく.
from openpyxl.utils.cell import get_column_interval, coord....
get_column_interval(1,4) =
['A', 'B', 'C', 'D']
coordinate_from_string('B12') =
('B', 12)
absolute_coordinate('B12') =
$B$12
get_column_letter(28) =
AB
column_index_from_string('AC') =
29
range_boundaries('C5:J20') =
(3, 5, 10, 20)
list(rows_from_range('C5:D7'))) =
[('C5', 'D5'), ('C6', 'D6'), ('C7', 'D7')]
Note: This is not a list but a generator
list(cols_from_range('C5:D7'))) =
[('C5', 'C6', 'C7'), ('D5', 'D6', 'D7')]
Note: This is not a list but a generator
coordinate_to_tuple('C8') =
(8, 3)
range_to_tuple('wsname!C5:D7') =
('wsname', (3, 5, 4, 7))
quote_sheetname('sheet name') =
'sheet name'
これは,以下のコードを実行して得られた出力.
import openpyxl
print(f'''
from openpyxl.utils.cell import get_column_interval, coord....
get_column_interval(1,4) =
{openpyxl.utils.cell.get_column_interval(1,4)}
coordinate_from_string('B12') =
{openpyxl.utils.cell.coordinate_from_string('B12')}
absolute_coordinate('B12') =
{openpyxl.utils.cell.absolute_coordinate('B12')}
get_column_letter(28) =
{openpyxl.utils.cell.get_column_letter(28)}
column_index_from_string('AC') =
{openpyxl.utils.cell.column_index_from_string('AC')}
range_boundaries('C5:J20') =
{openpyxl.utils.cell.range_boundaries('C5:J20')}
list(rows_from_range('C5:D7'))) =
{list(openpyxl.utils.cell.rows_from_range('C5:D7'))}
Note: This is not a list but a generator
list(cols_from_range('C5:D7'))) =
{list(openpyxl.utils.cell.cols_from_range('C5:D7'))}
Note: This is not a list but a generator
coordinate_to_tuple('C8') =
{openpyxl.utils.cell.coordinate_to_tuple('C8')}
range_to_tuple('wsname!C5:D7') =
{openpyxl.utils.cell.range_to_tuple('wsname!C5:D7')}
quote_sheetname('sheet name') =
{openpyxl.utils.cell.quote_sheetname('sheet name')}
''')