[8 - недопустимая координата или диапазон - Microsoft Excel Python - PullRequest
0 голосов
/ 14 марта 2020

У меня есть эта функция, чтобы поместить дату в таблицу Excel. Однако каждый раз, когда я запускаю его, я получаю ошибку координаты. Я пытался отладить его, но не смог выяснить источник проблемы. Кто-нибудь сможет мне помочь?

Функция:

def addDate():
# Get and format date
date = datetime.today().strftime('X%m/X%d')
date = date.replace('X0', 'X').replace('X', '')
# character number for "B"
cellStartNum = ord('B')
# Flag boolean to exit loop
emptyDateCell = False

while not emptyDateCell:
    # Get Current cell location
    currentCell = str(chr(cellStartNum)) + '8'
    # If the date is already there, then you do not need to add another column
    if ws[currentCell] == date:
        break
    else:
        # # If cell is not empty, move over one cell horizontally
        if ws[currentCell] != '':
            cellStartNum = cellStartNum + 1
        else:
            # If cell is empty, write the date
            ws[currentCell] = date
            ws[currentCell].font = Font(bold=True)
            emptyDateCell = True

Ошибка:

[8 - недопустимая координата или диапазон

...