1)
from openpyxl.utils import get_column_letter,column_index_from string
get_column_letter(3)
column_index_from_string('C')
2)
from openpyxl.utils.cell import coordinate_from_string, column_index_from_string
xy = coordinate_from_string('A4') #
returns ('A',4)
col = column_index_from_string(xy[0]) #
returns 1
row = xy[1]
3)
def num_to_letter(row, col):
row = str(row+1)
if col <=25:#Z是25,A是0
index = col + ord('A')
return chr(index)+row
else:
col_1 = (col // 26) - 1 + ord('A')
col_2 = (col % 26) + ord('A')
return chr(col_1)+chr(col_2)+row